I have a GUI with text on it and a button. I am making a glorified message box. I have a button on the GUI.
How do I make it so when you hit ENTER, its like clicking the OK button.
hitting enter clicks OK button
Re: hitting enter clicks OK button
From the help file.Gui, Add, Button, Default, OK
The example above includes the word Default in its Options to make "OK" the default button. The default button's action is automatically triggered whenever the user presses ENTER,
Re: hitting enter clicks OK button
@noname, thank you
it works first time , but when I use the button TEST is the button TEST default (?)
it works first time , but when I use the button TEST is the button TEST default (?)
Code: Select all
Gui,add,button,x10 y10 w50 h25 gA0 ,TEST
Gui,add,button,x10 y40 w50 h25 gA1 +default,OK
Gui,show,x10 y10 h90 w150,TEST-GUI
return
Guiclose:
exitapp
a0:
msgbox,You clicked TEST
return
$enter::
a1:
msgbox,You clicked OK / or used ENTER
return
Re: hitting enter clicks OK button
If I hit TAB, the OK button below hightlights, then I hit ENTER and the GUI goes away.
Gui, Add, Button, gTestIt x30 y240 , OK
return
TestIt:
If (GetKeyState("ENTER"))
WinClose GUi window.ahk
How can I get the OK button to default to being hightlighted and close the GUI just by hitting ENTER.
Thanks.
Gui, Add, Button, gTestIt x30 y240 , OK
return
TestIt:
If (GetKeyState("ENTER"))
WinClose GUi window.ahk
How can I get the OK button to default to being hightlighted and close the GUI just by hitting ENTER.
Thanks.
Re: hitting enter clicks OK button
Sorry sbrady , i do not have a solution for highlighting the focused button , i am surprised it does not seem to be possible.The example above includes the word Default in its Options to make "OK" the default button. The default button's action is automatically triggered whenever the user presses ENTER, except when the keyboard focus is on a different button ...
https://autohotkey.com/boards/viewtopic.php?t=38027
and
https://autohotkey.com/boards/viewtopic.php?t=23543
You can use controlfocus to set the correct button focused ( enter will execute it ) but the highlighting stays with the previous one which is confusing for the user.
Greetings
If there is only one button it seems to work even when another control can be focused.
Code: Select all
Gui, Add, Button, x30 y100 +default, OK
Gui, add,edit,w200
Gui, show,,test
return
ButtonOk:
winclose
return
Re: hitting enter clicks OK button
figured it out, so cool, double click the icon, a window pops open to tell you what files it can open,
hit ENTER and the window goes away and any aif or wav files get opened in Audacity.
hit ENTER and the window goes away and any aif or wav files get opened in Audacity.
Code: Select all
Gui, Show, h300 w300
Gui, Font, s18
Gui, Add, Text, h280 w280, This Script opens:`n"aif" and "wav" files`nin Audacity,`r`n`r`nthe files and this script must be located the same place.
Gui, Font, s12
;Gui, Add, Button, default x30 y240 , OK ;x30 y250 w100 h20 gTestIt
Gui, Add, Button, gTestIt x30 y240 +default, Hit Enter ;x30 y250 w100 h20
return
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
TestIt:
If (GetKeyState("ENTER"))
{
;WinClose GUi window.ahk
clips =
loop, %A_WorkingDir%\*.wav
{
clips = %clips% "%A_LoopFileName%"
}
loop, %A_WorkingDir%\*.aif
{
clips = %clips% "%A_LoopFileName%"
}
loop, %A_WorkingDir%\*.aiff
{
clips = %clips% "%A_LoopFileName%"
}
;loop, %A_WorkingDir%\*.mp3
;{
;clips = %clips% "%A_LoopFileName%"
;}
;clips = "SAL123.wav" "SUE123.aif"
run, "C:\Program Files (x86)\Audacity\audacity.exe\" %clips%
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
}
GuiClose:
GuiEscape:
ExitApp
Re: hitting enter clicks OK button
Example for loop
Code: Select all
setworkingdir,%a_scriptdir%
transform,s,chr,34
Gui, Show, h300 w300
Gui, Font, s18
Gui, Add, Text, h280 w280, This Script opens:`n"aif" and "wav" files`nin Audacity,`r`n`r`nthe files and this script must be located the same place.
Gui, Font, s12
Gui, Add, Button,gTestIt x30 y240 +default, Hit Enter
return
Guiclose:
exitapp
;------------------------------------------------
TestIt:
If (GetKeyState("ENTER"))
{
transform,s,chr,34 ;- ' " ' maybe not needed
Extensions:= "mp3,wav,aac,aif" ;- some music extensions
clips :=""
Loop, %a_scriptdir%\*.*, 0, 1
{
If A_LoopFileExt in %Extensions%
clips .= s . A_LoopFileFullPath . s . "`r`n"
}
msgbox,%clips% ;- for test
; I didn't find commandline parameters for audacity , have you a link with examples ?
;run, "C:\Program Files (x86)\Audacity\audacity.exe\" %clips%
}
return
Who is online
Users browsing this forum: SimmoF and 227 guests