Can't Run Hotkeys Asynchronously
See original GitHub issueI have two hotkeys set, one to perform an action and the other to cancel it. The problem is that when I call the second hotkey while the first hotkey is doing something, it doesn’t trigger until after the first one is done.
HotkeyManager.Current.AddOrReplace("Paste", HkTextBox.Hotkey.Key, HkTextBox.Hotkey.Modifiers, AutoPaste);
HotkeyManager.Current.AddOrReplace("CancelPaste", Key.Escape, ModifierKeys.Alt, CancelPaste);
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Asynchronosly launch a method - AutoHotkey Community
Threads are not asynchronous in AutoHotkey. Scripts cannot do two things at once. They can only stop what they're doing to run a...
Read more >How to async handle callback from keyboard hotkeys?
Need to register global hotkeys. For example, f4 and f8 . With keyboard library while first callback didn't return, the next won't call....
Read more >Anyway to run shortcut inside another without waiting for it ...
Is there anyway to start a shortcut inside another shortcut without waiting for it to complete? Kinda asynchronous styled?
Read more >View topic - execute asynchronous
Executing a script asynchronously will create a thread to execute it. This won't block the main thread, but it also means you can't...
Read more >Intro to the Run JavaScript on Webpage action in Shortcuts ...
Because JavaScript is usually used with asynchronous patterns, the call is intentionally not synchronous. This way, you can finish the action asynchronously.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Task.Factory.StartNew
means "run that on a new thread. ButDispatcher.BeginInvoke
means “run that on the UI thread”. So there’s no point in starting a new thread just to execute something on the UI thread…I gave you a few suggestions on how to fix the problem in my previous message, have you tried them? I checked what
input.Keyboard.Sleep
does, it’s just aThread.Sleep
. So I suggest you do it like this:Anyway, the problems you’re having have nothing to do with NHotkey, so I’m going to close this issue.
I tried running a new thread on both individually and together but it’s still running synchronously. The only difference this time is that the message box pops up on the screen without me having to click on the application.