With this instruction the button disappears completely .: Gui Add, Button, hidden vButtOK, OK!
A small test program
Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#SingleInstance force
; GUI Window
Gui 1: +AlwaysOnTop hwndGuiHwnd ; This option stores the window handle (HWND) of the GUI in OutputVar (GuiHwnd)
Gui 1: Default
Gui 1: Color, white
; Input
Gui 1: Font, cBlack s12 Normal, Verdana
Gui 1: Add, Text, x35 y80 h20 w120 vUserTxt1, Numbers .:
Gui 1: Font, cBlue s16 Bold, Verdana
Gui 1: Add, Edit, xp+100 yp-10 w65 h30 Limit3 Number +Center vInp gInputVal,
; Result1
Gui 1: Font, cBlue s14 Bold, Verdana
Gui 1: Add, Text, x35 yp+50 w200 h30 +Center vResult1
; Button
Gui 1: Font, s18 Bold, Arial
Gui 1: Add, Button, x150 y200 h40 w100 +Center Hidden vButtOK, OK!
Gui 1: Show, x40 y100 h260 w300, Test GUI
Return
InputVal:
Gui 1: Submit, NoHide
Return
#If WinActive( "ahk_id " GuiHwnd )
~NumpadEnter::
~Enter::
; https://www.autohotkey.com/boards/viewtopic.php?f=76&t=73402
; idea from Hellbent
GuiControlGet FocusOn, FocusV
; If focus on the field "inp"
if ( FocusOn = "Inp" )
{ MsgBox ,, Row.: %A_LineNumber% -> %A_ScriptName%, The Focus is on ( %Inp% )
If ( Inp = 123 )
{ GuiControl 1: Show, ButtOK
MsgBox ,, Row.: %A_LineNumber% -> %A_ScriptName%, Number %Inp% is correct!
}
else
{
MsgBox ,, Row.: %A_LineNumber% -> %A_ScriptName%, Wrong input! ( %InputVal% )
GuiControl 1:, Inp
}
Return
}
#If
GuiClose:
GuiContextMenu:
MsgBox
*Esc::
ExitApp
Return