if checkbox is ticked then run another ahk file Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
kentpachi
Posts: 152
Joined: 15 May 2016, 01:23

if checkbox is ticked then run another ahk file

Post by kentpachi » 14 Jul 2022, 07:53

Good day AHKers,

First, this is a code for a simple GUI script

; Generated by AutoGUI 2.5.8
#SingleInstance Force
#NoEnv
SetWorkingDir %A_ScriptDir%
SetBatchLines -1

Gui Add, CheckBox, x20 y23 w49 h23, first
Gui Add, CheckBox, x97 y24 w60 h23, second
Gui Add, CheckBox, x179 y24 w58 h23, third
Gui Add, CheckBox, x264 y23 w64 h23, fourth

Gui Show, w371 h73, Window
Return

GuiEscape:
GuiClose:
ExitApp


Image

There are 4 checkbox - first, seocond third and fourth


Is it possible if you ticked any of the checkbox, it will run the script ahk and if I untick it, it will close the ahk script?

also, how to make it pin to top on specific software like for example, it will automatically pin to top on notepad.exe
Last edited by kentpachi on 14 Jul 2022, 08:08, edited 1 time in total.

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

Re: if checkbox is ticked then run another ahk file  Topic is solved

Post by mikeyww » 14 Jul 2022, 08:02

Code: Select all

dir = %A_ScriptDir%
Gui, Font, s10
For each, box in ["first", "second", "third", "fourth"]
 Gui Add, CheckBox, gCheck w100 ym, %box%
Gui Show,, Scripts
Return

Check:
DetectHiddenWindows, On
script = %dir%\%A_GuiControl%.ahk
GuiControlGet, checked,, %A_GuiControl%
If checked
 Run, %script%
Else WinClose, %script% ahk_class AutoHotkey
Return

kentpachi
Posts: 152
Joined: 15 May 2016, 01:23

Re: if checkbox is ticked then run another ahk file

Post by kentpachi » 14 Jul 2022, 09:23

mikeyww wrote:
14 Jul 2022, 08:02

Code: Select all

dir = %A_ScriptDir%
Gui, Font, s10
For each, box in ["first", "second", "third", "fourth"]
 Gui Add, CheckBox, gCheck w100 ym, %box%
Gui Show,, Scripts
Return

Check:
DetectHiddenWindows, On
script = %dir%\%A_GuiControl%.ahk
GuiControlGet, checked,, %A_GuiControl%
If checked
 Run, %script%
Else WinClose, %script% ahk_class AutoHotkey
Return
thank you as always mikey, I use the glabel which is more newbie friendly

a followup question, how to make the gui pin/always on top on a specific exe only ? for example i want it to always on top on game123.exe

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

Re: if checkbox is ticked then run another ahk file

Post by mikeyww » 14 Jul 2022, 09:43

Code: Select all

dir = %A_ScriptDir%
Gui, Font, s10
For each, box in ["first", "second", "third", "fourth"]
 Gui Add, CheckBox, gCheck w100 ym, %box%
Gui Show,, Scripts
Loop {
 WinWait, ahk_exe notepad.exe
 SoundBeep, 1500
 WinSet, AlwaysOnTop, On
 WinWaitClose
 SoundBeep, 1000
}
Return

Check:
DetectHiddenWindows, On
script = %dir%\%A_GuiControl%.ahk
GuiControlGet, checked,, %A_GuiControl%
If checked
 Run, %script%
Else WinClose, %script% ahk_class AutoHotkey
Return

Post Reply

Return to “Ask for Help (v1)”