Activate a GUI from another script Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
one1tick
Posts: 32
Joined: 04 Mar 2022, 04:26

Activate a GUI from another script

Post by one1tick » 25 Sep 2022, 09:56

Hi,
I have a script using a couple of guis and actions are triggered by a hotkey (^Esc) within the scipt :

Code: Select all

gui 1 definition
gui 2 definition
gui x definition
return

^Esc::
code to use my gui based on several things...
......
return

xxx:
return

yyy:
return
Now I would like to call my code from another script... I see 2 options that are not really "clean".
- In the other script I can use Send, ^{Esc} to trigger the first script but I don't think it is the cleanest way...
- I remove the first return below the guis definitions and the ^Esc:: so I can call the first script from my second script when needed. Again I don't like it because each time the script will "rebuild" the guis...

Anyone see a better way to solve this situation ?

Thanks for any idea. Best.

User avatar
mikeyww
Posts: 26891
Joined: 09 Sep 2014, 18:38

Re: Activate a GUI from another script

Post by mikeyww » 25 Sep 2022, 12:15

I don't know how you define "clean", but you can include your script with #Include, or use SendLevel and trigger a hotkey routine.

https://www.autohotkey.com/docs/commands/SendLevel.htm

To run another script, you can use Run.

You can use WinActivate to activate a window, including a GUI.

one1tick
Posts: 32
Joined: 04 Mar 2022, 04:26

Re: Activate a GUI from another script  Topic is solved

Post by one1tick » 26 Sep 2022, 01:45

mikeyww wrote:
25 Sep 2022, 12:15
I don't know how you define "clean", but you can include your script with #Include, or use SendLevel and trigger a hotkey routine.

https://www.autohotkey.com/docs/commands/SendLevel.htm

To run another script, you can use Run.

You can use WinActivate to activate a window, including a GUI.
Thanks for your feedback @mikeyww.
I will go for my second option and run the first script from the second with run even if each time I will call the first script it will recreate my guis.

Thanks for your help.

Post Reply

Return to “Ask for Help (v1)”