Jump to content
Lecdev

$GUI_EVENT_MOUSEMOVE Help

Recommended Posts

Can anyone tell me the default parameter to input into, GUISetOnEvent($GUI_EVENT_MOUSEMOVE, "")  to disable a previously set user defined function?

help file example says empty string ("") which works for other events but doesnt seem to on mouse move.

Ive attached some of my test code to select icon by clicking and click on screen where needed to create an icon the same or cancel by right clicking and then escape the window with the keyboard escape key. best solution i have come up with after a few hours of trying different things is to create a DoNothing() function

 

any help would be appreciated.

dummy2.au3

Share this post


Link to post
Share on other sites

Maybe i didn't get  the issue, what is not happening that should?


Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Share this post


Link to post
Share on other sites

In the sample change lines 53 and 63 from GUISetOnEvent($GUI_EVENT_MOUSEMOVE, "DoNothing") to GUISetOnEvent($GUI_EVENT_MOUSEMOVE, "") as it should be in order to disable the user defined on event function as per autoit help file and you should see it doesnt actually disable the function and the icon never stops following the mouse. (provided the script behaves the same on your pc as it does mine)

I dont want the script to be calling a function forever everytime the mouse moves because its just undue stress on cpu usage, i would prefer to disable the on event function when its not needed the same way you can with other special event IDs.

Share this post


Link to post
Share on other sites

Consider this option:

PS my path to the icon is different "C:\Program Files (x86)\AutoIt3\Icons\MyAutoIt3_Yellow.ico" so you should change back.

#include <Misc.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
Opt("MouseCoordMode", 2) ;1=absolute, 0=relative, 2=client
#Region ### START Koda GUI section ### Form=
Global $Form1 = GUICreate("Form1", @DesktopWidth/2,@DesktopHeight/2)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "Form1Minimize")
GUISetOnEvent($GUI_EVENT_MAXIMIZE, "Form1Maximize")
GUISetOnEvent($GUI_EVENT_RESTORE, "Form1Restore")
Global $Icon1 = GUICtrlCreateIcon("C:\Program Files (x86)\AutoIt3\Icons\MyAutoIt3_Yellow.ico", -1, 5, 5, 32, 32)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Global $IconCenterLeft, $IconCenterTop
;=============================================================================
While 1
    ;=============================================================================
    $CursorInfo = GUIGetCursorInfo($Form1)
    $WinCoords = WinGetPos($Form1)
    ;=============================================================================
    If $CursorInfo[4] = $Icon1 Then
        If _IsPressed(01) Then
            Icon1Click()
        EndIf
        If _IsPressed(02) Then
            GUICtrlSetPos($Icon1,5,5,32,32)
        EndIf
    EndIf
    Sleep(100)
WEnd
;=============================================================================
Func Icon1Click()
        Do
            $IconCenterLeft = MouseGetPos(0) - 16
            $IconCenterTop = MouseGetPos(1) - 16
            GUICtrlSetPos($Icon1,$IconCenterLeft,$IconCenterTop,32,32)
            Sleep(100)
            If _IsPressed(01) Then
            $Icon2 = GUICtrlCreateIcon("C:\Program Files (x86)\AutoIt3\Icons\MyAutoIt3_Yellow.ico", -1, $IconCenterLeft, $IconCenterTop, 32, 32)
            EndIf
        Until _IsPressed(01) Or _IsPressed(02)
        GUICtrlSetPos($Icon1,5,5,32,32)
EndFunc
;=============================================================================
Func Form1Maximize()

EndFunc
;=============================================================================
Func Form1Minimize()

EndFunc
;=============================================================================
Func Form1Restore()

EndFunc
;=============================================================================
Func Form1Close()
Exit
EndFunc
;=============================================================================

 


Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Share this post


Link to post
Share on other sites

well part of the point is to replace the curser with the icon temporarily and unfortunately if you set the curser to id 16 to hide it _ispressed(01) or 02 dont work anymore.

but I can do a bit of a hybrid below; Still no idea why the empty string doesnt disable the event function on GUISetOnEvent($GUI_EVENT_MOUSEMOVE ,"") though, thats a bit strange.

 

#NoTrayIcon
#include <Misc.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
Opt("MouseCoordMode", 2) ;1=absolute, 0=relative, 2=client ( final application will need to be absolute (default) )
#Region ### START Koda GUI section ### Form=
Global $Form1 = GUICreate("Form1", @DesktopWidth / 2, @DesktopHeight / 2)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
Global $Icon1 = GUICtrlCreateIcon(@ProgramFilesDir & "\AutoIt3\Icons\MyAutoIt3_Yellow.ico", -1, 5, 5, 32, 32)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Global $EscapeDropIcon = 0, $IconCenterLeft, $IconCenterTop, $CursorInfo

