Hallo,
Gibt es sowas wie _IsPressed("MausScollNachUnten")?
Wenn ich einmal nach unten Scrolle wird ein Wert wie 1 zurückgegeben.
Hallo,
Gibt es sowas wie _IsPressed("MausScollNachUnten")?
Wenn ich einmal nach unten Scrolle wird ein Wert wie 1 zurückgegeben.
Weiß das niemand?
Lösung von Progandy:
#include <Misc.au3>
$struct = "DWORD vkCode;" _
&"DWORD scanCode;" _
&"long flags;" _
&"ULONG_PTR dwExtraInfo"
HotKeySet("{F2}","Guid")
Global $hMouseHook, $WheelMoving, $hWinHook
$CallbackMouseProc = TogglePlugMouse()
ToolTip("Wheel captured",2,2,"Capture Mose")
While 1
Sleep(100)
$WheelMsg = _GetWheelMove()
Select
Case $WheelMsg = "U" ;UP
ToolTip("UP")
Case $WheelMsg = "D" ;DOWN
ToolTip("Down")
Case Else
ToolTip("Nix")
EndSelect
WEnd
;BlockInput(0)
Func GUID()
TogglePlugMouse($CallbackMouseProc)
ToolTip("")
MsgBox(4096, "", "KeyBoard is enabled!")
Exit
EndFunc
Exit
Func _GetWheelMove()
Local $x = StringLeft($WheelMoving,1)
$WheelMoving = StringTrimLeft($WheelMoving,1)
Return $x
EndFunc
Func TogglePlugMouse($hCallProc=0)
If IsArray($hMouseHook) Then
DllCall("user32.dll", "int", "UnhookWindowsHookEx", "hwnd", $hMouseHook[0])
DllCallbackFree($hCallProc)
Return 0
EndIf
Local Const $WH_MOUSE_LL = 14
;~ Local Const $WH_MOUSE = 7
Local $hMouseProc = DllCallbackRegister("_MouseProc", "int", "int;ptr;ptr")
Local $hMod = DllCall("kernel32.dll", "hwnd", "GetModuleHandle", "ptr", 0)
$hMouseHook = DllCall("user32.dll", "hwnd", "SetWindowsHookEx", _
"int", $WH_MOUSE_LL, _
"ptr", DllCallbackGetPtr($hMouseProc), _
"hwnd", $hMod[0], _
"dword", 0)
Return $hMouseProc
EndFunc
Func _MouseProc($nCode, $wParam, $lParam)
If $nCode < 0 Then
Local $iRet = DllCall("user32.dll", "long", "CallNextHookEx", "hwnd", $hWinHook[0], _
"int", $nCode, _
"ptr", $wParam, _
"ptr", $lParam)
Return $iRet[0]
EndIf
$dllstruct = DllStructCreate($struct,$lParam)
;~ If DllStructGetData($dllstruct,1) = 0x1B And _IsPressed("11") Then $CTRL_ESC_Pressed = True
If $wParam = 0x20A Then
If DllStructGetData($dllstruct,3) > 0 Then
ConsoleWrite("Up" & @CRLF)
$WheelMoving &= "U"
ElseIf DllStructGetData($dllstruct,3) < 0 Then
ConsoleWrite("Down" & @CRLF)
$WheelMoving &= "D"
EndIf
EndIf
;~ ConsoleWrite($wParam & " - " & DllStructGetData($dllstruct,1) & " - " & DllStructGetData($dllstruct,2)& " - " & DllStructGetData($dllstruct,3)& " - " & DllStructGetData($dllstruct,4) & @LF)
Return 0
EndFunc
Danke es funktioniert. Kann man das nicht weniger kompliziert lösen?
da solltest du den ersteller des scriptes fragen
wie du siehst bin ich anfänger und naja... ich verstehe nichtmal wie dieses script funktioniert.
Das ist auch nicht einfacher
nur der Code ist in einer UDF versteckt. Außerdem kann man die Richtung nicht feststellen. Hab meins auch nochmal schöner gemacht. Der teil zwischen ; ##### brauchst dich nicht zu interessieren.
;########### UDF
[/autoit] [autoit][/autoit] [autoit]Global $_WHEELPROC_hMouseHook, $__WHEELPROC_WheelMoving, $hWinHook
[/autoit] [autoit][/autoit] [autoit]; Prog@ndy
Func _GetWheelMove()
Local $x = StringLeft($__WHEELPROC_WheelMoving,1)
$__WHEELPROC_WheelMoving = StringTrimLeft($__WHEELPROC_WheelMoving,1)
Return $x
EndFunc
; Prog@andy, modified some unknown source
Func _ToggleWheelHook()
If IsArray($_WHEELPROC_hMouseHook) Then
DllCall("user32.dll", "int", "UnhookWindowsHookEx", "hwnd", $_WHEELPROC_hMouseHook[0])
DllCallbackFree($_WHEELPROC_hMouseHook[1])
$_WHEELPROC_hMouseHook = 0
Return False
EndIf
Local Const $WH_MOUSE_LL = 14
Local $hMouseProc = DllCallbackRegister("__WHEELPROC_MouseProc", "int", "int;ptr;ptr")
Local $hMod = DllCall("kernel32.dll", "hwnd", "GetModuleHandle", "ptr", 0)
$_WHEELPROC_hMouseHook = DllCall("user32.dll", "hwnd", "SetWindowsHookEx", _
"int", $WH_MOUSE_LL, _
"ptr", DllCallbackGetPtr($hMouseProc), _
"hwnd", $hMod[0], _
"dword", 0)
$_WHEELPROC_hMouseHook[1] = $hMouseProc
Return True
EndFunc
; Prog@andy, modified some unknown source
Func __WHEELPROC_MouseProc($nCode, $wParam, $lParam)
If $nCode < 0 Then
Local $iRet = DllCall("user32.dll", "long", "CallNextHookEx", "hwnd", $hWinHook[0], _
"int", $nCode, _
"ptr", $wParam, _
"ptr", $lParam)
Return $iRet[0]
EndIf
Local $struct = "DWORD vkCode;" _
&"DWORD scanCode;" _
&"long flags;" _
&"ULONG_PTR dwExtraInfo"
Local $dllstruct = DllStructCreate($struct,$lParam)
If $wParam = 0x20A Then
If DllStructGetData($dllstruct,3) > 0 Then
$__WHEELPROC_WheelMoving &= "U"
ElseIf DllStructGetData($dllstruct,3) < 0 Then
$__WHEELPROC_WheelMoving &= "D"
EndIf
EndIf
Return 0
EndFunc
;####### UDF Ende
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]#include <Misc.au3>
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]HotKeySet("{F2}","_exit")
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]_ToggleWheelHook()
MsgBox(4096, "", "Wheel captured")
While 1
Sleep(100)
$WheelMsg = _GetWheelMove()
Select
Case $WheelMsg = "U" ;UP
ToolTip("UP")
ConsoleWrite("UP Event" & @CRLF)
Case $WheelMsg = "D" ;DOWN
ToolTip("Down")
ConsoleWrite("DOWN Event" & @CRLF)
Case Else
ToolTip("Nix")
EndSelect
WEnd
Func _exit()
Exit
EndFunc
Func OnAutoitExit()
_ToggleWheelHook()
ToolTip("")
MsgBox(4096, "", "Wheel capture disabled")
Exit
EndFunc
also ich habs nicht ganz so kompliziert gelöst oO
Global Const $WM_MOUSEWHEEL = 0x020A
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]GUIRegisterMsg($WM_SIZE, "WM_SIZE")
GUIRegisterMsg($WM_VSCROLL, "WM_VSCROLL")
GUIRegisterMsg($WM_MOUSEWHEEL, "_Mausrad")
Func _Mausrad($hWnd, $Msg, $wParam)
#forceref $Msg, $wParam
If $wParam == "0x00780000" Then _Bild_rauf()
If $wParam == "0xFF880000" Then _Bild_runter()
EndFunc
;~ Func _Bild_runter()
;~
;~ for $i = 0 To 4 Step 1
;~ WM_VSCROLL($sheet, 0x0, 0x00000001, 0) ;1 mal kurz nach oben Scrollen - selber Effekt wie auf den Pfeil klicken
;~ Next
;~
;~ EndFunc
;~ Func _Bild_rauf()
;~
;~ for $i = 0 To 4 Step 1
;~ WM_VSCROLL($sheet, 0x0, 0x00000000, 0) ;1 mal kurz nach unten Scrollen - selber Effekt wie auf den Pfeil klicken
;~ Next
;~
;~ EndFunc
Gruß
Prajoss
PS: VM_VSCROLL, VM_SIZE müsst ihr irgendwo noch deklarieren, ich häng se mal:
Func WM_VSCROLL($hWnd, $Msg, $wParam, $lParam)
#forceref $Msg, $wParam, $lParam
; MsgBox(0, "tt", $wParam)
Local $nScrollCode = BitAND($wParam, 0x0000FFFF)
Local $index = -1, $yChar, $yPos
Local $Min, $Max, $Page, $Pos, $TrackPos
For $x = 0 To UBound($aSB_WindowInfo) - 1
If $aSB_WindowInfo[$x][0] = $hWnd Then
$index = $x
$yChar = $aSB_WindowInfo[$index][3]
ExitLoop
EndIf
Next
If $index = -1 Then Return 0
; Get all the vertial scroll bar information
Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_VERT)
$Min = DllStructGetData($tSCROLLINFO, "nMin")
$Max = DllStructGetData($tSCROLLINFO, "nMax")
$Page = DllStructGetData($tSCROLLINFO, "nPage")
; Save the position for comparison later on
$yPos = DllStructGetData($tSCROLLINFO, "nPos")
$Pos = $yPos
$TrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos")
Switch $nScrollCode
Case $SB_TOP ; user clicked the HOME keyboard key
DllStructSetData($tSCROLLINFO, "nPos", $Min)
Case $SB_BOTTOM ; user clicked the END keyboard key
DllStructSetData($tSCROLLINFO, "nPos", $Max)
Case $SB_LINEUP ; user clicked the top arrow
DllStructSetData($tSCROLLINFO, "nPos", $Pos - 1)
Case $SB_LINEDOWN ; user clicked the bottom arrow
DllStructSetData($tSCROLLINFO, "nPos", $Pos + 1)
Case $SB_PAGEUP ; user clicked the scroll bar shaft above the scroll box
DllStructSetData($tSCROLLINFO, "nPos", $Pos - $Page)
Case $SB_PAGEDOWN ; user clicked the scroll bar shaft below the scroll box
DllStructSetData($tSCROLLINFO, "nPos", $Pos + $Page)
Case $SB_THUMBTRACK ; user dragged the scroll box
DllStructSetData($tSCROLLINFO, "nPos", $TrackPos)
EndSwitch
;~ // Set the position and then retrieve it. Due to adjustments
;~ // by Windows it may not be the same as the value set.
DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS)
_GUIScrollBars_SetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO)
_GUIScrollBars_GetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO)
;// If the position has changed, scroll the window and update it
$Pos = DllStructGetData($tSCROLLINFO, "nPos")
If ($Pos <> $yPos) Then
_GUIScrollBars_ScrollWindow($hWnd, 0, $yChar * ($yPos - $Pos))
$yPos = $Pos
EndIf
Return $GUI_RUNDEFMSG
[/autoit] [autoit][/autoit] [autoit]EndFunc ;==>WM_VSCROLL
[/autoit] [autoit][/autoit] [autoit]Func WM_SIZE($hWnd, $Msg, $wParam, $lParam)
#forceref $Msg, $wParam
Local $index = -1, $yChar, $xChar, $xClientMax, $xClient, $yClient, $ivMax
For $x = 0 To UBound($aSB_WindowInfo) - 1
If $aSB_WindowInfo[$x][0] = $hWnd Then
$index = $x
$xClientMax = $aSB_WindowInfo[$index][1]
$xChar = $aSB_WindowInfo[$index][2]
$yChar = $aSB_WindowInfo[$index][3]
$ivMax = $aSB_WindowInfo[$index][7]
ExitLoop
EndIf
Next
If $index = -1 Then Return 0
Local $tSCROLLINFO = DllStructCreate($tagSCROLLINFO)
; Retrieve the dimensions of the client area.
$xClient = BitAND($lParam, 0x0000FFFF)
$yClient = BitShift($lParam, 16)
$aSB_WindowInfo[$index][4] = $xClient
$aSB_WindowInfo[$index][5] = $yClient
; Set the vertical scrolling range and page size
DllStructSetData($tSCROLLINFO, "fMask", BitOR($SIF_RANGE, $SIF_PAGE))
DllStructSetData($tSCROLLINFO, "nMin", 0)
DllStructSetData($tSCROLLINFO, "nMax", $ivMax)
DllStructSetData($tSCROLLINFO, "nPage", $yClient / $yChar)
_GUIScrollBars_SetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO)
; Set the horizontal scrolling range and page size
DllStructSetData($tSCROLLINFO, "fMask", BitOR($SIF_RANGE, $SIF_PAGE))
DllStructSetData($tSCROLLINFO, "nMin", 0)
DllStructSetData($tSCROLLINFO, "nMax", 2 + $xClientMax / $xChar)
DllStructSetData($tSCROLLINFO, "nPage", $xClient / $xChar)
_GUIScrollBars_SetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO)
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_SIZE
Edit: die VM_SIZE, VM_VSCROLL braucht man natürlich nur wenn man das Mausrad nutzten will um das GUI zu scrollen, sonst sind sie unnötig.
Prajoss: Das funktioniert aber nur, solange deine AutoIt-GUI aktiv ist
wenn es systemweit gemacht werden soll, geht das nicht mehr.
Wozu sollte man auch das Scrollrad Systemweit binden? ![]()
Hotkey ![]()
Danke.