MouseOnEvent UDF!


163 posts in this topic

#1 ·  Posted (edited)

This UDF allows to set an events handler (a hook) for Mouse device.

The beginning...

I searched for a way to disable the Mouse Primary click, and be able to call some function when the click event is received...

Big thanks to amel27 for this one, i only organized the whole stuff to UDF style.

Example:

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

HotKeySet("{ESC}", "_Quit")

_Example_Intro()
_Example_Limit_Window()

Func _Example_Intro()
    MsgBox(64, "Attention!", "Let's set event function for mouse wheel *scrolling* up and down", 5)

    ;Set event function for mouse wheel *scrolling* up/down and primary button *down* action (call our function when the events recieved)
    _MouseSetOnEvent($MOUSE_WHEELSCROLLDOWN_EVENT, "_MouseWheel_Events")
    _MouseSetOnEvent($MOUSE_WHEELSCROLLUP_EVENT, "_MouseWheel_Events")
    _MouseSetOnEvent($MOUSE_PRIMARYDOWN_EVENT, "_MousePrimaryDown_Event")

    Sleep(3000)

    ;UnSet the events
    _MouseSetOnEvent($MOUSE_WHEELSCROLLDOWN_EVENT)
    _MouseSetOnEvent($MOUSE_WHEELSCROLLUP_EVENT)
    _MouseSetOnEvent($MOUSE_PRIMARYDOWN_EVENT)

    ToolTip("")

    MsgBox(64, "Attention!", "Now let's disable Secondary mouse button up action, and call our event function.", 5)

    _MouseSetOnEvent($MOUSE_SECONDARYUP_EVENT, "_MouseSecondaryUp_Event", 0, 1)
    Sleep(5000)
    _MouseSetOnEvent($MOUSE_SECONDARYUP_EVENT)

    ToolTip("")
EndFunc

