mithandir1 Posted January 10, 2009 Share Posted January 10, 2009 Hello I have been working on a PC based arcade machine. I have a small problem though the trackball I purchased does not have any mouse buttons. Since this will be my primary means of navigation I need a way to convert keystrokes(num/ and num*) into left and right mouse clicks. Here is what I have so far: #include <Misc.au3> Opt("SendKeyDelay",100) ;Break(0) $dll = DllOpen("user32.dll") While 1 If _IsPressed("6F", $dll) Then;if the scroll lock is pressed MouseClick("left") sleep(100) EndIf If _IsPressed("6A", $dll) Then;if the pause key is pressed mouseclick("right") sleep(100) EndIf WEnd It works somewhat, but has some issues. If the keys are held it repeatedly clicks the mouse and scroll bars are very jumpy. Also how do I stop the keys from being transmitted to programs? Link to comment Share on other sites More sharing options...
martin Posted January 11, 2009 Share Posted January 11, 2009 Hello I have been working on a PC based arcade machine. I have a small problem though the trackball I purchased does not have any mouse buttons. Since this will be my primary means of navigation I need a way to convert keystrokes(num/ and num*) into left and right mouse clicks. Here is what I have so far: #include <Misc.au3> Opt("SendKeyDelay",100) ;Break(0) $dll = DllOpen("user32.dll") While 1 If _IsPressed("6F", $dll) Then;if the scroll lock is pressed MouseClick("left") sleep(100) EndIf If _IsPressed("6A", $dll) Then;if the pause key is pressed mouseclick("right") sleep(100) EndIf WEnd It works somewhat, but has some issues. If the keys are held it repeatedly clicks the mouse and scroll bars are very jumpy. Also how do I stop the keys from being transmitted to programs? I would keep away from keys like Scroll lock and Pause and use something else, though I might be over cautious. You could use HotKeySet and have a function for each key which performs the mouse click, and that way no other program will see the keys you are using. #include <Misc.au3> HotKeySet("{NUMPADDIV}", "LClick") HotKeySet("{NUMPADMULT}", "RClick") While 1 Sleep(50) WEnd Func LClick() MouseClick("left") Sleep(100) EndFunc ;==>LClick Func RClick() MouseClick("right") Sleep(100) EndFunc ;==>RClick Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
FireFox Posted January 11, 2009 Share Posted January 11, 2009 @mithandir take a look to IsPressed_UDF , this should help you here an example with timer functions that allow you to click every 1sec (1000ms) : #include <Misc.au3> Opt("SendKeyDelay",100) $click = True While 1 If $timer >= 1000 Then $click = True If _IsPressed("6F") Then;if the scroll lock is pressed If $click = True Then $timer = timerinit() MouseClick("left") $click = False EndIf ElseIf _IsPressed("6A") Then;if the pause key is pressed If $click = True Then $timer = timerinit() mouseclick("right") $click = False EndIf EndIf WEnd Cheers, FireFox. Link to comment Share on other sites More sharing options...
mithandir1 Posted January 11, 2009 Author Share Posted January 11, 2009 I would keep away from keys like Scroll lock and Pause and use something else, though I might be over cautious. You could use HotKeySet and have a function for each key which performs the mouse click, and that way no other program will see the keys you are using. #include <Misc.au3> HotKeySet("{NUMPADDIV}", "LClick") HotKeySet("{NUMPADMULT}", "RClick") While 1 Sleep(50) WEnd Func LClick() MouseClick("left") Sleep(100) EndFunc ;==>LClick Func RClick() MouseClick("right") Sleep(100) EndFunc ;==>RClickThanks for the help. I am using the number pad keys / *. Those comments didn't get changed when I changed keys. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now