Jump to content

MouseOnEvent UDF!


MrCreatoR
 Share

Recommended Posts

So I am trying to code when the mouse wheel is clicked, it launches itunes play/pause command. I got it to work by hotkey, but not by mouse. It seems not to be able to find itunes app when the mouse hotkey tries to use it, but the keyboard works fine.

iTunesUDF.au3 (68) : ==> The requested action with this object has failed.:

$iTunesApp.PlayPause

$iTunesApp.PlayPause^ ERROR

CODE
#include <MouseSetOnEvent_UDF.au3>

#include <iTunesUDF.au3>

_iTunes_Start()

HotKeySet("{Esc}", "quit")

HotKeySet("{MEDIA_PLAY_PAUSE}", "PausePlay")

HotKeySet("{MEDIA_NEXT}","trackNext")

_MouseSetOnEvent($MOUSE_SECONDARYUP_EVENT , "PausePlay")

while 1

sleep (1000)

WEnd

Func PausePlay()

_iTunes_Play_Pause()

EndFunc

Func trackNext()

_iTunes_Next()

EndFunc

Func quit()

_iTunes_Quit()

_MouseSetOnEvent($MOUSE_WHELLDOWN_EVENT)

Exit(0)

EndFunc

Look at the events variable in the first post, SECONDARYUP is not a Whell button :P

This one works:

#include <MouseSetOnEvent_UDF.au3>

$iPaused = False

_MouseSetOnEvent($MOUSE_WHELLDOWN_EVENT, "PausePlay")

Sleep(5000)

_Quit()

Func Quit()
     _MouseSetOnEvent($MOUSE_WHELLDOWN_EVENT)
     Exit
EndFunc

Func PausePlay()
    $iPaused = Not $iPaused
    
    ConsoleWrite("Paused: " & $iPaused & @CRLF)
EndFunc

 

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

Look at the events variable in the first post, SECONDARYUP is not a Whell button :P

This one works:

#include <MouseSetOnEvent_UDF.au3>

$iPaused = False

_MouseSetOnEvent($MOUSE_WHELLDOWN_EVENT, "PausePlay")

Sleep(5000)

_Quit()

Func Quit()
     _MouseSetOnEvent($MOUSE_WHELLDOWN_EVENT)
     Exit
EndFunc

Func PausePlay()
    $iPaused = Not $iPaused
    
    ConsoleWrite("Paused: " & $iPaused & @CRLF)
EndFunc
It still fails.

Just press shift+alt+d to pause/play it, but it you press whelldown, then it crashes.

#include <MouseSetOnEvent_UDF.au3>
#include <iTunesUDF.au3>


_iTunes_Start()
HotKeySet("{Esc}", "quit")
HotKeySet("+!d", "PausePlay")
HotKeySet("{MEDIA_PLAY_PAUSE}", "PausePlay")
HotKeySet("{MEDIA_NEXT}","trackNext")
_MouseSetOnEvent( $MOUSE_WHELLDOWN_EVENT , "PausePlay")

while 1
    sleep (1000)
WEnd

Func PausePlay()
    $iTunesApp.PlayPause
EndFunc

Func trackNext()
    _iTunes_Next()
EndFunc

Func quit()
    _iTunes_Quit()
    _MouseSetOnEvent($MOUSE_WHELLDOWN_EVENT)
    Exit
EndFunc
Link to comment
Share on other sites

It's crashed on $iTunesApp.PlayPause? then i can't help you sorry, i don't use iTunes, be sure that this object supports PlayPause action.

 

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

Try like this:

#include <MouseSetOnEvent_UDF.au3>
#include <iTunesUDF.au3>

Global $iPlayPause = False

_iTunes_Start()

HotKeySet("{Esc}", "quit")
HotKeySet("+!d", "PausePlay")
HotKeySet("{MEDIA_PLAY_PAUSE}", "PausePlay")
HotKeySet("{MEDIA_NEXT}", "trackNext")

_MouseSetOnEvent($MOUSE_WHELLDOWN_EVENT, "PausePlay")

While 1
    Sleep(10)
    
    If $iPlayPause Then
        $iPlayPause = False
        $iTunesApp.PlayPause
    EndIf
WEnd

Func PausePlay()
    $iPlayPause = True
EndFunc

Func trackNext()
    _iTunes_Next()
EndFunc

Func quit()
    _iTunes_Quit()
    _MouseSetOnEvent($MOUSE_WHELLDOWN_EVENT)
    
    Exit
