Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

MouseOnEvent UDF!

Mouse Event Hook

  • Please log in to reply
155 replies to this topic

#41 MrCreatoR

MrCreatoR

    Must AutoIt!

  • MVPs
  • 3,251 posts

Posted 25 October 2008 - 07:53 PM

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

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

Posted Image AutoIt Russian CommunityPosted Image Projects: 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 ProgramPosted Image UDFs: 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 UDFPosted Image Examples: 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 DemoLike the examples/UDFs? Please rate the topic (up-right corner of the post header: Rating Posted Image)* === My topics === *

==========================================================Posted Image==========================================================

AutoIt is simple, subtle, elegant. © AutoIt Team








#42 Cloud22

Cloud22

    Seeker

  • New Members
  • 3 posts

Posted 26 October 2008 - 03:57 PM

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.
Plain Text         
#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


#43 MrCreatoR

MrCreatoR

    Must AutoIt!

  • MVPs
  • 3,251 posts

Posted 26 October 2008 - 06:12 PM

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.
Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

Posted Image AutoIt Russian CommunityPosted Image Projects: 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 ProgramPosted Image UDFs: 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 UDFPosted Image Examples: 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 DemoLike the examples/UDFs? Please rate the topic (up-right corner of the post header: Rating Posted Image)* === My topics === *

==========================================================Posted Image==========================================================

AutoIt is simple, subtle, elegant. © AutoIt Team


#44 Cloud22

Cloud22

    Seeker

  • New Members
  • 3 posts

Posted 26 October 2008 - 08:50 PM

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.

It does and it works with the keyboard hotkey. It just crashes if using the mouse hotkey.

#45 MrCreatoR

MrCreatoR

    Must AutoIt!

  • MVPs
  • 3,251 posts

Posted 26 October 2008 - 09:11 PM

Try like this:

AutoIt         
#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

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

Posted Image AutoIt Russian CommunityPosted Image Projects: 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 ProgramPosted Image UDFs: 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 UDFPosted Image Examples: 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 DemoLike the examples/UDFs? Please rate the topic (up-right corner of the post header: Rating Posted Image)* === My topics === *

==========================================================Posted Image==========================================================

AutoIt is simple, subtle, elegant. © AutoIt Team


#46 Reaper HGN

Reaper HGN

    Wayfarer

  • Active Members
  • Pip
  • 97 posts

Posted 27 October 2008 - 04:53 PM

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


#47 MrCreatoR

MrCreatoR

    Must AutoIt!

  • MVPs
  • 3,251 posts

Posted 27 October 2008 - 05:59 PM

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.
Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

Posted Image AutoIt Russian CommunityPosted Image Projects: 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 ProgramPosted Image UDFs: 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 UDFPosted Image Examples: 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 DemoLike the examples/UDFs? Please rate the topic (up-right corner of the post header: Rating Posted Image)* === My topics === *

==========================================================Posted Image==========================================================

AutoIt is simple, subtle, elegant. © AutoIt Team


#48 MrCreatoR

MrCreatoR

    Must AutoIt!

  • MVPs
  • 3,251 posts

Posted 27 October 2008 - 06:24 PM

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:

AutoIt         
#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).
Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

Posted Image AutoIt Russian CommunityPosted Image Projects: 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 ProgramPosted Image UDFs: 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 UDFPosted Image Examples: 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 DemoLike the examples/UDFs? Please rate the topic (up-right corner of the post header: Rating Posted Image)* === My topics === *

==========================================================Posted Image==========================================================

AutoIt is simple, subtle, elegant. © AutoIt Team


#49 Reaper HGN

Reaper HGN

    Wayfarer

  • Active Members
  • Pip
  • 97 posts

Posted 28 October 2008 - 09:29 AM

Ok, UDF updated!



@Reaper HGN
Here is an usage example of your script:

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

#50 therks

therks

    Witty quote

  • Active Members
  • PipPipPipPipPipPip
  • 2,168 posts

Posted 29 October 2008 - 12:35 PM

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!

#51 MrCreatoR

MrCreatoR

    Must AutoIt!

  • MVPs
  • 3,251 posts

Posted 29 October 2008 - 08:42 PM

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
Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

Posted Image AutoIt Russian CommunityPosted Image Projects: 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 ProgramPosted Image UDFs: 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 UDFPosted Image Examples: 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 DemoLike the examples/UDFs? Please rate the topic (up-right corner of the post header: Rating Posted Image)* === My topics === *

==========================================================Posted Image==========================================================

AutoIt is simple, subtle, elegant. © AutoIt Team


#52 myspacee

myspacee

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 667 posts

