Jump to content

$GUI_EVENT_MOUSEMOVE Help


Lecdev
 Share

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

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

Link to comment
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.

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

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

 

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

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

×
×
  • Create New...