EndFunc

 

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

Awesome UDF. I was trying to see if I could implement this in some of my scripts (which run in onEvent mode). I found that if I targeted the window for the UDF (which seems like the safest thing to do), I cannot click any of the window event buttons such as minimize, maximize or close. Did I miss something in the thread that addressed this or is there something special I have to do?

Here is the test code I am working with to see how the UDF works.

#include <MouseSetOnEvent_UDF.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Opt("GUIOnEventMode", 1)

$Form1 = GUICreate("Form1", 431, 37, 193, 125)
$Label1 = GUICtrlCreateLabel("Label1", 8, 8, 452, 22)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
GUISetState(@SW_SHOW)


GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
_MouseSetOnEvent($MOUSE_PRIMARYDOWN_EVENT, "_Downleft", "", "", $Form1)
_MouseSetOnEvent($MOUSE_PRIMARYUP_EVENT, "_Upleft", "", "", $Form1)

While 1
    Sleep(100)
WEnd

Func _Exit()
    Exit
EndFunc

Func _Downleft()
    GUICtrlSetData($Label1,"Mouse Left Down")
EndFunc

Func _Upleft()
    GUICtrlSetData($Label1,"Mouse Left Up")
EndFunc
Link to comment
Share on other sites

Awesome UDF. I was trying to see if I could implement this in some of my scripts (which run in onEvent mode). I found that if I targeted the window for the UDF (which seems like the safest thing to do), I cannot click any of the window event buttons such as minimize, maximize or close. Did I miss something in the thread that addressed this or is there something special I have to do?

....

Thanks :P.

About the clicking ability, for now the default processing was blocked (i.e: the system can not recieve mouse click events, and only the user function called).

I changed a little the UDF to handle this blocking process by extra parameter. Or, if you set that parameter to -1, you can just Return 1 (to block) or 0 (not block) from the event function.

I will post the changed UDF later.

 

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

Ok, UDF updated!

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

@Reaper HGN

Here is an usage example of your script:

#include <MouseSetOnEvent_UDF.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Opt("GUIOnEventMode", 1)

$Form1 = GUICreate("Form1", 431, 37, 193, 125)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")

$Label1 = GUICtrlCreateLabel("Label1", 8, 8, 452, 22)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")

GUISetState(@SW_SHOW)

_MouseSetOnEvent($MOUSE_PRIMARYDOWN_EVENT, "_Downleft", "", "", $Form1, 0)
_MouseSetOnEvent($MOUSE_PRIMARYUP_EVENT, "_Upleft", "", "", $Form1, 0)

While 1
    Sleep(10)
WEnd

Func _Exit()
    Exit
EndFunc

Func _Downleft()
    GUICtrlSetData($Label1, "Mouse Left Down")
EndFunc

Func _Upleft()
    GUICtrlSetData($Label1, "Mouse Left Up")
EndFunc

P.S

I placed this example (a little changed) in the archive, i hope you don't mind :P (check it out too, you can grab the window and drag it without holding the mouse button, press ENTER to release, or ESC to cancel).

 

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

Ok, UDF updated!

@Reaper HGN

Here is an usage example of your script:

#include <MouseSetOnEvent_UDF.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Opt("GUIOnEventMode", 1)

$Form1 = GUICreate("Form1", 431, 37, 193, 125)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")

$Label1 = GUICtrlCreateLabel("Label1", 8, 8, 452, 22)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")

GUISetState(@SW_SHOW)

_MouseSetOnEvent($MOUSE_PRIMARYDOWN_EVENT, "_Downleft", "", "", $Form1, 0)
_MouseSetOnEvent($MOUSE_PRIMARYUP_EVENT, "_Upleft", "", "", $Form1, 0)

While 1
    Sleep(10)
WEnd

Func _Exit()
    Exit
EndFunc

Func _Downleft()
    GUICtrlSetData($Label1, "Mouse Left Down")
EndFunc

Func _Upleft()
    GUICtrlSetData($Label1, "Mouse Left Up")
EndFunc

P.S

I placed this example (a little changed) in the archive, i hope you don't mind :P (check it out too, you can grab the window and drag it without holding the mouse button, press ENTER to release, or ESC to cancel).

