Имя пользователя:
Пароль:
 

Показать сообщение отдельно

Аватара для Yashied

Старожил


Сообщения: 206
Благодарности: 88

Профиль | Отправить PM | Цитировать


Вложения
Тип файла: 7z F42Notepad.7z
(341.9 Kb, 31 просмотров)

Код: Выделить весь код
#AutoIt3Wrapper_Icon=F4.ico

#NoTrayIcon

#Include <HotKey.au3>
#Include <Misc.au3>

Opt('TrayMenuMode', 3)

_Singleton('F42Notepad')

_HotKeyAssign(0x73, '_F4', -1, '[REGEXPCLASS:(Explore|Cabinet)WClass]')

$Exit = TrayCreateItem('Exit')
TraySetIcon(@ScriptFullPath)
TraySetToolTip('F42Notepad')

While 1
    Switch TrayGetMsg()
        Case $Exit
            Exit
    EndSwitch
WEnd

Func _F4()

    Local $aList = _WindowsExplorer_ExtractSelectedDirAndFiles(WinGetHandle(''))

    If Not @error Then
        For $i = 2 To $aList[0] + 1
            If Not StringInStr(FileGetAttrib($aList[$i]), 'D') Then
                Run(@SystemDir & '\Notepad.exe "' & $aList[$i] & '"')
            EndIf
        Next
    EndIf
EndFunc   ;==>_F4

; ===================================================================================================================
; Name...........: _WindowsExplorer_ExtractSelectedDirAndFiles
; Description....: Function to extract LocationURL and selected files from a "Windows Explorer" Window
; Syntax.........: _WindowsExplorer_ExtractSelectedDirAndFiles($hWnd)
; Parameters.....: $hWnd - Windows handle of an "Windows Explorer" Window
; AutoIt Version.: 3.3.6.1
; Return values..: Success  -   Array
;                               Array[0] = Number of files selected in right-hand Listview
;                               Array[1] = LocationURL - selected in left-hand Treeview or Window Rebar
;                               Array[2] - Array[n] = URL of selected files in right-hand Listview
;                  Failure  -   Array
;                               Array[0] = 0
;                               Array[1] = ""
;                               Sets the @error flag to non-zero.
;                               @error = 1 - $hwnd is not a valid window handle
;                               @error = 2 - $hwnd is not a window handle for an "Windows Explorer" Window
;                               @error = 3 - "Shell.Application" object could not be created
;                               @error = 4 - "$oShellApp.Windows()" object could not be created
; Author.........: Ascend4nt, KaFu, klaus.s
; ===================================================================================================================

Func _WindowsExplorer_ExtractSelectedDirAndFiles($hWnd, $oError = 0)
    Local $aExplorerSelectedFiles[2] = [0, ""]
    If Not IsHWnd($hWnd) Then Return SetError(1, 0, $aExplorerSelectedFiles)
    Local $aWinList = WinList("[REGEXPCLASS:(Explore|Cabinet)WClass]")
    While 1
        For $i = 1 To UBound($aWinList) - 1
            If $hWnd = $aWinList[$i][1] Then ExitLoop 2
        Next
        Return SetError(2, 0, $aExplorerSelectedFiles)
    WEnd
    If Not IsObj($oError) And Not ObjEvent("AutoIt.Error") Then $oError = ObjEvent("AutoIt.Error", "_WindowsExplorer_ExtractSelectedDirAndFiles")
    Local $fErrorHandling = False
    If IsObj($oError) Then $fErrorHandling = True
    Local $oShellApp = ObjCreate("Shell.Application")
    If Not IsObj($oShellApp) Then Return SetError(3, 0, $aExplorerSelectedFiles)
    Local $oShellApp_Windows = $oShellApp.Windows()
    If Not IsObj($oShellApp_Windows) Then Return SetError(4, 0, $aExplorerSelectedFiles)
    For $oShellApp_Inst In $oShellApp_Windows
        If $oShellApp_Inst.hwnd = $hWnd Then ExitLoop
    Next
    Local $iShellApp_Inst_SelectedItems_Count = $oShellApp_Inst.Document.SelectedItems.Count
    If $fErrorHandling And $oError.number Then Return SetError(5, 0, $aExplorerSelectedFiles)
    Local $sShellApp_Inst_LocationURL = $oShellApp_Inst.LocationURL
    Local $aRet = DllCall('shlwapi.dll', 'long', 'PathCreateFromUrlW', 'wstr', $sShellApp_Inst_LocationURL, 'wstr', '', 'dword*', 65534, 'dword', 0)
    If Not @error And $aRet[0] = 0 Then $sShellApp_Inst_LocationURL = $aRet[2]
    $aExplorerSelectedFiles[0] = $iShellApp_Inst_SelectedItems_Count
    $aExplorerSelectedFiles[1] = $sShellApp_Inst_LocationURL
    ReDim $aExplorerSelectedFiles[$aExplorerSelectedFiles[0] + 2]
    Local $oShellApp_Inst_SelectedItems = $oShellApp_Inst.Document.SelectedItems
    If $fErrorHandling And $oError.number Then Return SetError(6, 0, $aExplorerSelectedFiles)
    Local $iCounter = 2
    For $oShellApp_Inst_SelectedItem In $oShellApp_Inst_SelectedItems
        $aExplorerSelectedFiles[$iCounter] = $oShellApp_Inst_SelectedItem.path
        $iCounter += 1
    Next
    Return $aExplorerSelectedFiles
EndFunc   ;==>_WindowsExplorer_ExtractSelectedDirAndFiles
Это сообщение посчитали полезным следующие участники:

Отправлено: 13:24, 13-08-2011 | #3