jammzhentai450 Posted August 7, 2011 Posted August 7, 2011 (edited) Hi, i'm new to autoIT and i am trying to make an unlock tool for a rainmeter lockscreen. I have the code but the second section I want to happen when you click on the $Verify button, not straight away. Here's the code: #include <GUIConstantsEx.au3> $Action = IniRead ("Code.inc", "Action", "Action", "") opt("GUIOnEventMode", 1) $GUI = GUICreate("Unlocker",200,40) $Code = GuiCtrlCreateInput("1234" , 10, 10, 130, 20) $Verify = GuiCtrlCreateButton("Verify", 140,10,50,20) GUISetState(@SW_SHOW ;Run when verify button is clicked $Verify = IniRead ("UserVariables.inc", "Variables", "Code", "") if $Verify = StringCompare($Code, $Verify) then ShellExecute("refresh.exe", $Action) Exit Else $Fail = MsgBox (0, "Code Failed", "Wrong Code Sucka! This User is still locked!") if $Fail = 0 then Exit EndIf EndIf Any help would be appreciated. Thanks Edited August 7, 2011 by jammzhentai450
wakillon Posted August 7, 2011 Posted August 7, 2011 Try like this #include <GUIConstantsEx.au3> $Action = IniRead ("Code.inc", "Action", "Action", "") opt("GUIOnEventMode", 1) $GUI = GUICreate("Unlocker",200,40) GUISetOnEvent ( $GUI_EVENT_CLOSE, "_Close" ) $Code = GuiCtrlCreateInput("1234" , 10, 10, 130, 20) $Verify = GuiCtrlCreateButton("Verify", 140,10,50,20) GUICtrlSetOnEvent ( $Verify, '_FunctionName' );Run when verify button is clicked GUISetState(@SW_SHOW) While 1 Sleep ( 20 ) WEnd Func _FunctionName ( ) $Verify = IniRead ("UserVariables.inc", "Variables", "Code", "") if $Verify = StringCompare($Code, $Verify) then ShellExecute("refresh.exe", $Action) Exit Else $Fail = MsgBox (0, "Code Failed", "Wrong Code Sucka! This User is still locked!") if $Fail = 0 then Exit EndIf EndIf EndFunc Func _Close ( ) Exit EndFunc AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts
jammzhentai450 Posted August 7, 2011 Author Posted August 7, 2011 Thanks, Now I have to find a way to get the code to work. See ya
wakillon Posted August 7, 2011 Posted August 7, 2011 Thanks, Now I have to find a way to get the code to work. See yaWhat's not working ? AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts
jammzhentai450 Posted August 7, 2011 Author Posted August 7, 2011 (edited) What's not working ? oh, the bit where the code verifies against a file which has the code. I get the msgbox even when I have the right code. Here's the code the problem lies inbetween the two green lines #include <GUIConstantsEx.au3> $Action = IniRead ("Code.inc", "Action", "Action", "") $Compare = IniRead ("UserVariables.inc", "Variables", "Code", "") opt("GUIOnEventMode", 1) $GUI = GUICreate("Unlocker",200,40) GUISetOnEvent ( $GUI_EVENT_CLOSE, "_Close" ) $Code = GuiCtrlCreateInput("" , 10, 10, 130, 20) $Verify = GuiCtrlCreateButton("Verify", 140,10,50,20) GUICtrlSetOnEvent ( $Verify, '_FunctionName' );Run when verify button is clicked GUISetState(@SW_SHOW) While 1 Sleep ( 20 ) WEnd ;--------------------------------------------------------------------- Func _FunctionName ( ) $CompareCodes = StringCompare($Code, $Compare) if $CompareCodes = "0" Then ShellExecute("refresh.exe", $Action) Exit Else $Fail = MsgBox (0, "Code Failed", "Wrong Code Sucka! This User is still locked!") if $Fail = 0 then Exit EndIf EndIf EndFunc ;-------------------------------------------------------------------- Func _Close ( ) Exit EndFunc Edited August 7, 2011 by jammzhentai450
wakillon Posted August 7, 2011 Posted August 7, 2011 Try this ! #include <EditConstants.au3> #include <GUIConstantsEx.au3> $Action = IniRead ("Code.inc", "Action", "Action", "") $Compare = IniRead ("UserVariables.inc", "Variables", "Code", "") opt("GUIOnEventMode", 1) $GUI = GUICreate("Unlocker",200,40) GUISetOnEvent ( $GUI_EVENT_CLOSE, "_Close" ) $Code = GuiCtrlCreateInput("" , 10, 10, 130, 20, $ES_PASSWORD ) ; $ES_PASSWORD show asterix for each character typed into the Input control. $Verify = GuiCtrlCreateButton("Verify", 140,10,50,20) GUICtrlSetOnEvent ( $Verify, '_FunctionName' );Run when verify button is clicked GUISetState(@SW_SHOW) While 1 Sleep ( 20 ) WEnd Func _FunctionName ( ) If GUICtrlRead ( $Code ) = $Compare Then ; or use == for case sensitive. ShellExecute("refresh.exe", $Action) Exit Else GUICtrlSetData ( $Code, '' ) $Fail = MsgBox (0, "Code Failed", "Wrong Code Sucka! This User is still locked!") If $Fail = 0 Then Exit EndIf EndFunc Func _Close ( ) Exit EndFunc AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now