How to trigger a hotkey/hotstring from another script?

Get help with using AutoHotkey and its commands and hotkeys
newbieforever
Posts: 444
Joined: 24 Aug 2016, 03:34

How to trigger a hotkey/hotstring from another script?

11 Apr 2019, 03:44

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?
newbieforever
Posts: 444
Joined: 24 Aug 2016, 03:34

Re: How to trigger a hotkey/hotstring from another script?

11 Apr 2019, 04:33

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?
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: How to trigger a hotkey/hotstring from another script?

11 Apr 2019, 04:45

I'd use PostMessage (to send) and OnMessage (to receive).
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Rohwedder
Posts: 3268
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: How to trigger a hotkey/hotstring from another script?

11 Apr 2019, 06:53

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. "
newbieforever
Posts: 444
Joined: 24 Aug 2016, 03:34

Re: How to trigger a hotkey/hotstring from another script?

11 Apr 2019, 07:14

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?

Return to “Ask For Help”

Who is online

Users browsing this forum: Epialis, lexikos, rifqii_, Smile_ and 49 guests