Func _Example_Limit_Window()
    Local $hGUI = GUICreate("MouseOnEvent UDF Example - Restrict events on specific window")

    GUICtrlCreateLabel("Try to click on that specific GUI window", 40, 40, 300, 30)
    GUICtrlSetFont(-1, 12, 800)
    GUICtrlCreateLabel("Press <CTRL + Q> to exit", 10, 10)
    GUISetState()

    _MouseSetOnEvent($MOUSE_PRIMARYDOWN_EVENT, "_MousePrimaryDown_Event", $hGUI)
    ;A little(?) bugie when you mix different events :(
    ;_MouseSetOnEvent($MOUSE_SECONDARYUP_EVENT, "_MouseSecondaryUp_Event", $hGUI)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $GUI_EVENT_PRIMARYDOWN
                MsgBox(0, "", "Should be shown ;)")
        EndSwitch
    WEnd

    _MouseSetOnEvent($MOUSE_PRIMARYDOWN_EVENT)
    ;_MouseSetOnEvent($MOUSE_SECONDARYUP_EVENT)
EndFunc

Func _MouseWheel_Events($iEvent)
    Switch $iEvent
        Case $MOUSE_WHEELSCROLLDOWN_EVENT
            ToolTip("Wheel Mouse Button (scrolling) DOWN Blocked")
        Case $MOUSE_WHEELSCROLLUP_EVENT
            ToolTip("Wheel Mouse Button (scrolling) UP Blocked")
    EndSwitch

    Return 1 ;Block
EndFunc

Func _MousePrimaryDown_Event()
    ToolTip("Primary Mouse Button Down Blocked")
    Return 1 ;Block
EndFunc

Func _MouseSecondaryUp_Event()
    ToolTip("Secondary Mouse Button Up Blocked")
EndFunc

Func _Quit()
    Exit
EndFunc

Available Events Constants:

$MOUSE_MOVE_EVENT - Mouse moving.

$MOUSE_PRIMARYDOWN_EVENT - Primary mouse button down.

$MOUSE_PRIMARYUP_EVENT - Primary mouse button up.

$MOUSE_PRIMARYDBLCLK_EVENT - Primary mouse button double click.

$MOUSE_SECONDARYDOWN_EVENT - Secondary mouse button down.

$MOUSE_SECONDARYUP_EVENT - Secondary mouse button up.

$MOUSE_SECONDARYDBLCLK_EVENT - Secondary mouse button double click.

$MOUSE_WHEELDOWN_EVENT - Wheel mouse button pressed down.

$MOUSE_WHEELUP_EVENT - Wheel mouse button up.

$MOUSE_WHEELDBLCLK_EVENT - Wheel mouse button double click.

$MOUSE_WHEELSCROLL_EVENT - Wheel mouse scroll.

$MOUSE_WHEELSCROLLDOWN_EVENT - Wheel mouse scroll Down.

$MOUSE_WHEELSCROLLUP_EVENT - Wheel mouse scroll Up.

$MOUSE_XBUTTONDOWN_EVENT - Side mouse button down (usually navigating next/back buttons).

$MOUSE_XBUTTONUP_EVENT - Side mouse button up.

$MOUSE_XBUTTONDBLCLK_EVENT - [Not implemented yet] Side mouse button double click.

------------------------------------------

CHANGELOG:

v1.9 [22.07.2012]

* Script breaking version!

* Dropped AutoIt 3.3.0.0 support.

* Instead of $sParam1 and $sParam2, now $vParam used as last parameter.

* Event function ($sFuncName) now called with $iEvent as first parameter, and $vParam as second (both optional).

* Now $iBlockDefProc is set to -1 by default (event function can define whether to block event process or not, simply by returning 1 or 0).

* Fixed not working $MOUSE_PRIMARYDBLCLK_EVENT and $MOUSE_SECONDARYDBLCLK_EVENT,

now handled manually because windows does not always receive these events (depending on CS_DBLCLKS style).

(not tested properly, so these events will have "experimental" label for now).

* Fixed error related to "Subscript used with non-Array variable", caused when window with handle of $hTargetWnd parameter is not found (window closed).

* Examples updated.

v1.8 [02.06.2010]

* Fixed an issue with wrong handling when $MOUSE_XBUTTONUP/DOWN_EVENT and few other events are set.

* Fixed an issue when user attempts to set other function for the event that already have been set.

Now the function and other parameters are replaced for the current event.

* UDF file renamed (removed "Set" in the middle and "_UDF" at the end of the name).

* Cosmetic changes in the UDF code.

* Docs updated.

v1.7 [14.10.2009]

* Stability fixes. Thanks again to wraithdu.

v1.6 [13.10.2009]

* Fixed an issue with releasing the resources of mouse hook (Thanks to wraithdu).

v1.5 [09.10.2009]

+ Added wheel button up/down *scrolling* event recognition. Thanks to JRowe (http://www.autoitscript.com/forum/index.php?showtopic=103362).

* Fixed an issue with returning value from __MouseSetOnEvent_MainHandler - should call _WinAPI_CallNextHookEx before return (thanks to Yashied).

* Constants starting with MOUSE_EXTRABUTTON* renamed to MOUSE_XBUTTON*, as it should be in the first place.

* Few examples updated.

v1.4 [30.09.2009]

+ Added UDF header to the function.

+ Now the original events-messages (such as $WM_MOUSEMOVE) can be used as well.

+ Added missing events (althought i am not sure if they are still supported)

$MOUSE_PRIMARYDBLCLK_EVENT - Primary mouse button double click.
$MOUSE_SECONDARYDBLCLK_EVENT - Secondary mouse button double click.
$MOUSE_WHEELDBLCLK_EVENT - Wheel mouse button double click.
$MOUSE_EXTRABUTTONDBLCLK_EVENT - Side mouse button double click.

* Changed global vars and internal functions names to be more unique.

* Fixed variables declaration and misspelling.

v1.3 [27.10.2008]

* Added optional parameter $iBlockDefProc - Define wether the Mouse events handler will block the default processing or not (Default is 1, block). If this is -1, then user can Return from the event function to set processing operation (see the attached example «AutoDrag window.au3»).

v1.2 [05.04.2008]

* Added: [Optional] parameter $hTargetWnd, if set, the OnEvent function will be called only on $hTargetWnd window, otherwise will be standard Event processing.

Note: Can be a little(?) buggy when you mix different events :)

v1.1 [22.03.2008]

* Fixed: Incorrect ReDim when remove event from the array, it was causing UDF to crash script with error.

* Spell/Grammar corrections :)

