Jump to content

MouseOnEvent UDF!


MrCreatoR
 Share

Recommended Posts

  • 4 weeks later...

Latest Unofficial version 1.11

for those searching for x buttons look no further! I've got X buttons working

X buttons added!

'x'tra buttons 4 & 5 on side of mouse. See my this post further down

If you still have problems with this UDF then try mouse trap UDF

Link to comment
Share on other sites

  • 1 month later...

Hi !

The script is very helpfull but i've got a problem when i'm using it on a remote computer.

When I use UltraVNC to take control of the remote computer using this script, the mouse movements are slow down like there was latency.

If i desactivate the Hook, the mouse movements are fine.

I guess UltraVNC change the input mouse movements in a certain way and so the script can't follow the updates ?

Do you have any idea ?

Thanks for your work.

P.S : Event handlers i'm using : Left/Right click up/down, Wheel up/down, MouseMove

EDIT : I didn't notice until now but the slow down movement is present only outside of the GUI not inside ! Any idea ?

Edited by tatane
Link to comment
Share on other sites

  • 4 weeks later...

Hey there ppl, got an issue with a script, as described in this topic:

The issue is that it works fine, until i click in the gui, then it crashes.

#include <misc.au3>
#include <WindowsConstants.au3>
#include <MouseOnEvent.au3>
#include <GUIConstantsEx.au3>
Opt("GUIOnEventMode", 1)
Local $hDLL = DllOpen("user32.dll")
$GUI = GUICreate("GUI Test", 200, 100, 100, 100, -1, $WS_EX_ACCEPTFILES)
GUISetOnEvent($GUI_EVENT_CLOSE, "Quit")
GUISetState()

_MouseSetOnEvent($MOUSE_WHEELSCROLLUP_EVENT, "_MouseWheelUP")
_MouseSetOnEvent($MOUSE_WHEELSCROLLDOWN_EVENT, "_MouseWheelDN")

;=============================================================================

Func _MouseWheelUP($iEvent)
    If _IsPressed("56") Then ;V
        ConsoleWrite('UP' & @CRLF)
    EndIf
EndFunc   ;==>_MouseWheelUP

;=============================================================================

Func _MouseWheelDN($iEvent)
    If _IsPressed("56") Then ;V
        ConsoleWrite('DN' & @CRLF)
    EndIf
EndFunc   ;==>_MouseWheelDN

;=============================================================================

While 1
    Sleep(15)
WEnd

Func Quit()
    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

  • 2 weeks later...

MouseClickDrag('left', 100, 100, 500, 500)

Or do you mean, block to not be able to drag and drop?

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

Never seen that, i would try to make a script that detects the mouse click, and then have a timer, after that key has been pressed for more than X msecs, force button up. Not sure how it can be done, but i believe it's possible, as for this udf, i don't see the option you need, available.

Sugestion: _ispressed, timerinit, send

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

  • 5 months later...

#include <MouseSetOnEvent_UDF.au3>

_BlockMouseClicksInput(0)

ToolTip('MouseClicks is disabled')
Sleep(3000)

_BlockMouseClicksInput(1)

ToolTip('MouseClicks is enabled')
Sleep(3000)

Func _BlockMouseClicksInput($iOpt=0)
    If $iOpt = 0 Then
        _MouseSetOnEvent($MOUSE_PRIMARYUP_EVENT, "__Dummy")
        _MouseSetOnEvent($MOUSE_PRIMARYDOWN_EVENT, "__Dummy")
        _MouseSetOnEvent($MOUSE_SECONDARYUP_EVENT, "__Dummy")
        _MouseSetOnEvent($MOUSE_SECONDARYDOWN_EVENT, "__Dummy")
    Else
        _MouseSetOnEvent($MOUSE_PRIMARYUP_EVENT)
        _MouseSetOnEvent($MOUSE_PRIMARYDOWN_EVENT)
        _MouseSetOnEvent($MOUSE_SECONDARYUP_EVENT)
        _MouseSetOnEvent($MOUSE_SECONDARYDOWN_EVENT)
    EndIf
EndFunc   ;==>_BlockMouseClicksInput

Don't work ... Mouse buttons are enabled ...

Link to comment
Share on other sites

#include <MouseSetOnEvent_UDF.au3>

_BlockMouseClicksInput(0)

ToolTip('MouseClicks is disabled')
Sleep(3000)

_BlockMouseClicksInput(1)

ToolTip('MouseClicks is enabled')
Sleep(3000)

Func _BlockMouseClicksInput($iOpt=0)
    If $iOpt = 0 Then
        _MouseSetOnEvent($MOUSE_PRIMARYUP_EVENT, "__Dummy")
        _MouseSetOnEvent($MOUSE_PRIMARYDOWN_EVENT, "__Dummy")
        _MouseSetOnEvent($MOUSE_SECONDARYUP_EVENT, "__Dummy")
        _MouseSetOnEvent($MOUSE_SECONDARYDOWN_EVENT, "__Dummy")
    Else
        _MouseSetOnEvent($MOUSE_PRIMARYUP_EVENT)
        _MouseSetOnEvent($MOUSE_PRIMARYDOWN_EVENT)
        _MouseSetOnEvent($MOUSE_SECONDARYUP_EVENT)
        _MouseSetOnEvent($MOUSE_SECONDARYDOWN_EVENT)
    EndIf
