Using Second Script to Modify GUI in First Script

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
pmoshiri
Posts: 17
Joined: 14 Feb 2020, 13:12

Using Second Script to Modify GUI in First Script

21 Jun 2021, 14:37

Hi All,

I am wondering if it is possible to use a second script to modify a GUI thats generated in the first script. I have had no luck so far but just wondering if, generally, this is possible.

Thanks.
doubledave22
Posts: 343
Joined: 08 Jun 2019, 17:36

Re: Using Second Script to Modify GUI in First Script

21 Jun 2021, 15:41

You should be able to modify GUI elements on a second script but you won't be able to use the variable names made in script 1's gui when trying to modify them in script 2.

Instead you will have to use windows spy to get ClassNN/Control texts and use ControlGet and Control to manipulate them.

https://www.autohotkey.com/docs/commands/ControlGet.htm
https://www.autohotkey.com/docs/commands/Control.htm
pmoshiri
Posts: 17
Joined: 14 Feb 2020, 13:12

Re: Using Second Script to Modify GUI in First Script

21 Jun 2021, 16:28

doubledave22 wrote:
21 Jun 2021, 15:41
You should be able to modify GUI elements on a second script but you won't be able to use the variable names made in script 1's gui when trying to modify them in script 2.

Instead you will have to use windows spy to get ClassNN/Control texts and use ControlGet and Control to manipulate them.

https://www.autohotkey.com/docs/commands/ControlGet.htm
https://www.autohotkey.com/docs/commands/Control.htm
Thank you for your suggestion!

I am trying to use the imagebutton class to change the color of the gui generated in the first script. I am able to get HWND using ControlGet but I can't use the imagebutton class to change the color.
doubledave22
Posts: 343
Joined: 08 Jun 2019, 17:36

Re: Using Second Script to Modify GUI in First Script

21 Jun 2021, 16:58

If you want to call functions in script 1 from script 2 the best approach is probably ObjRegisterActive:
https://www.autohotkey.com/boards/viewtopic.php?t=6148

I only scratched the surface when using it. The example Lexikos posted should get you started.

Is there any reason you can't change this value from script 1? Maybe there's a simpler solution.
pmoshiri
Posts: 17
Joined: 14 Feb 2020, 13:12

Re: Using Second Script to Modify GUI in First Script

21 Jun 2021, 17:02

doubledave22 wrote:
21 Jun 2021, 16:58
If you want to call functions in script 1 from script 2 the best approach is probably ObjRegisterActive:
https://www.autohotkey.com/boards/viewtopic.php?t=6148

I only scratched the surface when using it. The example Lexikos posted should get you started.

Is there any reason you can't change this value from script 1? Maybe there's a simpler solution.

Sure, I am using a setimer routine to check whether a value in a sqlserver db has changed. Ive noticed using a settimer in my main script seems to cause me problems.
doubledave22
Posts: 343
Joined: 08 Jun 2019, 17:36

Re: Using Second Script to Modify GUI in First Script

21 Jun 2021, 18:39

I would suggest trying to narrow down the relevant code in your sqlserver timer thats causing problems and try to get help on that. I'm not sure I'll be of help but others may know more if you can post a trimmed down version and describe your problem.

always best to solve the core issue rather than find some elaborate workaround (unless it's truly your only choice)

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: dipahk, jeves, Nerafius, RandomBoy, zerox and 97 guests