Jump to content

wheel detection


Recommended Posts

hello i am new here but i write some scripts

now i am trying to write script that run in the background and do that my mouse will be multimedia mouse

i mean that the buttons do thing like vol up, vol down, next item in the playlist, pause etc...

i want :next, prev, pause, vol up, vol down so i need 5 buttons

i have horizontal and vertical scrolling left button right button and side button

i can detect the side left right and the wheel

but i can detect the scrolling of the wheel

i see _ispressed but there is no scrolling detection

i search something like "_WinAPI_Mouse_Event" but reversed (i don't want not to send event i want to catch\handle\detect event)

thank you,

Arye

(sorry about the English - i hope the i don't have a lot of mistakes)

Edited by hellfire03
Link to comment
Share on other sites

Heres the most simple example, which just gets up or down scroll... Read this page for other uses of wParam and lParam. If you haven't used GUIRegisterMsg before then I'd recommend reading the tutorial on the wiki.

#include<WinAPI.au3>
#include<WindowsConstants.au3>

Global Const $WHEEL_DELTA = 120

Global $hGUI

$hGUI = GUICreate("Test Wheel")

GUISetState()
GUIRegisterMsg($WM_MOUSEWHEEL, "WM_MOUSEWHEEL")

Local $iMsg
While 1
    $iMsg = GUIGetMsg()
    Switch $iMsg
        Case -3
            ExitLoop
    EndSwitch
WEnd

Func WM_MOUSEWHEEL($hWnd, $iMsg, $wParam, $lParam)
    $iLen = _WinAPI_HiWord($wParam) / $WHEEL_DELTA

    If $iLen > 0 Then
        ConsoleWrite("Scrolled up " & $iLen & @LF)
    Else
        ConsoleWrite("Scrolled down " & Abs($iLen) & @LF)
    EndIf
EndFunc   ;==>WM_MOUSEWHEEL
Link to comment
Share on other sites

Nice Example Mat! Added to my Function Folder :x

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

Nice Example Mat! Added to my Function Folder :x

Here's a more complete example:

#include<WinAPI.au3>
#include<WindowsConstants.au3>

Global Const $WHEEL_DELTA = 120

Global Const $MK_LBUTTON = 0x1
Global Const $MK_RBUTTON = 0x2
Global Const $MK_SHIFT = 0x4
Global Const $MK_CONTROL = 0x8
Global Const $MK_MBUTTON = 0x10
Global Const $MK_XBUTTON1 = 0x20
Global Const $MK_XBUTTON2 = 0x40

Global $hGUI

$hGUI = GUICreate("WM_MOUSEWHEEL (Full)")

GUISetState()
GUIRegisterMsg($WM_MOUSEWHEEL, "WM_MOUSEWHEEL")

Local $iMsg
While 1
    $iMsg = GUIGetMsg()
    Switch $iMsg
        Case -3
            ExitLoop
    EndSwitch
WEnd

Func WM_MOUSEWHEEL($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam, $lParam

    Local $iLen = _WinAPI_HiWord($wParam) / $WHEEL_DELTA
    Local $iKeys = _WinAPI_LoWord($wParam)
    Local $iX = _WinAPI_LoWord($lParam)
    Local $iY = _WinAPI_HiWord($lParam)

    Local $sDir
    If $iLen > 0 Then
        $sDir = "up"
    Else
        $sDir = "down"
        $iLen = Abs($iLen)
    EndIf

    Local $sKeys = ""
    If BitAND($iKeys, $MK_CONTROL) = $MK_CONTROL Then $sKeys &= "CONTROL & "
    If BitAND($iKeys, $MK_LBUTTON) = $MK_LBUTTON Then $sKeys &= "LBUTTON & "
    If BitAND($iKeys, $MK_MBUTTON) = $MK_MBUTTON Then $sKeys &= "MBUTTON & "
    If BitAND($iKeys, $MK_RBUTTON) = $MK_RBUTTON Then $sKeys &= "RBUTTON & "
    If BitAND($iKeys, $MK_SHIFT) = $MK_SHIFT Then $sKeys &= "SHIFT & "
    If BitAND($iKeys, $MK_XBUTTON1) = $MK_XBUTTON1 Then $sKeys &= "XBUTTON1 & "
    If BitAND($iKeys, $MK_XBUTTON2) = $MK_XBUTTON2 Then $sKeys &= "XBUTTON2 & "

    If $sKeys = "" Then
        $sKeys = "No keys"
    Else
        $sKeys = StringTrimRight($sKeys, 3)
    EndIf

    ConsoleWrite(StringFormat("Scrolled %s %d with %s pressed at (%d, %d).\n", $sDir, $iLen, $sKeys, $iX, $iY))

    ; Return 0 ; If you return zero, then the message will not be sent to any more windows.
EndFunc   ;==>WM_MOUSEWHEEL
Link to comment
Share on other sites

Brilliant! I am sure I will find some use for the MouseWheel soon :x

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

A MouseOnEvent example.

#include <MouseOnEvent.au3>
$hGUI = WinGetHandle("")

_MouseSetOnEvent($MOUSE_WHEELSCROLLUP_EVENT, "MOUSE_WHELLSCROLL_UP", "", "", $hGUI)
_MouseSetOnEvent($MOUSE_WHEELSCROLLDOWN_EVENT, "MOUSE_WHELLSCROLL_DOWN", "", "", $hGUI)

While 1
    Sleep(100)
WEnd

Func MOUSE_WHELLSCROLL_UP()
    ConsoleWrite("UP" & @CR)
EndFunc

Func MOUSE_WHELLSCROLL_DOWN()
    ConsoleWrite("DOWN" & @CR)
EndFunc

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

i want to understand:

_MouseSetOnEvent,_ispressed and hotkeyset catch the event or detect?

(if i click ALT autoit see it and do something and the OS get the ALT or autoit catch the event and stop it from get to the OS)

thank you

Those Functions detects events without disturbing your OS, you can also create your own combinations !

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...