Jump to content

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

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.


 

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

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

 

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

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.


 

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

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


 

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

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


 

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

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

 

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

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

 

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

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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By CarlD
      Update: Download the latest version here.
      As my first stab at GUI scripting, I'm trying to write a simple graphical interface for Grep for Windows. I have a basic GUI, but I'm stuck on one point and nothing I've tried so far works. The sticking point is that while the Tab key works to move focus from one input control to the next, clicking the mouse on any but the first input does nothing. This seems like a basic feature of GUI functionality that should work out of the box (like Tab), but clearly I'm missing something. I tried (among many other things) Melba23's technique in the post below, but this doesn't do what I'm after -- getting the left click to set the insertion point for user input. Would greatly appreciate a pointer or two. 😉
      Here's my code so far:
      ; Grep for Windows -- GUI [CLD] #include <AutoItConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> Opt("WinTitleMatchMode", -2) #cs FileInstall("X:\nix\search1.ico", @TempDir & "\search1.ico") FileInstall("X:\nix\grep.exe", @TempDir & "\grep.exe") FileInstall("X:\nix\sed.exe", @TempDir & "\sed.exe") FileInstall("X:\nix\libiconv2.dll", @TempDir & "\libiconv2.dll") FileInstall("X:\nix\libintl3.dll", @TempDir & "\libintl3.dll") FileInstall("X:\nix\pcre3.dll", @TempDir & "\pcre3.dll") FileInstall("X:\nix\regex2.dll", @TempDir & "\regex2.dll") #ce ; $sDefFs = @ScriptDir & "\.txt" $sOut = "" $iX = 20 $iY = 20 $hgGGrep = GUICreate("Grep for Windows: Simple TeXT search", 600, 600) GUISetState(@SW_SHOW, $hgGGrep) ; Obtain value of control: GUICtrlRead() ; left, top, width, height ; $iX, $iY, $iX + n, $iY + m ; $hgIco = GUICtrlCreateIcon(@ScriptDir & "\search1.ico", $iX, $iY, 10) $hgGL0 = GUICtrlCreateLabel("Enter a string or regular expression" & @CRLF & "(space between words means ""OR"")", $iX + 50, $iY, 250, 30) $hgSch = GUICtrlCreateInput("", $iX + 50, $iY + 40, 325, 20, $GUI_SS_DEFAULT_INPUT, -1) $hgXyZ = GUICtrlCreateCheckbox("cAsE-sEnSiTiVe", $iX + 50, $iY + 65, -1, -1) $hgExe = GUICtrlCreateButton("Search", 400, $iY + 40, -1, -1) $hgFL1 = GUICtrlCreateLabel("Filespec", $iX + 50, $iY + 100, 250, 20) $hgFs1 = GUICtrlCreateInput("d:\path\*.txt", $iX + 110, $iY + 100, 250, 20, $GUI_SS_DEFAULT_INPUT, -1) $hgFL2 = GUICtrlCreateLabel("Filespec", $iX + 50, $iY + 120, 250, 20) $hgFs2 = GUICtrlCreateInput("", $iX + 110, $iY + 120, 250, 20, $GUI_SS_DEFAULT_INPUT, -1) $hgFL3 = GUICtrlCreateLabel("Filespec", $iX + 50, $iY + 140, 250, 20) $hgFs3 = GUICtrlCreateInput("", $iX + 110, $iY + 140, 250, 20, $GUI_SS_DEFAULT_INPUT,-1) $hgOut = GUICtrlCreateEdit($sOut, 25, 190, 550, 400, $ES_LEFT, -1) GUICtrlSetState($hgSch, $GUI_FOCUS) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd ; #cs _WinAPI_SetFocus(ControlGetHandle("Grep for Windows", "", $hgSch)) _WinAPI_SetFocus(ControlGetHandle("Grep for Windows", "", $hgFs1)) _WinAPI_SetFocus(ControlGetHandle("Grep for Windows", "", $hgFs2)) _WinAPI_SetFocus(ControlGetHandle("Grep for Windows", "", $hgFs3)) #ce Thanks in advance.
    • By Chimp
      If I run a process using the run() statement and setting the proper  STDIO redirection flags, I can access and manage the I/O streams of that process.
      Is there a way to hook to the same streams of a process that is already running?
      Thanks for any tip
    • By WoodGrain
      Hi guys,
       
      I've written a script that will move my mouse to a location on the screen whenever my remote access software becomes active, the problem I have is that as soon as the remote access software becomes active it appears to capture the mouse and keyboard so nothing happens when I use MouseMove().
       
      Is there any way around this?
       
      Thanks!
    • By badcoder123
      Hey, all.  
      I've been looking for a way to change cursor colour but not the cursor itself. I've been looking for a couple hours now and can't find anything.  I also don't even know where to start, if anyone has any tips or examples please comment them.
      Thanks
    • By Bilgus
      Recently a user asked given two keyboards how to determine which keyboard was pressed this is the start of such functionality
      I was already given permission to post this example by a moderator before I bothered
      ;Bilgus 2018 ;Determine which keyboard was pressed #include <Array.au3> #include <WinAPISys.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global Const $HWND_MESSAGE = (-3) ;create a message-only window when set as Parent ;RAWINPUTDEVICE Constants Global Const $HID_USAGE_PAGE_GENERIC = 0x1 Global Const $HID_USAGE_GENERIC_KEYBOARD = 0x6 Global $ghSelectedDevice Global $gaKeyboards = EnumRawKeyboards("\HID") If IsArray($gaKeyboards) And $gaKeyboards[0][0] >= 1 Then $ghSelectedDevice = $gaKeyboards[1][0] ; hard coded change to suit _ArrayDisplay($gaKeyboards, '_WinAPI_EnumRawInputDevices', "", 0, Default, "Handle|Type|VID|Keys") ;Not Needed... Global $hTarget = GUICreate("main", 10, 10, Default, Default, Default, Default, $HWND_MESSAGE) ;Dummy window to recieve messages Register_RawInput($HID_USAGE_PAGE_GENERIC, $HID_USAGE_GENERIC_KEYBOARD, $RIDEV_INPUTSINK, $hTarget) ;$RIDEV_INPUTSINK recieves input when not foreground ; Register WM_INPUT message GUIRegisterMsg($WM_INPUT, 'WM_INPUT') HotKeySet("{ESC}", _Exit) While 1 Sleep(1000) WEnd Func Device_Pressed() ConsoleWrite("Device Pressed" & @CRLF) EndFunc ;==>Device_Pressed Func _Exit() Exit EndFunc ;==>_Exit Func Register_RawInput($iUsagePage, $iUsage, $iFlags, $hTargetHwnd) Local $tRID = DllStructCreate($tagRAWINPUTDEVICE) DllStructSetData($tRID, 'UsagePage', $iUsagePage) DllStructSetData($tRID, 'Usage', $iUsage) DllStructSetData($tRID, 'Flags', $iFlags) DllStructSetData($tRID, 'hTarget', $hTargetHwnd) ; Register HID input to obtain info from devices _WinAPI_RegisterRawInputDevices($tRID) EndFunc ;==>Register_RawInput Func WM_INPUT($hWnd, $iMsg, $wParam, $lParam) ;Callback from RawInput #forceref $iMsg, $wParam ;'struct;dword Type;dword Size;handle hDevice;wparam wParam;endstruct' Local $tRIH = DllStructCreate($tagRAWINPUTHEADER) If _WinAPI_GetRawInputData($lParam, $tRIH, DllStructGetSize($tRIH), $RID_HEADER) And DllStructGetData($tRIH, "Type") = $RIM_TYPEKEYBOARD Then ConsoleWrite("0x" & Hex(DllStructGetData($tRIH, "hDevice")) & @CRLF) If $ghSelectedDevice = DllStructGetData($tRIH, "hDevice") Then Device_Pressed() Else ;Different Device ConsoleWrite("Different Device Pressed" & @CRLF) EndIf EndIf Return $GUI_RUNDEFMSG ;Pass on to default winproc EndFunc ;==>WM_INPUT Func EnumRawKeyboards($sDeviceNameMatch = "") ;Returns array of keyboard device IDs Local $tInfo, $aData = _WinAPI_EnumRawInputDevices() If IsArray($aData) Then Local $aKeyboards[$aData[0][0] + 1][4] ;'dword Size;dword Type;';'struct;dword KbType;dword KbSubType;dword KeyboardMode;dword NumberOfFunctionKeys;dword NumberOfIndicators;dword NumberOfKeysTotal;endstruc' Local $_tagRID_INFO_KEYBOARD = $tagRID_INFO_KEYBOARD If StringRight($_tagRID_INFO_KEYBOARD, 1) <> "t" Then $_tagRID_INFO_KEYBOARD &= "t" ; t is missing from endstruct Local $iCt = 0, $iSz Local $tInfo, $tDeviceName, $sDeviceName For $i = 1 To $aData[0][0] $tInfo = DllStructCreate($_tagRID_INFO_KEYBOARD) If _WinAPI_GetRawInputDeviceInfo($aData[$i][0], $tInfo, DllStructGetSize($tInfo), $RIDI_DEVICEINFO) And $aData[$i][1] = $RIM_TYPEKEYBOARD Then $iSz = _WinAPI_GetRawInputDeviceInfo($aData[$i][0], 0, 0, $RIDI_DEVICENAME) ;Get bytes needed $tDeviceName = DllStructCreate('wchar[' & $iSz + 1 & ']') ;Holds device name string If _WinAPI_GetRawInputDeviceInfo($aData[$i][0], $tDeviceName, DllStructGetSize($tDeviceName), $RIDI_DEVICENAME) Then $sDeviceName = DllStructGetData($tDeviceName, 1) If $sDeviceNameMatch <> "" And Not StringInStr($sDeviceName, $sDeviceNameMatch) Then ContinueLoop $iCt += 1 $aKeyboards[$iCt][0] = $aData[$i][0] ;Handle $aKeyboards[$iCt][1] = $aData[$i][1] ;Type $aKeyboards[$iCt][2] = $sDeviceName $aKeyboards[$iCt][3] = DllStructGetData($tInfo, "NumberOfKeysTotal") EndIf EndIf Next $aKeyboards[0][0] = $iCt ; Write count of keyboard devices to array ReDim $aKeyboards[$iCt + 1][4] ;Resize array EndIf Return $aKeyboards EndFunc ;==>EnumRawKeyboards  
×
×
  • Create New...