* Added: An example of _BlockMouseClicksInput().

Download:

From Downloads: MouseOnEvent.zip

Attached: MouseOnEvent.zip

Old version:

MouseSetOnEvent_UDF_1.8.zip

MouseSetOnEvent_UDF_1.7.zip

MouseSetOnEvent_UDF_1.6.zip

MouseSetOnEvent_UDF_1.5.zip

MouseSetOnEvent_UDF_1.4.zip

MouseSetOnEvent_UDF_1.3.zip

Previous downloads: 146 + 200 + 804

Edited by MrCreatoR
3 people like this

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

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

Share this post


Link to post
Share on other sites



#2 ·  Posted

One mounth, 51 downloads (views?), and no comments? :)

:)


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

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

Share this post


Link to post
Share on other sites

#3 ·  Posted

Hi,

seems to work quite fine! But I do not use OnEvent mode.

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

#4 ·  Posted

Maybe the problem is that the title says "_MoseSetOnEvent"

Share this post


Link to post
Share on other sites

#5 ·  Posted

seems to work quite fine!

Thanks.

But I do not use OnEvent mode.

The UDF has nothing to do with OnEvent mode :) - you can use it with any mode :)

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

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

Share this post


Link to post
Share on other sites

#6 ·  Posted

Thanks.

The UDF has nothing to do with OnEvent mode :) - you can use it with any mode :)

:party: did just one short run and assumed the rest.

It is cool. This way, it is possible to add an option to BlockInput to just disable the mouse.

I tried this but it gets an error.

#include <MouseSetOnEvent_UDF.au3>
_blockInput()
ToolTip('MouseClicks is disabled')
Sleep(5000)
_blockInput(1)
ToolTip('MouseClicks is enabled')
Sleep(5000)

Func _blockInput($opt = 0)
    If $opt = 0 Then
        _MouseSetOnEvent($MOUSE_PRIMARYDOWN_EVENT, "_do")
        _MouseSetOnEvent($MOUSE_SECONDARYDOWN_EVENT, "_do")
    Else
        _MouseSetOnEvent($MOUSE_PRIMARYDOWN_EVENT)
        _MouseSetOnEvent($MOUSE_SECONDARYDOWN_EVENT)
    EndIf
EndFunc   ;==>_blockInput

Func _do()
EndFunc

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

#7 ·  Posted

This is really useful, will certainly add this to my autoit directory on my desktop :)


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites

#8 ·  Posted

:) did just one short run and assumed the rest.

It is cool. This way, it is possible to add an option to BlockInput to just disable the mouse.

I tried this but it gets an error.

Oops :) , the error is because i did a mistake when the array is Redimmed... just find in the UDF this line:

ReDim $aTmp_Mouse_Events[$aTmp_Mouse_Events[0][0]+1][0]

and replace last [0] by [4]

And nice example btw, i will include it into the archive, but i changed it a little(?)...

#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

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

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

Share this post


Link to post
Share on other sites

#9 ·  Posted

Updated first post:

CHANGELOG:

v1.1 [22.03.2008]

* Fixed: Incorrect ReDim when remove event from the array, it was causing UDF to crash script with error.

* Spell/Grammar corrections :)

* Added: An example of _BlockMouseClicksInput().


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

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

Share this post


Link to post
Share on other sites

#10 ·  Posted

Hi,

thanks for credit.

That is what I meant. (example)

Blocking the mouse is really helpful sometimes!

Great!

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

#11 ·  Posted

Maybe the problem is that the title says "_MoseSetOnEvent"

The title of the topic and and the first post have a misspelling.

Share this post


Link to post
Share on other sites

#12 ·  Posted

Great work :)

I'm gonna start playing with !!

Share this post


Link to post
Share on other sites

#14 ·  Posted

Hi,

I tried to play around with the following script.

The intention is to demonstrate right mouse click in a specific application, say UltraEdit.

It is very simple, if you right mouse click (down/up) when UltraEdit is active, then a tooltip will be displayed.

If you right mouse click in another Window, it will perform normal right mouse click.

If middle mouse button is clicked, the application will exit.

I have two questions

