jaberwacky Posted May 12, 2013 Share Posted May 12, 2013 (edited) I'm working on a script for one or more monitors that will wrap the mouse around the monitors and yet still allow you to drag windows to the edge of the monitor for the Windows 7 Snap feature. So, this is a basic script that does what I set out to do. I think it will even work on multiple monitors. If you have more than two monitors and want to test then I will love you forever. [update -- 05/19/2013] This update has a major difference. When the user drags the mouse to the edge of a monitor there is a 300 millisecond delay before the mouse will wrap. This will give the user some time to change their mind. When the user drags a window or selection rectangle to the edge of a monitor the user will have 700 milliseconds to take advantage of the Windows 7 Snap feature. If the user has not moved the mouse from the edge within that time then the window will move to the opposite edge. There are several speed optimizations without getting too silly and wishy washy. expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_testing=y #AutoIt3Wrapper_Run_AU3Check=n #AutoIt3Wrapper_UseX64=n #AutoIt3Wrapper_UseUpx=n #AutoIt3Wrapper_AU3Check_Parameters=-w 1 -w 2 -w 3 -w 4 -w 6 -w 7 -d #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ; ============================================================================ ; = MosueWrap: = ; = I intend to allow for mouse wrap action but still be able to utilize = ; = the Windows 7 Snap feature. = ; = Should work on any number of monitors. = ; = = ; = Credits: = ; = Guinness, etc. = ; ============================================================================ #include <Misc.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> _Singleton(@ScriptName) Global Const $mouse_proc_callback = DllCallbackRegister("mouse_proc", "long", "int;wparam;lparam") Global Const $hook = _WinAPI_SetWindowsHookEx($WH_MOUSE_LL, DllCallbackGetPtr($mouse_proc_callback), _WinAPI_GetModuleHandle(0)) Global Const $user32 = DllOpen("User32.Dll") OnAutoItExitRegister("cleanup") Global $mouse_hover_time = 300 Global $vertical = True Global $horizontal = True Global $paused = True Do Switch Not $paused Case True mouse_wrap() $paused = True EndSwitch Sleep(25) Until False Func mouse_proc($code, $w_param, $l_param) Switch $code >= 0 Case True Switch $w_param Case $WM_LBUTTONDOWN, $WM_RBUTTONDOWN $mouse_hover_time = 700 Case $WM_LBUTTONUP, $WM_RBUTTONUP $mouse_hover_time = 300 Case $WM_MOUSEMOVE $paused = False EndSwitch EndSwitch Return _WinAPI_CallNextHookEx($hook, $code, $w_param, $l_param) EndFunc Func mouse_wrap() Static Local $virtual_desktop_width = _WinAPI_GetSystemMetrics($SM_CXVIRTUALSCREEN) - 1 Static Local $last_x = -1 Static Local $last_y = -1 Local Const $x = MouseGetPos(0) Local Const $y = MouseGetPos(1) Switch ($last_x <> $x) Or ($last_y <> $y) Case True $last_x = $x $last_y = $y Switch $horizontal Case True Select Case $x = 0 Switch hovertime_left_right(0) Case True MouseMove($virtual_desktop_width, $y, 0) Return True EndSwitch Case $x = $virtual_desktop_width Switch hovertime_left_right($virtual_desktop_width) Case True MouseMove(1, $y, 0) Return True EndSwitch EndSelect EndSwitch Switch $vertical Case True Local Const $monitor_height = get_monitor_height($x, $y) - 1 Select Case $y = 0 Switch hovertime_top_bottom(0) Case True MouseMove($x, $monitor_height, 0) EndSwitch Case $y = $monitor_height Switch hovertime_top_bottom($monitor_height) Case True MouseMove($x, 1, 0) EndSwitch EndSelect EndSwitch EndSwitch Return True EndFunc Func hovertime_top_bottom(Const ByRef $edge) Local Const $hover_time = TimerInit() Do Switch MouseGetPos(1) <> $edge Case True Return False EndSwitch Until Round(TimerDiff($hover_time)) = $mouse_hover_time Return True EndFunc Func hovertime_left_right(Const ByRef $edge) Local Const $hover_time = TimerInit() Do Switch MouseGetPos(0) <> $edge Case True Return False EndSwitch Until Round(TimerDiff($hover_time)) = $mouse_hover_time Return True EndFunc Func get_monitor_height(Const ByRef $x, Const ByRef $y) Static Local $point = DllStructCreate($tagPOINT) DllStructSetData($point, 'x', $x) DllStructSetData($point, 'y', $y) Local Const $monitor_handle = _WinAPI_MonitorFromPoint($point) Local Const $monitor_info = _WinAPI_GetMonitorInfo($monitor_handle) Return DllStructGetData($monitor_info[1], 4) EndFunc #region ; WinAPIEx ; #FUNCTION# ==================================================================================================================== ; Name...........: _WinAPI_GetMonitorInfo ; Description....: Retrieves information about a display monitor. ; Syntax.........: _WinAPI_GetMonitorInfo ( $hMonitor ) ; Parameters.....: $hMonitor - A handle to the display monitor of interest. ; Return values..: Success - The array containing the following information: ; ; [0] - $tagRECT structure that specifies the display monitor rectangle, in virtual-screen coordinates. ; [1] - $tagRECT structure that specifies the work area rectangle of the display monitor that can be used by applications, in virtual-screen coordinates. ; [2] - 1 (True) for the primary display monitor, or 0 (False) otherwise. ; [3] - The device name of the monitor being used, e.g. "\\.\DISPLAY1". ; Failure - 0 and sets the @error flag to non-zero. ; Author.........: Yashied ; Modified.......: ; Remarks........: None ; Related........: ; Link...........: @@MsdnLink@@ GetMonitorInfo ; Example........: Yes ; =============================================================================================================================== Func _WinAPI_GetMonitorInfo(Const ByRef $hMonitor) ; I set these to static because I didn't want them to execute everytime the function entered. Static Local $tMIEX = DllStructCreate("dword;long[4];long[4];dword;wchar[32]") Static Local $size = DllStructGetSize($tMIEX) Static Local $miex_size = DllStructSetData($tMIEX, 1, $size) Local Const $Ret = DllCall($user32, "int", "GetMonitorInfoW", "ptr", $hMonitor, "ptr", DllStructGetPtr($tMIEX)) If (@error) Or (Not $Ret[0]) Then Return SetError(1, 0, False) Static Local $ptr[2] = [DllStructGetPtr($tMIEX, 1), DllStructGetPtr($tMIEX, 2)] Local $Result[4] For $i = 0 To 1 $Result[$i] = DllStructCreate($tagRECT) If Not _WinAPI_MoveMemory(DllStructGetPtr($Result[$i]), $ptr[$i], 16) Then Return SetError(2, 0, False) EndIf Next Switch DllStructGetData($tMIEX, 4) Case 1 ; MONITORINFOF_PRIMARY $Result[2] = 1 Case Else $Result[2] = 0 EndSwitch $Result[3] = DllStructGetData($tMIEX, 5) Return $Result EndFunc ; #FUNCTION# ==================================================================================================================== ; Name...........: _WinAPI_MonitorFromPoint ; Description....: Retrieves a handle to the display monitor that contains a specified point. ; Syntax.........: _WinAPI_MonitorFromPoint ( $tPOINT [, $iFlag] ) ; Parameters.....: $tPOINT - $tagPOINT structure that specifies the point of interest in virtual-screen coordinates. ; $iFlag - The flag that specifies the function's return value if the point is not contained within any display ; monitor. This parameter can be one of the following values. ; $MONITOR_DEFAULTTONEAREST ; $MONITOR_DEFAULTTONULL ; $MONITOR_DEFAULTTOPRIMARY ; Return values..: Success - A handle to the display monitor that contains a specified point, or the value depends on the ; $MONITOR_* constant. ; Failure - 0 and sets the @error flag to non-zero. ; Author.........: Yashied ; Modified.......: ; Remarks........: None ; Related........: ; Link...........: @@MsdnLink@@ MonitorFromPoint ; Example........: Yes ; =============================================================================================================================== Func _WinAPI_MonitorFromPoint(Const ByRef $tPOINT, Const $iFlag = 1) Static Local $tpoint_ptr = DllStructGetPtr($tPOINT) Static Local $tPT = DllStructCreate("long[2]", $tpoint_ptr) Local Const $Ret = DllCall($user32, "ptr", "MonitorFromPoint", "long", DllStructGetData($tPT, 1, 1), "long", DllStructGetData($tPT, 1, 2), "dword", $iFlag) If (@error) Then Return SetError(1, 0, False) Return $Ret[0] EndFunc ; #FUNCTION# ==================================================================================================================== ; Name...........: _WinAPI_MoveMemory ; Description....: Moves a block of memory from one location to another. ; Syntax.........: _WinAPI_MoveMemory ( $pDestination, $pSource, $iLength ) ; Parameters.....: $pDestination - A pointer to the starting address of the move destination. ; $pSource - A pointer to the starting address of the block of memory to be moved. ; $iLength - The size of the block of memory to move, in bytes. ; Return values..: Success - 1. ; Failure - 0 and sets the @error flag to non-zero. ; Author.........: Yashied ; Modified.......: ; Remarks........: The source and destination blocks may overlap. ; Related........: ; Link...........: @@MsdnLink@@ RtlMoveMemory ; Example........: Yes ; =============================================================================================================================== Func _WinAPI_MoveMemory(Const ByRef $pDestination, Const ByRef $pSource, Const ByRef $iLength) Static Local $ntdll = DllOpen("ntdll.dll") DllCall($ntdll, "none", "RtlMoveMemory", "ptr", $pDestination, "ptr", $pSource, "ulong_ptr", $iLength) If (@error) Then Return SetError(1, 0, False) Return True EndFunc #endregion ; WinAPIEx Func cleanup() _WinAPI_UnhookWindowsHookEx($hook) DllCallbackFree($mouse_proc_callback) DllClose($user32) EndFunc Edited May 19, 2013 by jaberwocky6669 Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
guinness Posted May 12, 2013 Share Posted May 12, 2013 (edited) I don't have two monitors to test but I can give you some pointers. 1. Your 'WindowFromPoint' doesn't sit right with me, as this should use a POINT structure instead. I'm actually surprised it works. Why not create a wrapper function of _WinAPI_WindowFromPoint OR just use _WinAPI_WindowFromPoint. 2. I don't quite see the difference between using $WH_MOUSE_LL with _WinAPI_SetWindowsHookEx and the DLL? Edited May 12, 2013 by guinness jaberwacky 1 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 parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
jaberwacky Posted May 12, 2013 Author Share Posted May 12, 2013 Thanks for the pointers! I implemented the first one. Now I need to sleep. I will look more into the rest when I wake up. I used MouseSpotter's script because I didn't know about _WinAPI_SetWindowsHookEx. But now I do thanks to you! Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
jaberwacky Posted May 12, 2013 Author Share Posted May 12, 2013 Updated. Now for one or more monitors. Tested on two monitors on Windows 7 x64 with AutoIt Stable and 3.3.9.5. Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
guinness Posted May 12, 2013 Share Posted May 12, 2013 You don't need to call MouseGetPos as in your Mouse_Proc you can pass $lParam to $tagMSLLHOOKSTRUCT and then retrieve the X and Y co-ordinates from the structure. Search the Forum using those keywords. You learnt anything new today? 0_- 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 parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
jaberwacky Posted May 12, 2013 Author Share Posted May 12, 2013 But what are the advantages? Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
guinness Posted May 12, 2013 Share Posted May 12, 2013 Well for one you're not calling MouseGetPos twice (I would use the return array option anyway) plus the information is already there, so it seems silly not to take advantage of that information. 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 parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
jaberwacky Posted May 12, 2013 Author Share Posted May 12, 2013 I see now. Instead of calling MouseGetPos() every 10 milliseconds I just use that struct for every mousemove event. Kewl, thanks! Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
guinness Posted May 13, 2013 Share Posted May 13, 2013 Why did you go back? Post what you tried and I will amend it. 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 parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
jaberwacky Posted May 13, 2013 Author Share Posted May 13, 2013 (edited) I was aggravated yesterday because I had spent hours on minor problems even though I should have known better. So the issue I came up against is that when the mouse moves to the edge of the monitor and then stops moving function mouse_proc is called multiple times like twenty of more (I didn't count). I think the problem is that MOUSEHOOKSTRUCT returns negative values for off screen coordinates and I don't really know the best way to handle those. Should I clip them off at zero? I think this is what causes the error that I describe with the repeating even though I stop. Here is the best representation of what I had yesterday. This is untested though but it gives the intent I had. expandcollapse popup; ====================================================================================================================== ; = Credits: ; = Guinness, Kylomas, Melba23, trancexx, etc. ; ====================================================================================================================== #AutoIt3Wrapper_AU3Check_Parameters=-w 1 -w 2 -w 3 -w 4 -w 6 -w 7 -d #include <Misc.au3> _Singleton(@ScriptName) #include <WinAPI.au3> #include <WindowsConstants.au3> Global Const $mouse_proc_callback = DllCallbackRegister("mouse_proc", "long", "int;wparam;lparam") Global Const $hook = _WinAPI_SetWindowsHookEx($WH_MOUSE_LL, DllCallbackGetPtr($mouse_proc_callback), _WinAPI_GetModuleHandle(0)) OnAutoItExitRegister("cleanup") Global Const $desktop_width = _WinAPI_GetSystemMetrics(78) Global Const $monitorx_height = get_monitorx_height() Global $mouse_x = '' Global $mouse_y = '' Global $paused = True Do Switch Not $paused Case True Select Case $mouse_x <= @DesktopWidth Switch $mouse_y Case (@DesktopHeight - 1) MouseMove($mouse_x, 1, 0) ContinueLoop EndSwitch Case $mouse_x > @DesktopWidth Switch $mouse_y Case ($monitorx_height - 1) MouseMove($mouse_x, 1, 0) ContinueLoop EndSwitch EndSelect Select Case $mouse_x = 0 MouseMove($desktop_width - 1, $mouse_y, 0) Case $mouse_x = ($desktop_width - 1) MouseMove(1, $mouse_y, 0) Case $mouse_y = 0 MouseMove($mouse_x, (@DesktopHeight - 1), 0) EndSelect EndSwitch Sleep(25) Until False Func mouse_proc($code, $w_param, $l_param) Static $button_down = False Switch $code >= 0 Case True Switch $w_param Case $WM_LBUTTONDOWN, $WM_RBUTTONDOWN $button_down = True $paused = True Case $WM_LBUTTONUP, $WM_RBUTTONUP $button_down = False $paused = False Case $WM_MOUSEMOVE Switch Not $button_down Case True $paused = False Local Const $mouse_hook = DllStructCreate("ptr;hwnd;uint;ulong_ptr", $l_param) Local Const $point = DllStructCreate("long x;long y", DllStructGetPtr($mouse_hook, 1)) Local Const $x = DllStructGetData($point, 'x') Select Case $x < 0 $mouse_x = 0 Case $x > $desktop_width $mouse_x = $desktop_width Case Else $mouse_x = $x EndSelect Local Const $y = DllStructGetData($point, 'y') Switch monitor_from_pointx($x, $desktop_width) Case 1 Select Case $y < 0 $mouse_y = 0 Case $y > @DesktopHeight $mouse_y = @DesktopHeight Case Else $mouse_y = $y EndSelect Case 2 Select Case $y < 0 $mouse_y = 0 Case $y > $monitorx_height $mouse_y = $monitorx_height Case Else $mouse_y = $y EndSelect EndSwitch EndSwitch EndSwitch EndSwitch Return _WinAPI_CallNextHookEx($hook, $code, $w_param, $l_param) EndFunc ; ====================================================================== ; = Hacky kludge ; = I intend to replace this with something that calls MonitorFromPoint ; = or some other suitable function. ; ====================================================================== Func monitor_from_pointx(Const $x, Const $_desktop_width) Select Case $x <= @DesktopWidth Return 1 Case $x > $_desktop_width Return 2 EndSwitch EndFunc ; ====================================================================================================================== ; = Mostly Stolen From: ; = DrLarch: http://www.autoitscript.com/forum/topic/131618-detect-monitor-maximum-native-resolution/?p=1071159 ; ====================================================================================================================== Func get_monitorx_height() Local Const $display_device = DllStructCreate("dword; char[32]; char[128]; dword; char[128]; char[128]") DllStructSetData($display_device, 1, DllStructGetSize($display_device)) Local Const $display_monitor_amount = _WinAPI_GetSystemMetrics(80) DllCall("User32.dll", "bool", "EnumDisplayDevices", "ptr", 0, "dword", ($display_monitor_amount - 1), "ptr", DllStructGetPtr($display_device), "dword", 1) Local Const $device_name = DllStructGetData($display_device, 2) Local Const $tag_DEVMODE = "char dmDeviceName[32];ushort dmSpecVersion;ushort dmDriverVersion;short dmSize;" & _ "ushort dmDriverExtra;dword dmFields; long x;long y; dword dmDisplayOrientation;dword dmDisplayFixedOutput;" & _ "short dmColor;short dmDuplex;short dmYResolution;short dmTTOption;short dmCollate;" & _ "byte dmFormName[32];ushort LogPixels;dword dmBitsPerPel;int dmPelsWidth;dword dmPelsHeight;" & _ "dword dmDisplayFlags;dword dmDisplayFrequency" Local Const $DEVMODE = DllStructCreate($tag_DEVMODE) DllStructSetData($DEVMODE, "dmSize", DllStructGetSize($DEVMODE)) DllCall("User32.dll", "bool", "EnumDisplaySettings", "str", $device_name, "dword", -1, "ptr", DllStructGetPtr($DEVMODE)) Return DllStructGetData($DEVMODE, "dmPelsHeight") EndFunc Func cleanup() _WinAPI_UnhookWindowsHookEx($hook) DllCallbackFree($mouse_proc_callback) EndFunc Edited May 13, 2013 by jaberwocky6669 Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
guinness Posted May 13, 2013 Share Posted May 13, 2013 It's because your setup of the struct was wrong. I don't understand your overall intention, but you can see in the console that the mouse co-ordinates are working. expandcollapse popup; ====================================================================================================================== ; = Credits: ; = Guinness, Kylomas, Melba23, trancexx, etc. ; ====================================================================================================================== #AutoIt3Wrapper_AU3Check_Parameters=-w 1 -w 2 -w 3 -w 4 -w 6 -w 7 -d #include <Misc.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> _Singleton(@ScriptName) Global Const $tagMSLLHOOKSTRUCT = $tagPOINT & ';dword mouseData;dword flags;dword time;ulong_ptr dwExtraInfo' Global Const $mouse_proc_callback = DllCallbackRegister("mouse_proc", "long", "int;wparam;lparam") Global Const $hook = _WinAPI_SetWindowsHookEx($WH_MOUSE_LL, DllCallbackGetPtr($mouse_proc_callback), _WinAPI_GetModuleHandle(0)) OnAutoItExitRegister("cleanup") Global Const $desktop_width = _WinAPI_GetSystemMetrics($SM_CXVIRTUALSCREEN) Global Const $monitorx_height = get_monitorx_height() Global $mouse_x = '' Global $mouse_y = '' Global $paused = True Do Switch Not $paused Case True Select Case $mouse_x <= @DesktopWidth Switch $mouse_y Case (@DesktopHeight - 1) MouseMove($mouse_x, 1, 0) ContinueLoop EndSwitch Case $mouse_x > @DesktopWidth Switch $mouse_y Case ($monitorx_height - 1) MouseMove($mouse_x, 1, 0) ContinueLoop EndSwitch EndSelect Select Case $mouse_x = 0 MouseMove($desktop_width - 1, $mouse_y, 0) Case $mouse_x = ($desktop_width - 1) MouseMove(1, $mouse_y, 0) Case $mouse_y = 0 MouseMove($mouse_x, (@DesktopHeight - 1), 0) EndSelect EndSwitch Sleep(25) Until False Func mouse_proc($iCode, $wParam, $lParam) Static $button_down = False Local Const $tMOUSEHOOKS = DllStructCreate($tagMSLLHOOKSTRUCT, $lParam) ; http://msdn.microsoft.com/en-us/library/windows/desktop/ms644970(v=vs.85).aspx Switch $iCode >= 0 Case True Switch $wParam Case $WM_LBUTTONDOWN, $WM_RBUTTONDOWN $button_down = True $paused = True Case $WM_LBUTTONUP, $WM_RBUTTONUP $button_down = False $paused = False Case $WM_MOUSEMOVE $mouse_x = DllStructGetData($tMOUSEHOOKS, 'X') $mouse_y = DllStructGetData($tMOUSEHOOKS, 'Y') ConsoleWrite($mouse_x & @CRLF) ConsoleWrite($mouse_y & @CRLF) Switch Not $button_down Case True $paused = False Select Case $mouse_x < 0 $mouse_x = 0 Case $mouse_x > $desktop_width $mouse_x = $desktop_width Case Else $mouse_x = $mouse_x EndSelect Switch monitor_from_pointx($mouse_x, $desktop_width) Case 1 Select Case $mouse_y < 0 $mouse_y = 0 Case $mouse_y > @DesktopHeight $mouse_y = @DesktopHeight Case Else $mouse_y = $mouse_y EndSelect Case 2 Select Case $mouse_y < 0 $mouse_y = 0 Case $mouse_y > $monitorx_height $mouse_y = $monitorx_height Case Else $mouse_y = $mouse_y EndSelect EndSwitch EndSwitch EndSwitch EndSwitch Return _WinAPI_CallNextHookEx($hook, $iCode, $wParam, $lParam) EndFunc ;==>mouse_proc ; ===================================================================== ; = Hacky kludge ; = I intend to replace this with something that calls WindowFromPoint ; = or some other suitable function. ; ===================================================================== Func monitor_from_pointx(Const $x, Const $_desktop_width) Select Case $x <= @DesktopWidth Return 1 Case $x > $_desktop_width Return 2 EndSelect EndFunc ;==>monitor_from_pointx ; ====================================================================================================================== ; = Mostly Stolen From: ; = DrLarch: http://www.autoitscript.com/forum/topic/131618-detect-monitor-maximum-native-resolution/?p=1071159 ; ====================================================================================================================== Func get_monitorx_height() Local Const $display_device = DllStructCreate("dword; char[32]; char[128]; dword; char[128]; char[128]") DllStructSetData($display_device, 1, DllStructGetSize($display_device)) Local Const $display_monitor_amount = _WinAPI_GetSystemMetrics(80) DllCall("User32.dll", "bool", "EnumDisplayDevices", "ptr", 0, "dword", ($display_monitor_amount - 1), "ptr", DllStructGetPtr($display_device), "dword", 1) Local Const $device_name = DllStructGetData($display_device, 2) Local Const $tag_DEVMODE = "char dmDeviceName[32];ushort dmSpecVersion;ushort dmDriverVersion;short dmSize;" & _ "ushort dmDriverExtra;dword dmFields; long x;long y; dword dmDisplayOrientation;dword dmDisplayFixedOutput;" & _ "short dmColor;short dmDuplex;short dmYResolution;short dmTTOption;short dmCollate;" & _ "byte dmFormName[32];ushort LogPixels;dword dmBitsPerPel;int dmPelsWidth;dword dmPelsHeight;" & _ "dword dmDisplayFlags;dword dmDisplayFrequency" Local Const $DEVMODE = DllStructCreate($tag_DEVMODE) DllStructSetData($DEVMODE, "dmSize", DllStructGetSize($DEVMODE)) DllCall("User32.dll", "bool", "EnumDisplaySettings", "str", $device_name, "dword", -1, "ptr", DllStructGetPtr($DEVMODE)) Return DllStructGetData($DEVMODE, "dmPelsHeight") EndFunc ;==>get_monitorx_height Func cleanup() _WinAPI_UnhookWindowsHookEx($hook) DllCallbackFree($mouse_proc_callback) EndFunc ;==>cleanup 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 parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
jaberwacky Posted May 13, 2013 Author Share Posted May 13, 2013 I set my struct up using this page for my information: http://msdn.microsoft.com/en-us/library/windows/desktop/ms644968%28v=vs.85%29.aspx This worked well. It gave me accurate mouse coordinates. It didn't work for you? Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
guinness Posted May 13, 2013 Share Posted May 13, 2013 Weird it worked for. Anyway, my approach is correct according to MSDN. 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 parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
jaberwacky Posted May 13, 2013 Author Share Posted May 13, 2013 (edited) It's almost as though we're using two different MSDNs! typedef struct tagMOUSEHOOKSTRUCT { POINT pt; HWND hwnd; UINT wHitTestCode; ULONG_PTR dwExtraInfo; } MOUSEHOOKSTRUCT, *PMOUSEHOOKSTRUCT, *LPMOUSEHOOKSTRUCT; Ohhh, I see, you used: typedef struct tagMSLLHOOKSTRUCT { POINT pt; DWORD mouseData; DWORD flags; DWORD time; ULONG_PTR dwExtraInfo; } MSLLHOOKSTRUCT, *PMSLLHOOKSTRUCT, *LPMSLLHOOKSTRUCT; Which is definitely the one I should be using. DOH! Edited May 13, 2013 by jaberwocky6669 Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
guinness Posted May 13, 2013 Share Posted May 13, 2013 I use tagMSLLHOOKSTRUCT whereas you used tagMOUSEHOOKSTRUCT. Even so your version should be this... (notice the POINT) $tagMOUSEHOOKSTRUCT = $tagPOINT & ';hwnd hwnd;uint wHitTestCode;ulong_ptr dwExtraInfo' 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 parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
jaberwacky Posted May 13, 2013 Author Share Posted May 13, 2013 I'm just going to have to go back to the way I was doing it with the MouseGetPos. I don't know how to best deal with negative coordinates. If any body knows how, don't hesitate. Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
guinness Posted May 13, 2013 Share Posted May 13, 2013 Abs? 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 parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
jaberwacky Posted May 13, 2013 Author Share Posted May 13, 2013 (edited) True, but the values go into the negative hundreds. The problem this causes is that the mouse is wrapped multiple times even though I need it to only wrap once. Edited May 13, 2013 by jaberwocky6669 Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
jaberwacky Posted May 13, 2013 Author Share Posted May 13, 2013 Anyways, I need to study for my final exam. Chemistry. Wish me luck. Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
jaberwacky Posted May 13, 2013 Author Share Posted May 13, 2013 Sheesh, I just realized the simple solution to my problem. May not be the most elegant but whatever. I think I can honestly blame my lack of thinking on final exams stress and being sick. =P I will implement and post after my final exam this evening. Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now