Posted 12 November 2008 - 10:00 AM

nice UDF,
simple usage and powerfull.

But can't use with mouse wheel up and down,
anyone can suggest me an UDF or example script to detect
mouse wheel up and down movments ?

thank you,

m.

#53 illya

illya

    Seeker

  • Active Members
  • 15 posts

Posted 11 December 2008 - 07:58 PM

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 :)

#54 Skizmata

Skizmata

    Prodigy

  • Active Members
  • PipPipPip
  • 169 posts

Posted 17 December 2008 - 02:32 AM

Great stuff! Thanks again MrCreator as allways great work!
AutoIt changed my life.

#55 fmen

fmen

    Adventurer

  • Active Members
  • PipPip
  • 137 posts

Posted 18 December 2008 - 12:25 AM

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, 18 December 2008 - 12:26 PM.


#56 MrCreatoR

MrCreatoR

    Must AutoIt!

  • MVPs
  • 3,251 posts

Posted 28 January 2009 - 11:54 PM

[quote name='KentonBomb' post='503165' date='Apr 8 2008, 12:05 AM']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ƒo݊÷ ØÚ0¦·¬²Ø^®(!¶j.±æî¶Ú'b‹¬yëaxË ŒM£ !z|¨¹ìb¶Ø^2È£ayÊ'µìm™éîjš^j»²'ò¢êkzËvØ^nëm¢{p‰Çˆ²Øb²)ízw^wú®¢×’¢ºò~Šåj׫z™rç^¢·lÓ~Œ9D„H@Ž40`3–4ED5;(¶”¥ëޞج²Ø¥–—«~ŠæyܨºÈhºW[–‡$¶”¥©l¡«­¢+؍¥¹±Õ‘”€™±Ðí5½Õ͕M•Ñ=¹ٕ¹Ñ}U¹…Ô̙Ðì()}5½Õ͕M•Ñ=¹ٕ¹Ð ÔÄØ°€™ÅÕ½Ðí ±½ÝUÀ™ÅÕ½Ðì¤)}5½Õ͕M•Ñ=¹ٕ¹Ð ÔÄÜ°€™ÅÕ½Ðí  ±½ÝUÀ™ÅÕ½Ðì¤()M±••À ÔÀÀÀ¤()}5½Õ͕M•Ñ=¹ٕ¹Ð ÔÄؤ)}5½Õ͕M•Ñ=¹ٕ¹Ð ÔÄܤ()Õ¹Œ ±½ÝUÀ ¤($í5͝   ½à À°€™ÅÕ½Ðí-…‰½½´™ÅÕ½Ð찀™ÅÕ½Ðíe½Ô…±°‘¥”™ÅÕ½Ðì¤(%Q½½±Q¥À ™ÅÕ½Ðíe½Ô…±°‘¥”™ÅÕ½Ðì¤)¹‘Õ¹

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

Posted Image AutoIt Russian CommunityPosted Image Projects: 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 ProgramPosted Image UDFs: 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 UDFPosted Image Examples: 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 DemoLike the examples/UDFs? Please rate the topic (up-right corner of the post header: Rating Posted Image)* === My topics === *

==========================================================Posted Image==========================================================

AutoIt is simple, subtle, elegant. © AutoIt Team


#57 MrCreatoR

MrCreatoR

    Must AutoIt!

  • MVPs
  • 3,251 posts

Posted 29 January 2009 - 12:01 AM

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

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

Posted Image AutoIt Russian CommunityPosted Image Projects: 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 ProgramPosted Image UDFs: 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 UDFPosted Image Examples: 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 DemoLike the examples/UDFs? Please rate the topic (up-right corner of the post header: Rating Posted Image)* === My topics === *

==========================================================Posted Image==========================================================

AutoIt is simple, subtle, elegant. © AutoIt Team


#58 illya

illya

    Seeker

  • Active Members
  • 15 posts

Posted 03 February 2009 - 07:24 PM

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


#59 FireFox

FireFox

    It slips through our fingers, like a fist full of sand.

  • MVPs
  • 5,376 posts

Posted 03 February 2009 - 09:09 PM

@illya
#Include <IsPressed_UDF.au3> While 1 If _IsPressed('01') Then ;something EndIf WEnd


Cheers, FireFox.

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.

Hardware : Intel® Core™ i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

Updated 07 November, 2013 - If you find dead links please send me a PM, do not post in the topics !


#60 Ascend4nt

Ascend4nt

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 1,359 posts

Posted 20 February 2009 - 12:15 AM

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





Also tagged with one or more of these keywords: Mouse, Event, Hook

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users