configure AutoHotKey on keyboard

bmn

Member
I have the Microsoft Ergonomic keyboard 4000, and was trying to configure AutoHotKey to use the Favorite keys 1 through 5 for simple tasks like Buy Market Order, Sell Market order etc, on TOS.. However, it doesn't recognize it at all. I have it run as Administrator. I figured out the keys for Favorites as well, for example Favorite 1 key is 0100000000050000, Favorite 2 is 0100000000090000. But somehow those keys don't work with TOS. Did anyone get this to work ?
 
Last edited by a moderator:

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

@bmn you will have to detect the raw input data from your keyboard since "Favorite" keys are non-standard keys. This link should point you in the right direction. https://www.autohotkey.com/board/topic/36304-hidextended-input-devices-ms-natural-keyboard-4000-etc/
After that, it should just be a matter of turning on hot keys in TOS and have AHK send the correct hotkey combination.
Thanks, yes that's how I was able to find the AHK key for Favorite keys - for example Favorite 1 key is 0100000000050000, Favorite 2 is 0100000000090000. Unfortunately, that's how far I could get. I tried running it in Administrator mode as well, no success. It is almost like TOS doesn't allow AHK to work with that. I have TOS hotkeys enabled, and that works fine.. But just trying to see if I can do it via the Favorite keys, since it's not a combination key. nothing better to do!
 
@bmn which one do you have TOS running: Live, OnDemand, or Papertrade? I could be wrong, but I'm thinking hotkeys only work in TOS with live trading. Try swapping out the key sends from AHK with mouse clicks on the correct button.
 
Last edited:
@bmn which one do you have TOS running: Live, OnDemand, or Papertrade? I could be wrong, but I'm thinking hotkeys only work in TOS with live trading. Try swapping out the key sends from AHK with mouse clicks on the correct button.
Thanks for replying. I have tried with Live and OnDemand (haven't tried Paper Trade yet). But the layout is the same, and since AHK goes with the coordinates, it should "click" on the Buy Market button as I trace it with mouse. Maybe AHK doesn't recognize the Favorite keys on this specific keyboard - image below, note the top 5 buttons labeled 1 through 5, those are the Favorite keys. I see AHK does recognize the other keys correctly. I have run the script to see what keys get recorded in AHK when I press say Favorite key 1, and that's what gives that code "0100000000050000".. However, when I put that in the AutoHotKey.ahk file for the "Buy Market" button, nothing happens.
7332059_sd.jpg
 
since AHK goes with the coordinates, it should "click" on the Buy Market button as I trace it with mouse.
Not sure what you mean here, AHK can't recognize a button control just because you move your mouse pointer over it.
You have to use a line of code in your AHK script such as:
Ruby:
MouseClick, Left, 1580, 125, 1, 0
Where 2nd and 3rd parameters are coordinates on screen where the button control is located.

Maybe AHK doesn't recognize the Favorite keys on this specific keyboard
AHK returned the raw data when you pressed the Favorite key 1 (0100000000050000), so it does recognize the key press.

However, when I put that in the AutoHotKey.ahk file for the "Buy Market" button, nothing happens.
Have you tried using one of the regular keys to test that everything beyond what key you use is working?

If you want post your AHK script, I might be able to help you troubleshoot it.
 
Not sure what you mean here, AHK can't recognize a button control just because you move your mouse pointer over it.
You have to use a line of code in your AHK script such as:
Ruby:
MouseClick, Left, 1580, 125, 1, 0
Where 2nd and 3rd parameters are coordinates on screen where the button control is located.


AHK returned the raw data when you pressed the Favorite key 1 (0100000000050000), so it does recognize the key press.


Have you tried using one of the regular keys to test that everything beyond what key you use is working?

If you want post your AHK script, I might be able to help you troubleshoot it.
Yes, it works fine if I use say "Ctrl+1" as the hotkey. The Buy Market gets triggered without problem. It's just those 5 favorite keys that don't get recognized.
Here's the code from my .ahk file - thanks for checking this for me!

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; ThinkorSwim hotkeys
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;
;Buy Market action - to buy 1 contract of /ES
;;;;;;;;;;;
; Favorites 1
; ^1:: works fine using Ctrl+1
0100000000050000:
IfWinNotActive, Main@thinkorswim [build 1974], , WinActivate, Main@thinkorswim [build 1974],
MouseClick, left, 2004, 149
Sleep, 100
return

;;;;;;;;;;;
;Sell Market
;;;;;;;;;;;
; Favorites 2
0100000000090000:
IfWinNotActive, Main@thinkorswim [build 1974], , WinActivate, Main@thinkorswim [build 1974],
MouseClick, left, 2085, 144
return

;;;;;;;;;;;
;Flatten
;;;;;;;;;;;
; Favorites 5
0100000000410000:
IfWinNotActive, Main@thinkorswim [build 1974], , WinActivate, Main@thinkorswim [build 1974],
MouseClick, left, 2078, 106
return
 
Last edited:
@bmn searched around a little a found this.
https://www.autohotkey.com/boards/viewtopic.php?t=60567

The script you need to translate your extra buttons is here.
https://github.com/PolarGoose/AutoHotKey-Natural-Ergonomic-Keyboard-4000-support

You will need the 3 scripts listed here:
https://github.com/PolarGoose/AutoHotKey-Natural-Ergonomic-Keyboard-4000-support/tree/master/Src
to translate the keyboard data into something AHK can recognize.

From just glancing over it, you will repurpose the "example.ahk" in the link above as your "Buy Market" script.
When you run the file, it will pull from the other two scripts.
Both the example.ahk and Natural_keyboard_4000_support.ahk have #include statements where you
may have to change the file directory to match where you saved the files.
 
@bmn searched around a little a found this.
https://www.autohotkey.com/boards/viewtopic.php?t=60567

The script you need to translate your extra buttons is here.
https://github.com/PolarGoose/AutoHotKey-Natural-Ergonomic-Keyboard-4000-support

You will need the 3 scripts listed here:
https://github.com/PolarGoose/AutoHotKey-Natural-Ergonomic-Keyboard-4000-support/tree/master/Src
to translate the keyboard data into something AHK can recognize.

From just glancing over it, you will repurpose the "example.ahk" in the link above as your "Buy Market" script.
When you run the file, it will pull from the other two scripts.
Both the example.ahk and Natural_keyboard_4000_support.ahk have #include statements where you
may have to change the file directory to match where you saved the files.
Just coming back to post that I got it working, thanks to your helpful links. Appreciate it!
 

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
178 Online
Create Post

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top