MrCreatoR

MouseOnEvent UDF!

195 posts in this topic

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

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



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

Share this post


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


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

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.

Share this post


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

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

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

Share this post


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


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

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


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

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.

Share this post


Link to post
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!

Share this post


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


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

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Great stuff! Thanks again MrCreator as allways great work!


AutoIt changed my life.

Share this post


Link to post
Share on other sites

#55 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

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½Ô±°¥ÅÕ½Ðì¤)¹Õ¹

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

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

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

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

Share this post


Link to post
Share on other sites

@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(R) Core(TM) 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

 

Share this post


Link to post
Share on other sites

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

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

  • Similar Content

    • fishbones
      Help me with mouse clicks
      By fishbones
      Hi guys!
      I'm really new to AutoIT, and I have little experience with scripting or any sort of programming. But I'm trying to learn!
      Right now, what I'm trying to do is make a quick script that repeats a few functions while a key is held down. I want to see if I can make a quick-burst script that might work in Fallout 4 with machine guns
       
      #include <Misc.au3> $dll = DllOpen("user32.dll") While 1 Sleep(100) If _IsPressed("01", $dll) Then MouseDown("left") Sleep(320) MouseUp("left") Sleep(25) EndIf WEnd DllClose($dll) Right now, when I hold down my left mouse button, it just repeats the script once - then I have to release and hold again to enable it again. Is it possible to to start it from the top and basically just repeats itself while I'm holding down my mouse button?

      In advance, thank you!
    • algiuxas
      GUI Show/Hide Cursor [SOLVED]
      By algiuxas
      Hello,
      I want that when mouse cursor is in GUI, cursor would hide, and when cursor is outside GUI it would appear again.

      (Sorry for my bad English)
    • Grosminet
      WHY a while loop speedup when the mouse is moving
      By Grosminet
      Searching inside the forum, I don't succeed to get any explanation about a strange (for me !) phenomena:
      Using AutoIt, I have coded a "cortex of neurons Simulator" for which I handle several neurons activity (Action Potential and Postsynaptic Potential) which take a long time, about 20 ms per neuron to be processed. This is why I need a global loop running about 1s for a global cortex of 50 neurons.
      But when I move the mouse (in any direction, like rotating above the GUI) the speed of the loop increase significantly : around x8 times more ... !
      This happens only if the GUI has the focus. I did a check with the "Windows Task Manager" where I can see the CPU usage changing every time the mouse is moving (growing from 3% to 15%).
      I believe to remember some lecture about the influence of the user events regarding the "Application" capability to anticipate user actions by changing it's rate of pooling events, but I'm not sure it was in an AutoIt forum, or maybe it was in an other "developer forum" (like "Code Project", "Stackoverflow" , or ...?
      Could somebody help me to understand this behaviour ?
      If possible, is there a programmatic method to manage the speed of a simple "For, Next" loop ? I try to change the Application priority (setting to level 4 with "ProcessSetPriority"), but this seems not very efficient ....
      Thanks, Alain.

      FYI: I'm using :
      Autoit 3.3.14.2 Windows 7 Home Premium Service Pack 1 Computer ASUS N56V Screen resolution: 1920x1080 (recommended) Theme :Windows Classic
    • Jefrey
      TCPServer UDF (multi client, event-based, able to bind console app to socket)
      By Jefrey
      Hi guys/girls!
      I'm gonna share this UDF I made today.
      It allows you to easily create TCP servers and set actions depending on three events: OnConnect, OnDisconnect and OnReceive.
      It is also multi client (you can set the clients limit) and you can also bind a Console-based executable to the socket (similar to -e parameter in NetCat). This feature is useful if you want to use some Console UDF to create your TCP server and don't want to mix it with the TCP functions. Also, as it runs on background just firing events, it won't pause your script while listening/receiving, so you can do anything else (stop and restart the server, allow the user to click buttons or just wait on an infinite loop) that your callbacks will be called once the event is fired.
      It's also very easy to use. See this examples:
      Example #1: A basic server
      By running this (then connecting to the server using Netcat), you will receive a message box telling you when some user connects or disconnects (the socket ID and his IP address is passed as parameter to your callback function) and also when the user sends something over the TCP socket (the data sent is passed as parameter).
      #cs Download netcat at https://eternallybored.org/misc/netcat/ Execute this script Run in CMD: nc -vv 127.0.0.1 8081 #ce #include "TCPServer.au3" ; First we set the callback functions for the three events (none of them is mandatory) _TCPServer_OnConnect("connected") _TCPServer_OnDisconnect("disconnect") _TCPServer_OnReceive("received") ; And some parameters _TCPServer_DebugMode(True) _TCPServer_SetMaxClients(10) ; Finally we start the server at port 8081 at any interface _TCPServer_Start(8081) Func connected($iSocket, $sIP) MsgBox(0, "Client connected", "Client " & $sIP & " connected!") _TCPServer_Broadcast('new client connected guys', $iSocket) _TCPServer_Send($iSocket, "Hey! Write something ;)" & @CRLF) _TCPServer_SetParam($iSocket, "will write") EndFunc ;==>connected Func disconnect($iSocket, $sIP) MsgBox(0, "Client disconnected", "Client " & $sIP & " disconnected from socket " & $iSocket) EndFunc ;==>disconnect Func received($iSocket, $sIP, $sData, $sPar) MsgBox(0, "Data received from " & $sIP, $sData & @CRLF & "Parameter: " & $sPar) _TCPServer_Send($iSocket, "You wrote: " & $sData) _TCPServer_SetParam($iSocket, 'will write again') EndFunc ;==>received While 1 Sleep(100) WEnd Example #2: A basic HTTP server (just one page, as it is just an example)
      In this example, we run this code and point our browser to the address mentioned on the comments. A basic "It works!" page is show.
      #cs Run this script Point your browser to http://localhost:8081/ #ce #include "TCPServer.au3" _TCPServer_OnReceive("received") _TCPServer_DebugMode(True) _TCPServer_SetMaxClients(10) _TCPServer_Start(8081) Func received($iSocket, $sIP, $sData, $sParam) _TCPServer_Send($iSocket, "HTTP/1.0 200 OK" & @CRLF & _ "Content-Type: text/html" & @CRLF & @CRLF & _ "<h1>It works!</h1>" & @CRLF & _ "<p>This is the default web page for this server.</p>" & @CRLF & _ "<p>However this server is just a 26-lines example.</p>") _TCPServer_Close($iSocket) EndFunc ;==>received While 1 Sleep(100) WEnd Example #3: A telnet-like server (Command Prompt bound to the socket after password requesting)
      By running this example and connecting with Netcat, we will be asked for a password, which is 12345 as we set on the script. If the password is correct, we will see the Command Prompt live-updated (try running a ping to some server, for example).
      #cs Download netcat at https://eternallybored.org/misc/netcat/ Execute this script Run in CMD: nc -vv 127.0.0.1 8081 #ce #include "TCPServer.au3" Global $sPassword = "12345" ; input server password here _TCPServer_OnConnect("connected") _TCPServer_OnDisconnect("disconnect") _TCPServer_OnReceive("received") _TCPServer_DebugMode(True) _TCPServer_SetMaxClients(10) _TCPServer_Start(8081) Func connected($iSocket, $sIP) _TCPServer_Send($iSocket, "Welcome! Please input password: ") _TCPServer_SetParam($iSocket, 'login') EndFunc ;==>connected Func disconnect($iSocket, $sIP) MsgBox(0, "Client disconnected", "Client " & $sIP & " disconnected from socket " & $iSocket) EndFunc ;==>disconnect Func received($iSocket, $sIP, $sData, $sParam) If $sParam = "login" Then If $sData <> $sPassword Then _TCPServer_Send($iSocket, "Wrong password. Try again: ") Return Else _TCPServer_SetParam($iSocket, 'command') _TCPServer_BindAppToSocket($iSocket, 'cmd.exe') EndIf ElseIf $sParam = "command" Then _TCPServer_SendToBound($iSocket, $sData) EndIf EndFunc ;==>received While 1 Sleep(100) WEnd The limit is your imagination? Well, no sure. We have this limit:
      You can't create more than one server with this UDF in the same script. However, you can pause and resume (read 'stop and start again') your server at any time in your script, without having to reset the server settings. And of course you can have many clients (or just one, it's your choice!) in the same server. Or run multiple instances. Functions list:
      _TCPServer_Start
      _TCPServer_Stop
      _TCPServer_Close
      _TCPServer_Send
      _TCPServer_Broadcast
      _TCPServer_SetParam
      _TCPServer_BindAppToSocket
      _TCPServer_SendToBound
      _TCPServer_UnBindAppToSocket
      _TCPServer_GetMaxClients
      _TCPServer_IsServerActive
      _TCPServer_ListClients
      _TCPServer_OnConnect
      _TCPServer_OnDisconnect
      _TCPServer_OnReceive
      _TCPServer_SetMaxClients
      _TCPServer_DebugMode
      _TCPServer_AutoTrim
      _TCPServer_SocketToIP
      _TCPServer_SocketToConnID
      _TCPServer_ConnIDToSocket
       
      Help file and more examples included!
      Latest version: 1.0.0.1
      Download: TCPServer UDF.rar
      Changelog
      1.0 - First release - 18/04/2015 1.0.0.1 - Bug fix __TCPServer_Accept internal function / help file recompiled - 26/04/2015 Perhaps you will need to uncompress the file first, so the help file will work.
      Fork this on Github: http://github.com/jesobreira/TCPServerUDF
      TCPServer UDF.rar
       
    • TheAutomator
      CUI console mouseevent
      By TheAutomator
      Hi everyone 
      Can someone guide me to the right direction with this question?
      I need a simple example for getting the mouse coordinates and other input events (using api calls, not mousegetpos) on a console window (return the x and y cell)
      https://msdn.microsoft.com/en-us/library/windows/desktop/ms684239(v=vs.85).aspx
      UDF link where I get the code from:
      https://github.com/MattDiesel/au3-console/blob/master/Console.au3
      A c++ example that does exactly what i'm looking for:
      https://msdn.microsoft.com/en-us/library/windows/desktop/ms685035(v=vs.85).aspx
       
      The code in the attachments helps a lot but I don't quite understand it,
      what code of it is necessary and is there a way more 'simple/less code' way to do this (like the c++ example)
       
      Thanks,
      TheAutomator
       
      test.au3