I'm working on a HotKey tool for online game Dota 2 which should to simulate some keypress with Awt Robot. So, my problem is that modifier key is Alt and then I run first time from Intelij Idea my code and trying in game the registered Hotkey combination first time all work as expected, but the second time then I press again the hotkey nothing happen. I tried with delay on awt robot as you can see 2 commented lines in ghostWalk method and I realized that nothing is not simulated because when method is called to simulate keypress my finger is still on Alt key but with delay from 40-60 all work ok. (with 40 not rly, need to move out finger from alt key very fast)

So if to run code below and press registered hotkey always first time Alt + Key work as expected without any delay nothing, if to close program and run again the same thing always first time work as expected, second third etc times not. This look like first time the HotKey event is started when Alt key is released this is why all work okay all others time need the delay until Alt key is released. Is there any way to fix this ?

Hmmm so you are saying after the Hotkey is registered the first time you see the "WINDOWS+W Hotkey Pressed" message but then subsequent presses you do not see that message?

Only if you restart the app?

One thing to try not that it should make a difference but if you look at our example I have a class that implements HotKeyListener and I register that class to it. THe only thing I see you doing differently is the anonymous inline class registration.

Melloware wrote:Hmmm so you are saying after the Hotkey is registered the first time you see the "WINDOWS+W Hotkey Pressed" message but then subsequent presses you do not see that message?

Nope, message is printed always whenever I press the registered HotKey .For example if to try my code in Steam store search textbox (cannot try this in browser or notepad because focus from textbox is move out when I press Alt) then all work as expected - I'm press the combination Alt + D and "qqwrd" is printed. But in game, only first time when I press the Hotkey all work as expected. This is output of 2 times press the Hotkey - "qqwrdd" where "qqwrd" is after first time and last "d" after second time, the "d" after second time is printed only because there is delay "robot.delay(i)" where i = 180.This looks like second third etc times the method which simulate key press is started when my finger still press Alt key and nothing is printed, idk why always if to restart program always first time work as expected, the second, third time work only with start delay(60) you can see 2 commented lines in ghostWalk method.P.S if registered Hotkey is without Alt modifier, for example only "Z" all work as expected always without delay and other sh**. I don't think that this is game limits because first time always work + I have another tool which do the same as I want to do without this problem in the same game.

Melloware wrote:Hmmmm you are right I am stumped. I thought the problem was my hotkey was not registering the callback after the first time.

You are saying your code is executing it's just not doing what you expect it to do.

Exactly, you can try my code in skype to see what exactly happens, in skype the focus is too moving out on a top tabs from a moment and first "q" is not printing but anyway in the rest the code behavior is exactly like in game after first time only "D" is simulated.I tried to look in the source code to understand what changes are made after first event but I'm newbie and the source looks for me like chinese. Did you have any idea how to fix this ?Here is my all code from first to last line. Dll x64.

is the creation of the Robot() class expensive i wonder if that should just be instantiated once?

I have no idea, I tried now and if he is initiated somewhere else than ghostWalk method then only "D" is printed always even first time. With no modifier for example only "Z" key then no matter where and how it is initiated this work always like it should. Well, maybe I'm not doing right, can you suggest how it should to be initiated? Tried it as static initiated in main() method also tried as non static initiated only one time in k() method, idk what is wrong, this just fucked up my brain.