- Сообщения
- 8,673
- Репутация
- 2,486
Zaramot [?]
мне нужна правая кнопка мыши
Код:
#NoTrayIcon
#include <GUIToolbar.au3>
#include <Array.au3>
#include "MouseOnEvent.au3"
Opt("WinWaitDelay", 1)
HotKeySet("^+e", "_Exit") ;Выход по <Ctrl + Shift + E>
Global $sLast_NextBack_Window = ""
Global $sLast_BackNext_Window = ""
Global $iScrollDown = 0
Global $iScrollUp = 0
Global $iSecondaryDown = 0
Global $iSecondaryUp = 0
Global $iSwitchNext = 1
Global $iSwitchBack = 2
Global $iSwitchNextBack = 3
Global $iSwitchBackNext = 4
_MouseSetOnEvent($MOUSE_WHEELSCROLLDOWN_EVENT, "WHEELSCROLLDOWN_EVENT", "", "", 0, -1)
_MouseSetOnEvent($MOUSE_WHEELSCROLLUP_EVENT, "WHEELSCROLLUP_EVENT", "", "", 0, -1)
_MouseSetOnEvent($MOUSE_SECONDARYDOWN_EVENT, "SECONDARYDOWN_EVENT", "", "", 0, -1)
_MouseSetOnEvent($MOUSE_SECONDARYUP_EVENT, "SECONDARYUP_EVENT", "", "", 0, -1)
While 1
Sleep(10)
If $iSecondaryDown And $iScrollDown Then
$iScrollDown = 0
_SwitchTaskBarWindow_Proc($iSwitchBack)
ElseIf $iScrollDown Then
$iScrollDown = 0
EndIf
If $iSecondaryDown And $iScrollUp Then
$iScrollUp = 0
_SwitchTaskBarWindow_Proc($iSwitchNext)
ElseIf $iScrollUp Then
$iScrollUp = 0
EndIf
WEnd
Func WHEELSCROLLDOWN_EVENT()
$iScrollDown = 1
If $iSecondaryDown Then Return 1
EndFunc
Func WHEELSCROLLUP_EVENT()
$iScrollUp = 1
If $iSecondaryDown Then Return 1
EndFunc
Func SECONDARYDOWN_EVENT()
$iSecondaryDown = 1
EndFunc
Func SECONDARYUP_EVENT()
$iSecondaryDown = 0
If $iScrollDown Or $iScrollUp Then Return 1
EndFunc
Func _SwitchTaskBarWindow_Proc($iMode)
Local $sActivate_Window = "", $hParent_Active_Wnd = _WinAPI_GetAncestor(WinGetHandle(""), $GA_ROOTOWNER)
Local $aTaskBarWindows = _WinListTaskBarWindowsEx(1)
For $i = 1 To $aTaskBarWindows[0][0]
If WinActive($aTaskBarWindows[$i][0]) Or $aTaskBarWindows[$i][0] = $hParent_Active_Wnd Then
Switch $iMode
Case $iSwitchBack ;Предыдущее окно (1-ое по счёту)
If $i = 1 Then $i = $aTaskBarWindows[0][0] + 1
$sActivate_Window = $aTaskBarWindows[$i - 1][0]
Case $iSwitchNext ;Следующее окно (1-ое по счёту)
If $i = $aTaskBarWindows[0][0] Then $i = 0
$sActivate_Window = $aTaskBarWindows[$i + 1][0]
Case $iSwitchNextBack ;Следующее <> Предыдущее окно
If $sLast_NextBack_Window <> $aTaskBarWindows[$i][0] Then $sLast_NextBack_Window = ""
If $sLast_NextBack_Window = "" Then
If $i = $aTaskBarWindows[0][0] Then $i = 0
$sActivate_Window = $aTaskBarWindows[$i + 1][0]
$sLast_NextBack_Window = $sActivate_Window
Else
If $i = 1 Then $i = $aTaskBarWindows[0][0] + 1
$sActivate_Window = $aTaskBarWindows[$i - 1][0]
$sLast_NextBack_Window = ""
EndIf
Case $iSwitchBackNext ;Предыдущее <> Следующее окно
If $sLast_BackNext_Window <> $aTaskBarWindows[$i][0] Then $sLast_BackNext_Window = ""
If $sLast_BackNext_Window = "" Then
If $i = 1 Then $i = $aTaskBarWindows[0][0] + 1
$sActivate_Window = $aTaskBarWindows[$i - 1][0]
$sLast_BackNext_Window = $sActivate_Window
Else
If $i = $aTaskBarWindows[0][0] Then $i = 0
$sActivate_Window = $aTaskBarWindows[$i + 1][0]
$sLast_BackNext_Window = ""
EndIf
EndSwitch
ExitLoop
EndIf
Next
;Не найдены активные окна...
If $sActivate_Window = "" Then
Switch $iMode
Case $iSwitchBack
;Активируем последнее окно
$sActivate_Window = $aTaskBarWindows[$aTaskBarWindows[0][0]][0]
Case Else
;Активируем первое окно
$sActivate_Window = $aTaskBarWindows[1][0]
EndSwitch
EndIf
WinActivate($sActivate_Window)
EndFunc
Func _WinListTaskBarWindowsEx($iListSort=1)
Local $hToolbar = ControlGetHandle("[CLASS:Shell_TrayWnd]", "", "ToolbarWindow323")
If @error Then $hToolbar = ControlGetHandle("[CLASS:Shell_TrayWnd]", "", "ToolbarWindow322")
If @error Then Return SetError(1, 0, 0)
Local $aWinList = WinList()
Local $aRet_List[$aWinList[0][0] + 1][2], $iToolbarButtonIndex
For $i = 1 To $aWinList[0][0] Step 1
If Not BitAND(WinGetState($aWinList[$i][1]), 2) Then ContinueLoop
$iToolbarButtonIndex = _WinAPI_FindToolbarButton($aWinList[$i][1], $hToolbar)
If $iToolbarButtonIndex > 0 Then
$aRet_List[0][0] += 1
$aRet_List[$aRet_List[0][0]][0] = $aWinList[$i][1]
$aRet_List[$aRet_List[0][0]][1] = $iToolbarButtonIndex
EndIf
Next
If $aRet_List[0][0] = 0 Then Return SetError(2, 0, 0)
ReDim $aRet_List[$aRet_List[0][0] + 1][2]
If $iListSort Then _ArraySort($aRet_List, 0, 1, $aRet_List[0][0], 1)
Return $aRet_List
EndFunc
Func _WinAPI_FindWindowEx($hParent, $hChild, $sClass, $sWindow)
; must create structs and use ptrs to account for passing a true NULL as classname or window title
; simply using "wstr" and "" does NOT work
Local $sStruct1, $sStruct2
If $sClass = "" Then
$sClass = 0
Else
$sStruct1 = DllStructCreate("wchar[256]")
DllStructSetData($sStruct1, 1, $sClass)
$sClass = DllStructGetPtr($sStruct1)
EndIf
If $sWindow = "" Then
$sWindow = 0
Else
$sStruct2 = DllStructCreate("wchar[256]")
DllStructSetData($sStruct2, 1, $sWindow)
$sWindow = DllStructGetPtr($sStruct2)
EndIf
Local $aRet = DllCall("user32.dll", "hwnd", "FindWindowExW", "hwnd", $hParent, "hwnd", $hChild, "ptr", $sClass, "ptr", $sWindow)
$sStruct1 = 0
$sStruct2 = 0
Return $aRet[0]
EndFunc
Func _WinAPI_FindToolbarButton($hWnd, $hTB)
Local $iReturn = -1, $iPID, $hProcess, $sStruct = DllStructCreate("ptr")
; open process owning toolbar control
_WinAPI_GetWindowThreadProcessId($hTB, $iPID)
$hProcess = _WinAPI_OpenProcess(0x410, False, $iPID)
If $hProcess Then
Local $iCount = _GUICtrlToolbar_ButtonCount($hTB)
For $i = 0 To $iCount - 1
Local $iID = _GUICtrlToolbar_IndexToCommand($hTB, $i)
; button param is ptr to owner's window handle, stored in target process's memory space
Local $dwData = _GUICtrlToolbar_GetButtonParam($hTB, $iID)
; read the window handle from the explorer process
Local $aRet = DllCall("kernel32.dll", "int", "ReadProcessMemory", "ptr", _
$hProcess, "ptr", $dwData, "ptr", DllStructGetPtr($sStruct), "uint", 4, "uint*", 0)
If $aRet[5] Then
If $hWnd = DllStructGetData($sStruct, 1) Then
$iReturn = $i
ExitLoop
EndIf
EndIf
Next
_WinAPI_CloseHandle($hProcess)
EndIf
Return $iReturn
EndFunc
Func _Exit()
Exit
EndFunc