Hi!
As a kind of joke to my little sister ( she's 8 ) I told her that I would keep her from installing anything on her computer until my dad entered a password. (Yes, she installs a bunch of random stuff.) I came up with this, but after I correctly enter the password, it seems to just go idle. No new setups are detected, etc.
Can anyone spot something wrong with this?
Code:
;
; AutoHotkey Version: 1.x
; Language: English
; Platform: Win9x/NT
; Author: A.N.Other <myemail@nowhere.com>
;
; Script Function:
; Template script (you can customize this template by editing "ShellNew\Template.ahk" in your Windows folder)
;
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
SetBatchLines, -1
SetTimer, EmptyMem, 60000
WatchListCount = 2
WatchList[1] = setup.exe
WatchList[2] = msiexec.exe
Loop ; Keep repeating the checks
{
Loop %WatchListCount% ; Check for each in the list
{
Gui, Destroy
CurrentItem := WatchList[%A_Index%]
; MsgBox, %CurrentItem%
Process, Exist, %CurrentItem%
ErrorLevelDump = %ErrorLevel%
If ( ErrorLevel <> 0 ) ; ErrorLevel is not blank or zero
{
WinGetTitle, InstallTitle, ahk_pid %ErrorLevelDump%
TextCenter := A_ScreenWidth-50
Gui +AlwaysOnTop -SysMenu +Owner
Menu, Tray, NoIcon
Gui, Font, s20
Gui, Add, Text, Center W%TextCenter%, Install Detected!`nA password is required to continue! ; 20 px margin on each side
Gui, Add, Edit, Center W%TextCenter% +Password vPassword,
Gui, Add, Button, Center W%TextCenter% gSubmit, Authorize
Gui, Add, Text, Center W%TextCenter%, Installation Window Title: %InstallTitle%
Gui, Show, W%A_ScreenWidth% H%A_ScreenHeight% NoActivate, Install Detected!
return
Submit:
Gui, Submit
Gui, Destroy
If (Password = "password")
{
MsgBox, Password Correct! The installation may continue.
}
else
{
Gui +AlwaysOnTop -SysMenu +Owner
Menu, Tray, NoIcon
Gui, Font, s20 cRed
Gui, Add, Text, Center W%TextCenter%, Password Incorrect! ; 20 px margin on each side
Gui, Font, s20 cBlack
Gui, Add, Text, Center W%TextCenter%, Install Detected!`nA password is required to continue! ; 20 px margin on each side
Gui, Add, Edit, Center W%TextCenter% +Password vPassword,
Gui, Add, Button, Center W%TextCenter% gSubmit, Authorize
Gui, Add, Text, Center W%TextCenter%, Installation Window Title: %InstallTitle%
Gui, Show, W%A_ScreenWidth% H%A_ScreenHeight% NoActivate, Install Detected!
}
return
}
}
}
EmptyMem:
EmptyMem()
SetTimer, EmptyMem, 60000
return
All criticism welcomed, I'm new to AutoHotKey.