Thanks for the response. I dont mind you using the example at all, such as it is :( I tested it with the new UDF and found that in fact the default processing does occur. On the system I tested it on, though, it took upwards of three seconds to complete the action (ie, it was like the computer froze for that time frame, then closed or minimized the window). I will try it on another system tomorrow (er today) and see if it acts the same way or not.

Thanks again. now all I need to do is figure out how to determine a WHEELSCROLLUP event from a WHEELSCROLLDOWN event.

Link to comment
Share on other sites

When I first found this UDF I thought it was pretty cool but I have a couple comments/suggestions, I hope you don't mind MrCreator.

One, just a little nitpick, is you spelled wheel as "WHELL". I guess English is not your first language, correct? So I assumed you just didn't realize, but if this is intentional then by all means leave it. :P

Two, I would rename the OnAutoItExit function to something like _Mouse_Events_Cleanup just to avoid conflicts, maybe set it manually with Opt('OnExitFunc', '_Mouse_Events_Cleanup') ? That one is mostly preference I guess, and obviously can be altered in the UDF (I did in mine), but if it was already set to something else it would make your UDF that much easier to drop-in. Maybe eventually we'll get a standard built in Exit event stack implemented, I think Valik mentioned wanting something like that done before...

Third, as the last poster just mentioned, is there anyway we can detect direction for the wheel scroll event?

Otherwise the UDF is great, thanks very much for writing it, and writing it well!

Link to comment
Share on other sites

When I first found this UDF I thought it was pretty cool but I have a couple comments/suggestions, I hope you don't mind MrCreator.

One, just a little nitpick, is you spelled wheel as "WHELL". I guess English is not your first language, correct? So I assumed you just didn't realize, but if this is intentional then by all means leave it. :P

Two, I would rename the OnAutoItExit function to something like _Mouse_Events_Cleanup just to avoid conflicts, maybe set it manually with Opt('OnExitFunc', '_Mouse_Events_Cleanup') ? That one is mostly preference I guess, and obviously can be altered in the UDF (I did in mine), but if it was already set to something else it would make your UDF that much easier to drop-in. Maybe eventually we'll get a standard built in Exit event stack implemented, I think Valik mentioned wanting something like that done before...

Third, as the last poster just mentioned, is there anyway we can detect direction for the wheel scroll event?

Otherwise the UDF is great, thanks very much for writing it, and writing it well!

Hi Rob,

About the first issue, yes, i just misspelled the word «Wheel», but i think it's more a typo rather then spell error :P (sometimes you write it once, and the rest is the copies of it -> Drag the selection with CTRL down :( ), i know that it's Wheel not Whell :idea: - And yes, English is not my main language, it's even not the second language (Russian main, Hebrew is second).

About the second issue, it is not problem to rename the function and set it via Opt, but in any case user can set Opt after the UDF include part (i always do that), and then the UDF will not release the callback properly (and i am not sure about this issue, do we really have to release stuff before script exits? Afaik, AutoIt engine builded in the way that allows to release automatically all handles before it exits).

I personally always open the UDF, and check what it does, what i should take in account when i include the UDF. But yes, i realize that there is a beginners that doesn't do that and they doesn't know how, but i think the best what i (and other UDF builders that have this func in they UDFs) can do in such situation, is to make a «Note» about the function OnAutoItExit(), and from there is the user's responsibility to make it workable and take it into account.

About the wheel up/down recognition, i really don't know how to get those events (and i really want it too :)), and btw, this issue discussed on the previous page :P

 

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

  • 2 weeks later...
  • 5 weeks later...

First: MrCreatoR I love this piece of code, thank you for creating it :)

2nd: Is there a way to seperate mousebutton 4 and 5 (the ones on the left side of the mouse, 4 makes you go forward in explorer and 5 makes you go back) because that would really kick ass :)

Link to comment
Share on other sites

Great UDF!!

I can now disable that annoying XP "autoscroll" feature in applications like IE?

This is the feature that is triggered by a middle click and causes the page to automatically and erratically scroll up or down. Another middle click is needed to turn off this horrible unneeded feature.

God what an annoyance!

#include <MouseSetOnEvent_UDF.au3>

While 1
    _MouseSetOnEvent($MOUSE_WHELLDOWN_EVENT, "DummyFunc")
    _MouseSetOnEvent($MOUSE_WHELLUP_EVENT)
sleep(10)
WEnd


Func DummyFunc()
      Sleep(1)