EndFunc   ;==>_BlockMouseClicksInput

Don't work ... Mouse buttons are enabled ...

Wheres __Dummy?

Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Link to comment
Share on other sites

How should the __ Dummy?

I never really looked into the UDF, but I think I may assume you need to define __Dummy somwhere.

Func __Dummy()
EndFunc

Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Link to comment
Share on other sites

#include <MouseSetOnEvent_UDF.au3>

_BlockMouseClicksInput(0)

ToolTip('MouseClicks is disabled')
Sleep(3000)

_BlockMouseClicksInput(1)

ToolTip('MouseClicks is enabled')
Sleep(3000)

Func _BlockMouseClicksInput($iOpt=0)
    If $iOpt = 0 Then
        _MouseSetOnEvent($MOUSE_PRIMARYUP_EVENT, "__Dummy")
        _MouseSetOnEvent($MOUSE_PRIMARYDOWN_EVENT, "__Dummy")
        _MouseSetOnEvent($MOUSE_SECONDARYUP_EVENT, "__Dummy")
        _MouseSetOnEvent($MOUSE_SECONDARYDOWN_EVENT, "__Dummy")
    Else
        _MouseSetOnEvent($MOUSE_PRIMARYUP_EVENT)
        _MouseSetOnEvent($MOUSE_PRIMARYDOWN_EVENT)
        _MouseSetOnEvent($MOUSE_SECONDARYUP_EVENT)
        _MouseSetOnEvent($MOUSE_SECONDARYDOWN_EVENT)
    EndIf
EndFunc   ;==>_BlockMouseClicksInput
Func __Dummy()
EndFunc

 

Don't work.... Buttons are enabled

Link to comment
Share on other sites

  • 3 weeks later...

See the example BlockMouseClicksInput, you must pass a 0 , 1 you don't even need to define a dummy func..

hope it helps.

Func _BlockMouseClicksInput($iOpt = 0)
    If $iOpt = 0 Then
        _MouseSetOnEvent($MOUSE_PRIMARYUP_EVENT, "__Dummy", 0, 1)
        _MouseSetOnEvent($MOUSE_PRIMARYDOWN_EVENT, "__Dummy", 0, 1)
        _MouseSetOnEvent($MOUSE_SECONDARYUP_EVENT, "__Dummy", 0, 1)
        _MouseSetOnEvent($MOUSE_SECONDARYDOWN_EVENT, "__Dummy", 0, 1)
    Else
        _MouseSetOnEvent($MOUSE_PRIMARYUP_EVENT)
        _MouseSetOnEvent($MOUSE_PRIMARYDOWN_EVENT)
        _MouseSetOnEvent($MOUSE_SECONDARYUP_EVENT)
        _MouseSetOnEvent($MOUSE_SECONDARYDOWN_EVENT)
    EndIf
EndFunc
Link to comment
Share on other sites

  • 1 year later...

Hi, MrCreatoR. I'v been interested in setting some mouse hotkeys, but at current state this UDF has some very limited use. For example, following code is valid, because standard HotkeySet leaks the key into processing chain, while yours doesn't.

#include <misc.au3>

HotkeySet("z", "SomeFunc")
While 1
   Sleep(40)
WEnd

Func SomeFunc()
   While _IsPressed "5A"
      SomeRepeatableFunc()
      Sleep(10)
   WEnd
EndFunc

Func SomeRepeatableFunc()
   Send("Holla! ")
EndFunc

If it would, then there would be a lot easier to set a "combined hotkey" such as:

#include <misc.au3>
#include "MouseOnEvent.au3"

_MouseSetOnEvent($RMouse, "SomeFunc")

While 1
   Sleep(100)
WEnd

Func SomeFunc()
   _MouseSetOnEvent($LMouse, "SomeRepeatableFunc")
   While _IsPressed (2)
      Sleep(50)
   WEnd
   _MouseSetOnEvent($LMouse)
EndFunc

Func SomeRepeatableFunc()
   Send("Holla! ")
EndFunc

AHK has mouse hotkeys, hotkeys combination and Keyb+mouse hotkeys supported natively, but Autoit is much more convenient to use :), so I was wondering... ;)

P.S.