While 1
    $CursorInfo = GUIGetCursorInfo($Form1)
    $WinCoords = WinGetPos($Form1)
    If $CursorInfo[4] = $Icon1 Then
        If _IsPressed(01) Then
            Icon1Click()
        EndIf
        If _IsPressed(02) Then
            GUICtrlSetPos($Icon1, 5, 5, 32, 32)
        EndIf
    EndIf
    Sleep(75)
WEnd

Func Icon1Click()
    GUICtrlSetCursor($Icon1, 16)
    GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "_IconPasteAtPosition")
    GUISetOnEvent($GUI_EVENT_SECONDARYDOWN, "_EscapeFollow")
    $EscapeDropIcon = 0
    Local $TempCurserX, $TempCurserY
    Do
        $TempCurserX = MouseGetPos(0) - 16
        $TempCurserY = MouseGetPos(1) - 16
        If ($TempCurserX <> $IconCenterLeft) Or ($TempCurserY <> $IconCenterTop) Then
            $IconCenterLeft = $TempCurserX
            $IconCenterTop = $TempCurserY
            GUICtrlSetPos($Icon1, $IconCenterLeft, $IconCenterTop, 32, 32)
        EndIf
        Sleep(15)
    Until $EscapeDropIcon
    GUICtrlSetPos($Icon1, 5, 5, 32, 32)
    GUICtrlSetCursor($Icon1, -1)
EndFunc   ;==>Icon1Click

Func Form1Close()
    Exit
EndFunc   ;==>Form1Close

Func _IconPasteAtPosition()
    If Not $EscapeDropIcon Then
        GUICtrlCreateIcon(@ProgramFilesDir & "\AutoIt3\Icons\MyAutoIt3_Yellow.ico", -1, $IconCenterLeft, $IconCenterTop, 32, 32)
        GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "")
        GUISetOnEvent($GUI_EVENT_SECONDARYDOWN, "")
        $EscapeDropIcon = 1
    EndIf
EndFunc   ;==>_IconPasteAtPosition

Func _EscapeFollow()
    GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "")
    GUISetOnEvent($GUI_EVENT_SECONDARYDOWN, "")
    $EscapeDropIcon = 1
EndFunc   ;==>_EscapeFollow

 

Share this post


Link to post
Share on other sites
Func Icon1Click()
GUICtrlSetCursor($Icon1, 16)
    Sleep(100)
        Do
            $IconCenterLeft = MouseGetPos(0) - 16
            $IconCenterTop = MouseGetPos(1) - 16
            GUICtrlSetPos($Icon1,$IconCenterLeft,$IconCenterTop,32,32)
            Sleep(20)
            If _IsPressed(01) Then
            $Icon2 = GUICtrlCreateIcon("C:\Program Files (x86)\AutoIt3\Icons\MyAutoIt3_Yellow.ico", -1, $IconCenterLeft, $IconCenterTop, 32, 32)
            EndIf
        Until _IsPressed(01) Or _IsPressed(02)
        GUICtrlSetPos($Icon1,5,5,32,32)
EndFunc

What do you mean if the cursor becomes the icon it no longer works? here it does, like this.

As for the GUISetOnEvent($GUI_EVENT_MOUSEMOVE ,"")  issue, i think maybe create another topic on why it doesn't work for disable, and maybe if it turns out a bug, it then is fixed.

Edited by careca

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Share this post