EndFunc
Edited by fmen
Link to comment
Share on other sites

  • 1 month later...

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")
EndFuncoÝ÷ ØÚ0¦·¬²Ø^®(!¶j.±æî¶Ú'b¬yëaxË M£!z|¨¹ìb¶Ø^2È£ayÊ'µìméîj^j»²'ò¢êkzËvØ^nëm¢{pDzØb²)ízw^wú®¢×¢ºò~åj׫zrç^¢·lÓ~9DH@40`34ED5;(¶¥ëÞج²Ø¥«~æyܨºÈhºW[$¶¥©l¡«­¢+Ø¥¹±Õ±Ðí5½ÕÍMÑ=¹Ù¹Ñ}U¹ÔÌÐì()}5½ÕÍMÑ=¹Ù¹Ð ÔÄØ°ÅÕ½Ðí   ±½ÝUÀÅÕ½Ðì¤)}5½ÕÍMÑ=¹Ù¹Ð ÔÄÜ°ÅÕ½Ðí   ±½ÝUÀÅÕ½Ðì¤()M±À ÔÀÀÀ¤()}5½ÕÍMÑ=¹Ù¹Ð ÔÄؤ)}5½ÕÍMÑ=¹Ù¹Ð ÔÄܤ()Õ¹  ±½ÝUÀ ¤($í5Í ½à À°ÅÕ½Ðí-½½´ÅÕ½Ðì°ÅÕ½Ðíe½Ô±°¥ÅÕ½Ðì¤(%Q½½±Q¥À ÅÕ½Ðíe½Ô±°¥ÅÕ½Ðì¤)¹Õ¹

 

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

Great UDF!!

I can now disable that annoying XP "autoscroll" feature in applications like IE?

This is the feature that is triggered by a middle click and causes the page to automatically and erratically scroll up or down. Another middle click is needed to turn off this horrible unneeded feature.

God what an annoyance!

#include <MouseSetOnEvent_UDF.au3>

While 1
    _MouseSetOnEvent($MOUSE_WHELLDOWN_EVENT, "DummyFunc")
    _MouseSetOnEvent($MOUSE_WHELLUP_EVENT)
sleep(10)
WEnd


Func DummyFunc()
      Sleep(1)
EndFunc
Not a good idea, don't have to set it in loop:

#include <MouseSetOnEvent_UDF.au3>

HotKeySet("^q", "_Quit")

_MouseSetOnEvent($MOUSE_WHELLDOWN_EVENT, "DummyFunc")

While 1
    Sleep(10)
WEnd

Func _Quit()
    _MouseSetOnEvent($MOUSE_WHELLUP_EVENT)
    Exit
EndFunc

Func DummyFunc()
EndFunc

 

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

Is there a way to just make it listen for mouseclicks, and not undo them?

(I only want to make something happen when I click down my button. But as it is now it also "blocks" my click)

my code:

CODE

_MouseSetOnEvent($MOUSE_PRIMARYUP_EVENT, "MousePrimaryUp_Event")

Func MousePrimaryUp_Event()

Send("^!r")

EndFunc

Link to comment
Share on other sites

  • 3 weeks later...

MrCreatoR, I forgot to send you thanks for writing this UDF. It has helped me greatly :)

A few things you can add to the mouse hook portion:

1st, the MSLLHOOKSTRUCT information:

Note: the wheel delta (when relevant) will be a negative value when scrolled 'down' and positive when scrolled 'up'. For *most* mice, this will be either -120 or 120, but some, like my MX Revolution with it's 'flywheel', will return greater or lesser values. Not sure how to translate those other values (divide by 120? who knows..), but I've included at least how to obtain the value here.

; a pointer to the MSLLHOOKSTRUCT is passed in $lParam, which contains valuable info
Local $stMSLLHookStruct=DllStructCreate("int;int;dword;dword;dword;ptr",$lParam)
Local $iMouseX=DllStructGetData($stMSLLHookStruct,1),$iMouseY=DllStructGetData($stMSLLHookStruct,2)

; Wheel delta is only relevant when mouse event = WM_MOUSEWHEEL (522)
Local $iWheelDelta=BitShift(DllStructGetData($stMSLLHookStruct,3),16)

2nd, when $nCode<0, according to MSDN, the callback function should call the next hook procedure and return with that call's return code. I'm not certain if you would want to block the next function in the callback chain, but it doesn't seem to make a difference in my testing, since regular system processing doesn't continue until you return with a 0.

Anyway, thanks again for the great UDF.

Ascend4nt

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