;Altered var names for convenience measures
Global Const $MouseMv_EV                    = 0x200         ;512 (WM_MOUSEMOVE)         ; ==> Mouse moving.
Global Const $LMouse                        = 0x201         ;513 (WM_LBUTTONDOWN)       ; ==> Primary mouse button down.
Global Const $LMouseUP                      = 0x202         ;514 (WM_LBUTTONUP)         ; ==> Primary mouse button up.
Global Const $LMouseDClick                  = 0x203         ;515 (WM_LBUTTONDBLCLK)     ; ==> Primary mouse button double click.
Global Const $RMouse                        = 0x204         ;516 (WM_RBUTTONDOWN)       ; ==> Secondary mouse button down.
Global Const $RMouseUP                      = 0x205         ;517 (WM_RBUTTONUP)         ; ==> Secondary mouse button up.
Global Const $RMouseDClick                  = 0x206         ;518 (WM_RBUTTONDBLCLK)     ; ==> Secondary mouse button double click.
Global Const $MMouse                        = 0x207         ;519 (WM_MBUTTONDOWN)       ; ==> Wheel mouse button pressed down.
Global Const $MMouseUP                      = 0x208         ;520 (WM_MBUTTONUP)         ; ==> Wheel mouse button up.
Global Const $MMouseDClick                  = 0x209         ;521 (WM_MBUTTONDBLCLK)     ; ==> Wheel mouse button double click.
Global Const $Wheel_EV                      = 0x20A         ;522 (WM_MOUSEWHEEL)        ; ==> Wheel mouse scroll.
Global Const $WheelDown                     = 0x20A + 8     ;530 (WM_MOUSEWHEEL + 8)    ; ==> Wheel mouse scroll Down.
Global Const $WheelUp                       = 0x20A + 16    ;538 (WM_MOUSEWHEEL + 16)   ; ==> Wheel mouse scroll Up.
Global Const $MouseX_EV                     = 0x20B         ;523 (WM_XBUTTONDOWN)       ; ==> Side mouse button down (usually navigating next/back buttons).
Global Const $MouseXUP_EV                   = 0x20C         ;524 (WM_XBUTTONUP)         ; ==> Side mouse button up.
Global Const $MouseXDClick                  = 0x20D         ;525 (WM_XBUTTONDBLCLK)     ; ==> Side mouse button double click.
Edited by PsiLink
Link to comment
Share on other sites

Hi, MrCreatoR. I'v been interested in setting some mouse hotkeys, but at current state this UDF has some very limited use. For example, following code is valid, because standard HotkeySet leaks the key into processing chain, while yours doesn't.

Hi, i am not sure that i understand, what exactly are you trying to do, what your expecting to happen?

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

The thing is, that native Autoit function HotkeySet and your UDF function a little differently.

#include <misc.au3>
#include "mouseOnEvent.au3"

HotkeySet("z", "SomeFunc")
_MouseSetOnEvent($RMouse, "AnotherFunc")

While 1
   Sleep(100
WEnd

Func SomeFunc()
   While _IsPressed("5A")
      ConsoleWrite('KeybZ ')
      Sleep(10)
   WEnd
EndFunc

Func AnotherFunc()
   While _IsPressed(2)
      ConsoleWrite('RMB2 ')
      Sleep(10)
   WEnd
EndFunc

I want to set some "combined hotkeys" like RMB+LMB, RMB+WheelDown or even RMB+move mouse in certain direction. For this to work, _IsPressed should notice the key was actually pressed and that is a problem.

My current solution is all about using _IsPressed(), but it could have been much more convenient if there were actual hotkey

#include <MouseOnEvent.au3>
#include <Misc.au3>

Global Const $Btn1Down = '_IsPressed(1)' ;LMB
Global Const $Btn2Down = '_IsPressed(2)' ;RMB

$bRBMUsedInHK = False

Loop()

Func Loop()
   While 1
      If Execute($Btn2Down) Then
         While Execute($Btn2Down)
            Sleep(30)

            If Execute($Btn1Down) Then
               While Execute($Btn1Down)
                  Sleep(10)
               WEnd

               ConsoleWrite('1 ')
               $bRBMUsedInHK = True
            EndIf
         WEnd
      EndIf

      If $bRBMUsedInHK Then ;Close context menu if any
         Send("{altdown}")
         Sleep(40)
         Send("{altup}")
         $bRBMUsedInHK = False
      EndIf

      Sleep(50)
   WEnd
EndFunc

P.S. Можно и на русском, но форум ведь зарубежный :)

Link to comment
Share on other sites

  • 3 months later...

i have some troubles with using MouseSetOnEvent udf in x64 script - after mouse clicks it always crush with "AutoIt3.exe ended.rc:128"

#AutoIt3Wrapper_UseX64=Y
#include "MouseOnEvent.au3"

$Form1 = GUICreate("some gui", 333, 222, @DesktopWidth/2-175, @DesktopHeight/2-111)
$Input1 = GUICtrlCreateInput("some text", 8, 8, 921, 21)
GUISetState(@SW_SHOW)
_MouseSetOnEvent($MOUSE_PRIMARYDBLCLK_EVENT, '_DblClk_Event')

While 1
    Sleep(10)
WEnd
_MouseSetOnEvent($MOUSE_PRIMARYDBLCLK_EVENT)

is there a some fix for it?

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...