Link to post
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

  • Similar Content

    • By ahha
      This one has me baffled.  I can't seem to get MouseMove to work properly with scaling in some windows.
      Run this program and use the arrow keys to move the mouse Up, Down, Left, Right at native (100%) scaling and it works as expected. 
      Now go to 125%, for example, and move Up, Down, Left, Right on the desktop and it works.
      Now open the MouseMove help window (cursor on MouseMove then F1).
      Move the mouse into the MouseMove help window and try Up, Down, Left, Right and the movements are diagonal!
      If you move, for example, right from desktop into the MouseMove window it goes from moving right to down and right (diagonal) as soon as the mouse hits the MouseMove help window.  I'm stumped.
      How do I get MouseMove to work properly?  Any hints appreciated.
      ; ;#AutoIt3Wrapper_run_debug_mode=Y ; use this to debug in console window <--- LOOK ;Trying to figure out how to scale properly for MouseMove - moving mouse in Up, Down, Left, Right moves diagonally on some windows if scale <> 1 (100%). ;Test on main monitor and use 1920x1080 then scale to 125% as simple example. ;To change display scale in Windows 10, right click on desktop "Display Settings" --> Scale and layout ;arrow keys on arrow keypad HotKeySet("{UP}", "__UpMouse") HotKeySet("{DOWN}", "__DownMouse") HotKeySet("{LEFT}", "__LeftMouse") HotKeySet("{RIGHT}", "__RightMouse") ;v2g - cutting out superfluous code to show issue, added scaling Opt("MouseCoordMode",1) ;1 = absolute screen coordinates (default) - use this because otherwise active window mucks it up $scale = _GetScale() MsgBox(0,"DEBUG", "$scale = " & $scale) While 1 ;watch the console - the mouse is not moving correctly Sleep(10) ;this works well and does not appear to use the CPU WEnd ;================= Functions ================== Func __UpMouse() Local $mousepos, $mouseposafter $mousepos = MouseGetPos() MouseMove($mousepos[0]+0, $mousepos[1]-1) $mouseposafter = MouseGetPos() ConsoleWrite("in __UpMouse()" & @CRLF & "Before UP (x,y) = " & $mousepos[0] & "," & $mousepos[1] & @CRLF & " After UP (x,y) = " & $mouseposafter[0] & "," & $mouseposafter[1] & @CRLF & @CRLF) EndFunc Func __DownMouse() Local $mousepos, $mouseposafter $mousepos = MouseGetPos() MouseMove($mousepos[0]+0, $mousepos[1]+1) $mouseposafter = MouseGetPos() ConsoleWrite("in __DownMouse()" & @CRLF & "Before DOWN (x,y) = " & $mousepos[0] & "," & $mousepos[1] & @CRLF & " After DOWN (x,y) = " & $mouseposafter[0] & "," & $mouseposafter[1] & @CRLF & @CRLF) EndFunc Func __LeftMouse() Local $mousepos, $mouseposafter $mousepos = MouseGetPos() MouseMove($mousepos[0]-1, $mousepos[1]+0) $mouseposafter = MouseGetPos() ConsoleWrite("in __LeftMouse()" & @CRLF & "Before LEFT (x,y) = " & $mousepos[0] & "," & $mousepos[1] & @CRLF & " After LEFT (x,y) = " & $mouseposafter[0] & "," & $mouseposafter[1] & @CRLF & @CRLF) EndFunc Func __RightMouse() Local $mousepos, $mouseposafter $mousepos = MouseGetPos() MouseMove($mousepos[0]+1, $mousepos[1]+0) $mouseposafter = MouseGetPos() ConsoleWrite("in __RightMouse()" & @CRLF & "Before RIGHT (x,y) = " & $mousepos[0] & "," & $mousepos[1] & @CRLF & " After RIGHT (x,y) = " & $mouseposafter[0] & "," & $mouseposafter[1] & @CRLF & @CRLF) EndFunc Func _GetScale() ;returns a scale factor for PixelGetColor ;from: https://www.autoitscript.com/forum/topic/156251-mouse-coordinates/?tab=comments#comment-1130002 $tDEVMODE = DllStructCreate('byte[32];dword[10];byte[32];dword[6]') $pDEVMODE = DllStructGetPtr($tDEVMODE) $i = 0 while 1 $ret = DllCall('user32.dll', 'int', 'EnumDisplaySettings', 'ptr', 0, 'dword', $i, 'ptr', $pDEVMODE) if ($ret[0] = 0) then exitloop $width = DllStructGetData($tDEVMODE, 4, 2) ; native width $i += 1 wend $scale = $width / @DesktopWidth Return($scale) EndFunc  
    • By LegitStack
      So I'm trying to make a script that will move my mouse when I scroll. I know that's weird, but I have my reasons. What I have so far can detect when I'm moving my mouse, but then when I tell the script to make my mouse move whenever it detects scroll activity it freezes. probably because of some feedback loop.
      Anyway, If anyone on here wants to help, I'm at a loss of how to solve this problem. Like maybe when it is about to take the action of moving the mouse it could stop detection for a bit, idk. but I don't know how to do that.
       
       
      #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> #include <MsgBoxConstants.au3> #include <Misc.au3> #include <GUIConstants.au3> Global Const $MSLLHOOKSTRUCT = $tagPOINT & ";dword mouseData;dword flags;dword time;ulong_ptr dwExtraInfo" Global $currentEvent Global $hDLL = DllOpen("user32.dll") #Region ### START Koda GUI section ### Form= ;Register callback $hKey_Proc = DllCallbackRegister("_Mouse_Proc", "int", "int;ptr;ptr") $hM_Module = DllCall("kernel32.dll", "hwnd", "GetModuleHandle", "ptr", 0) $hM_Hook = DllCall("user32.dll", "hwnd", "SetWindowsHookEx", "int", $WH_MOUSE_LL, "ptr", DllCallbackGetPtr($hKey_Proc), "hwnd", $hM_Module[0], "dword", 0) #EndRegion ### END Koda GUI section ### While 1 WEnd Func _Mouse_Proc($nCode, $wParam, $lParam) Local $info, $mouseData If $nCode < 0 Then $ret = DllCall("user32.dll", "long", "CallNextHookEx", "hwnd", $hM_Hook[0], _ "int", $nCode, "ptr", $wParam, "ptr", $lParam) Return $ret[0] EndIf $info = DllStructCreate($MSLLHOOKSTRUCT, $lParam) $mouseData = DllStructGetData($info, 3) Select Case $wParam = $WM_MOUSEWHEEL If _WinAPI_HiWord($mouseData) > 0 Then ;Wheel Up $currentEvent = "WheelUp" Else ;Wheel Down $currentEvent = "WheelDown" If _IsPressed("02", $hDLL) Then MsgBox(0,"test","test") EndIf EndIf EndSelect ;;;;;;Mouse Movement CAUSES FREEZING, MAKES ME RESTART COMPUTER: if $currentEvent == "WheelUp" then $pos = MouseGetPos() MouseMove($pos[0]+100,$pos[1]+100,0) EndIf $ret = DllCall("user32.dll", "long", "CallNextHookEx", "hwnd", $hM_Hook[0], _ "int", $nCode, "ptr", $wParam, "ptr", $lParam) Return $ret[0] EndFunc ;==>_Mouse_Proc Func OnAutoItExit() DllCall("user32.dll", "int", "UnhookWindowsHookEx", "hwnd", $hM_Hook[0]) $hM_Hook[0] = 0 DllCallbackFree($hKey_Proc) $hKey_Proc = 0 EndFunc ;==>OnAutoItExit  
    • By Miliardsto
      Hello I got this script works below and I want to do not move cursor on screen when action is performed.
      Opt("MouseCoordMode", 1) ; cause it gets whole screen coords Local $x, $y Local $search = _ImageSearch('item.bmp', 0, $x, $y, 0) If $search = 1 Then MouseMove($x, $y,0) MouseClick("right", $x, $y)) MouseMove($xMiddle, $yMiddle,0) MouseClick("left", $xMiddle, $yMiddle) EndIf I changed this above to this below and what happen is. It clicks right button and then left button but not move mouse to $x $y and then to $xMiddle $yMiddle.
      Opt("MouseCoordMode", 1) ; cause it gets whole screen coords Local $x, $y Local $search = _ImageSearch('item.bmp', 0, $x, $y, 0) If $search = 1 Then ControlClick("","",0,"secondary",1,$x,$y) ControlClick("","",0,"primary",1,$xMiddle,$yMiddle) EndIf If needed I got handle in var $hwnd
      Please tell me how parameters in ControlClick would like be
    • By Fuzy
      #include<img/img.au3>
      #include <AutoItConstants.au3>
      Func Skype()
      $coords = imageSearch(0,0,-1,-1,"Skype.PNG")
      MouseMove($coords[0],$coords[1])
      [when it find the skype icon i want it to move from these coordinates, but of insted of moving to an expecific coordinate i want it to move down from these coordinates, (there is multiple images so i cant move to an specific image)] -- Kinda having trouble telling what i want cuz english isnt my first language, sorry about that. ;X
      MouseClick($MOUSE_CLICK_LEFT)
    • By jannikrendl
      Hey,
      so I was trying to create a script which clicks an option of a dropdown menu but can't find a solution to move the mouse from the current position 50 units down...
      If someone knows how to do this pls help me
      [EDIT: MBY the solution is to just use MouseGetPos and then use MouseMove(MouseGetPos[0],MouseGetPos[1]+50)? but idk... mby there is a better solution...
      Global $aPos = MouseGetPos Sleep(10000) MouseMove($aPos[0],$aPos[1]+50,10) ] Edit 2: NOPE Isn't working...
      Thanks in advance
      Jannik
×
×
  • Create New...