Simulating a Mouse click with a keystroke?

Filthy Dangles

Registered User*
Oct 23, 2014
28,635
40,251
A weird thread/question, I will do my best to explain what I am trying to accomplish specifically as it's somewhat convoluted. I didn't see a general or meta tech thread...

There is a popular Public Golf course in my area where you can reserve tee times online, but it is really hard to get a good tee time at this course. You have to logon a set time and click the date and then the times appear below where first come first serve, you have to click it as fast as you can and they go away really fast.

Basically, you have to keep clicking the '10' highlighted in the below image until the times become available (at the top of the hour) and then click the times as they appear as buttons below where it says 'Tee Times appear here'.

If I could just shorten that time by not having to click '10' and having my mouse right where the tee times appear, I could increase my chances of getting a good time. Clicking 'Enter' or 'Shift' or 'Ctrl' with the 10 does not perform a 'click'.

I generally use Google Chrome browser. Is there some keyboard command I am missing, or is there some browser extension or app i'd need to install for this? Anyone have experience or a solution for a similar problem?



cOTIUdj.png
 

Osprey

Registered User
Feb 18, 2005
27,306
9,792
If you're on Windows and willing to put in a little time to set it up, the free AutoHotkey tool can do that for you. It's more than you need, but you can do just about anything with it.

To get started:
1. Download the "current version" from www.autohotkey.com
2. Run it and install or extract it.
3. Browse to the folder that you installed/extracted it to.
4. Create a blank text file with a .ahk extension. This will be your script.
5. Open the file in a text editor like Notepad.
6. Double click on AutoHotkey.chm to open the AutoHotkey help file (i.e. manual).
7. Look up commands in the help file and add them to your script.
8. Save your script.
9. Drag your script onto AutoHotkey.exe to run it. You can also rename AutoHotkey.exe to the same as your script (ex. to MyScript.exe if you named your script MyScript.ahk) so that running it will automatically run your script, which might make things easier, especially if you want to create a shortcut later.

As for which commands to use to do what you want... heck, it'll just be easier to write a script for you:
Code:
#SingleInstance Force

Esc::ExitApp

MButton & LButton::    ; When the middle mouse button is held down and the left mouse button is pressed...
    MouseGetPos, DateX, DateY  ;  Save the X and Y coordinates of the mouse position as the date position
Return

MButton::    ; When the middle mouse button is pressed...
    MouseGetPos, TeeX, TeeY  ; Save the X and Y coordinates of the mouse position as the tee times position
    MouseClick, Left, %DateX%, %DateY%  ; Click the left mouse button at the date position
    Sleep, 50  ; Wait 50ms just to be safe
    MouseMove, %TeeX%, %TeeY%  ; Move the mouse back to the tee times position
Return

To use it, run it (step 9 above), mouse over the date ("10" in this case), then hold down your middle mouse button while pressing your left mouse button. That saves the position of the date. Now, mouse over to the tee times and press the middle mouse button (press and release; don't hold this time). That'll move your mouse over to the date, click it and then move it back to where you had it (over the tee times). If you need to change the date or you moved/resized your browser window, re-save the position of the date by holding MMB and pressing LMB again.

Press Esc at any time to stop the script and unload AutoHotkey from memory (or, if you don't want Esc to unload it, remove that hotkey command and just close the program from the Windows notification area). Once you've gotten this script working, you may care to add commands to make it more powerful. Use the AutoHotkey help file to look them up. If you need further help, while I can give some, the best place is the AutoHotkey forums, especially the Ask For Help subforum: AutoHotkey Community - Index page

I sure hope that you're on Windows or else I just got carried away typing that all out for nothing :laugh:.
 
Last edited:
  • Like
Reactions: Filthy Dangles

Osprey

Registered User
Feb 18, 2005
27,306
9,792
FYI, Filthy, I just edited my post to greatly improve the script. It works better and you shouldn't have to modify it to make it work. You can still modify it if you want, especially by changing the buttons. I just thought that the middle mouse button (assuming that you have one) might be easier to remember and less problematic to use than a keystroke.
 
Last edited:
  • Like
Reactions: Filthy Dangles

Ad

Upcoming events

Ad

Ad