Page 1 of 1
How to trigger a hotkey/hotstring from another script?
Posted: 11 Apr 2019, 03:44
by newbieforever
Hi!
What is the simplest* way to trigger (from a script) hotkeys or hotstrings which are defined in other running scripts?
* Maybe an one-line solution?
Re: How to trigger a hotkey/hotstring from another script?
Posted: 11 Apr 2019, 04:19
by Rohwedder
Re: How to trigger a hotkey/hotstring from another script?
Posted: 11 Apr 2019, 04:33
by newbieforever
Thank you, Rohwedder!
In the meantime I foud this:
https://www.autohotkey.com/boards/viewtopic.php?t=20763
The method presented by Zvonko is an one-line solution for hotkeys, this is perfect. But for hotstrings 3 lines are required:
Code: Select all
; :*:btw::by the way ; hotstring defined in another script***
SendLevel 1
Send btw
SendLevel 0
Could the definition of the hotstring*** be adapted in such a way that triggering from another script would be possible by an one-line command?
Re: How to trigger a hotkey/hotstring from another script?
Posted: 11 Apr 2019, 04:45
by jeeswg
I'd use PostMessage (to send) and OnMessage (to receive).
Re: How to trigger a hotkey/hotstring from another script?
Posted: 11 Apr 2019, 06:53
by Rohwedder
Hallo,
you need only one
SendLevel 1 in the Auto-execute Section
try:
Code: Select all
;Script1
SendLevel 1
1::Send btw{Space} ; Produces "by the way "
2::Send q ; Produces "e.g. "
Code: Select all
;Script2
::btw::by the way
q::Send,% "e.g. "
Re: How to trigger a hotkey/hotstring from another script?
Posted: 11 Apr 2019, 07:14
by newbieforever
Rohwedder wrote: ↑11 Apr 2019, 06:53
you need only one
SendLevel 1 in the Auto-execute Section
Yes, I see. However, this would affect the whole script...
I don't understand how this question is related to the use of
#InputLevel preceding the hotstring definition. Could by this way
SendLevel become unnecessary?