1. what is the best way to make this program stay in memory to track mouse clicks until it is terminated?

sleep(2147483647) is a bad way I suppose, but for testing purpose, it is ok

another way is

while 1

wend

2. this is really annoying me

After this program exits, left mouse click is not able to activate other Window

Only after I press Alt+Tab to switch to other Window, left mouse click starts to work normally

Any inputs will be appreciated :)

#include <MouseSetOnEvent_UDF.au3>

_MouseSetOnEvent($MOUSE_SECONDARYUP_EVENT, "RightMouseUp")
_MouseSetOnEvent($MOUSE_SECONDARYDOWN_EVENT, "RightMouseDown")
_MouseSetOnEvent($MOUSE_WHELLUP_EVENT , "MiddleMouseUp")

sleep(2147483647)

Func RightMouseUp()
  If WinActive("UltraEdit") Then
    ToolTip("Right Mouse up")
  Else
    MouseUp("Right")
  EndIf
EndFunc

Func RightMouseDown()
  If WinActive("UltraEdit") Then
    ToolTip("Right Mouse down")
  Else
    MouseDown("Right")
  EndIf
EndFunc

Func MiddleMouseUp()
  _MouseSetOnEvent($MOUSE_SECONDARYUP_EVENT);Enable mouse button back.
  _MouseSetOnEvent($MOUSE_SECONDARYDOWN_EVENT);Enable mouse button back.
  _MouseSetOnEvent($MOUSE_WHELLUP_EVENT);Enable mouse button back.
  exit
EndFunc

Share this post


Link to post
Share on other sites

#15 ·  Posted

First post updated:

v1.2 [05.04.2008]

* Added: [Optional] parameter $hTargetWnd, if set, the OnEvent function will be called only on $hTargetWnd window, otherwise will be standard Event processing.

Note: Can be a little(?) buggy when you mix different events :)


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

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

Share this post


Link to post
Share on other sites

#16 ·  Posted

what is the best way to make this program stay in memory to track mouse clicks until it is terminated?

sleep(2147483647) is a bad way I suppose

You can just set a loop:

While 1
   Sleep(10)
WEnd

:)


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

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

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

I know it's an older topic, but this is one of the few UDF's posted lately that I actually needed to use in a project of mine.

Awesome UDF :)

EDIT: I may have found a possible bug (Unless this is intended behavior)

Try this code in SciTe:

#include <MouseSetOnEvent_UDF.au3>

_MouseSetOnEvent(516, "BlowUp")
Sleep(5000)
_MouseSetOnEvent(516)
Func BlowUp()
    MsgBox(0, "Kaboom", "You all die")
EndFunc

Now press the right mouse button. You see the MsgBox. Now when you exit the MsgBox, the context menu appears as if you pressed the button twice. Is this intended?

Edited by KentonBomb

Share this post


Link to post
Share on other sites

#18 ·  Posted

Great udf!


[quote name='PsaltyDS' post='635433' date='Jan 27 2009, 07:04 AM']Larry is a mass murderer?! It's always the quiet, clean cut, bald guys... [/quote]

Share this post


Link to post
Share on other sites

#19 ·  Posted

damn, i really want to use your udf !!!

but am i the only one who has problems ? i have got the "MouseSetOnEvent_UDF.au3", i tried it with v 3.2.8.1 and 3.2.10.0 and the latest beta, but i do not have the following functions:

- DllCallbackRegister

- DllCallbackGetPtr

- DllCallbackFree

and so on. so please where can i find these ? i've been searching the forum for hours, but there seems to be a problem with lots of functions with similar names.

thx

j.


I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.Don't forget this IP: 213.251.145.96

Share this post


Link to post
Share on other sites

#20 ·  Posted

damn, i really want to use your udf !!!

but am i the only one who has problems ? i have got the "MouseSetOnEvent_UDF.au3", i tried it with v 3.2.8.1 and 3.2.10.0 and the latest beta, but i do not have the following functions:

- DllCallbackRegister

- DllCallbackGetPtr

- DllCallbackFree

and so on. so please where can i find these ? i've been searching the forum for hours, but there seems to be a problem with lots of functions with similar names.

thx

j.

It requires Beta.

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