Jump to content
Sign in to follow this  
mithandir1

help with mouse click emulator

Recommended Posts

mithandir1

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?

Share this post


Link to post
Share on other sites
martin

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.

Share this post


Link to post
Share on other sites
FireFox

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


 

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
mithandir1

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
Thanks for the help. I am using the number pad keys / *. Those comments didn't get changed when I changed keys.

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
Sign in to follow this  

×