I don't have much experience in creating an interface (Gui), I tried to create a password blocker to avoid using another existing program, but I removed the return to automatically close after 15 seconds (or almost).
It works 9 or 10 times, so the "Close", "Escape", "Send" buttons no longer work.
I assume it's my mistake, I made a simplified version to understand:
Code: Select all
#SingleInstance Force
exeTarget := "notepad.exe"
;CFG_INI := RegExReplace(A_ScriptName, "\.[^.]*$")
;MsgBox % CFG_INI
;IniWrite, main, %CFG_INI%.ini, Section, Value
Standby:
PWTry = 0
Loop
{
IfWinExist, ahk_exe %exeTarget%
{
Break
}
Sleep 100
}
Authentic:
Gui,2: Destroy
Gui,2: -MinimizeBox +LastFound +Owner -dpiscale
Gui,2: Add, Edit, w120 h20 x8 y9 Password vPword
Gui,2: Add, Button, w32 h22 x132 y8 +Default gChkPW vVOK, OK
Gui,2: Show, w172 h38 Center, Your Password:, nohide
Loop, 400
{
IfWinActive, ahk_exe %exeTarget%
{
; --------- Only Executable
If A_IsCompiled
{
WinActivate, ahk_exe %A_ScriptName%
}
else
{
WinActivate, Your Password:
}
;GuiControl,2: Focus, VOK
GuiControl,2: Text, VOK, "PWTry"
GuiControl,2: Focus, Pword
}
Sleep, 10
}
Goto CloseExe
2GuiClose:
Goto CloseExe
2GuiEscape:
Goto CloseExe
ChkPW:
Gui,2: Submit
; --------- Sample Master Password
If (Pword == "@lfa")
{
Goto AllowedExe
}
If (PWTry > 20)
{
Goto CloseExe
}
PWTry++
Goto Authentic
AllowedExe:
Gui,2: Destroy
Loop
{
; --------- Wait Close
IfWinNotExist, ahk_exe %exeTarget%
{
Break
}
Sleep 100
}
Goto Standby
CloseExe:
Gui,2: Destroy
WinClose, ahk_exe %exeTarget%
Goto Standby