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
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
if checkbox is ticked then run another ahk file Topic is solved
if checkbox is ticked then run another ahk file
Last edited by kentpachi on 14 Jul 2022, 08:08, edited 1 time in total.
Re: if checkbox is ticked then run another ahk file Topic is solved
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
Re: if checkbox is ticked then run another ahk file
thank you as always mikey, I use the glabel which is more newbie friendlymikeyww wrote: ↑14 Jul 2022, 08:02Code: 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
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
Re: if checkbox is ticked then run another ahk file
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