coolness Posted May 22, 2006 Share Posted May 22, 2006 This code will work to open notepad when 1 is pressed. But what I'm looking for is the code that will open it, when 1 or 2 is pressed. ; Loop around until the user gives a valid "autoit" answer $bLoop = 1 While $bLoop = 1 $text = InputBox("test", "enter""1"" in this box, and press enter. to open notepad") If @error = 1 Then exit Else ; They clicked OK, but did they type the right thing? If $text <> "1" Then MsgBox(4096, "Error", "You typed in the wrong thing - try again!") Else $bLoop = 0 ; Exit the loop - ExitLoop would have been an alternative too EndIf EndIf WEnd run("notepad.exe") sleep(600) send("success") here is the code, that I tryed, for 1 and 2 to both work. ; Loop around until the user gives a valid "autoit" answer $bLoop = 2 While $bLoop = 2 $text = InputBox("test", "enter""1"" in this box, and press enter. to open notepad") If @error = 2 Then exit Else ; They clicked OK, but did they type the right thing? If $text <> "1" Then MsgBox(4096, "Error", "You typed in the wrong thing - try again!") EndIf EndIf WEnd run("notepad.exe") sleep(600) send("sucess") $bLoop = 0 ; Exit the loop - ExitLoop would have been an alternative too else $bLoop = 2 While $bLoop = 2 $text = InputBox("test", "enter""2"" in this box, and press enter. to open notepad") If @error = 2 Then exit Else ; They clicked OK, but did they type the right thing? If $text <> "1" Then MsgBox(4096, "Error", "You typed in the wrong thing - try again!") Else $bLoop = 0 ; Exit the loop - ExitLoop would have been an alternative too EndIf EndIf WEnd run("notepad.exe") sleep(600) send("sucess") ;end of script But it didn't work. Could someone please let me know what I'm doing wrong? thanks I would appreciate it. Link to comment Share on other sites More sharing options...
coolness Posted May 22, 2006 Author Share Posted May 22, 2006 pleas help if you can. Link to comment Share on other sites More sharing options...
bucky002 Posted May 22, 2006 Share Posted May 22, 2006 Eh, I would explain to you what you did wrong, but I got to go. Just compare my script and yours. I think I made it like what you wanted. $bLoop = 1 $text = InputBox("test", "enter""1"" in this box, and press enter. to open notepad") If @error = 1 Then Exit EndIf ; They clicked OK, but did they type the right thing? If $text = $bLoop Then Run("notepad.exe") Sleep(600) Send("success") ElseIf $text Then MsgBox(4096, "Error", "You typed in the wrong thing - try again!") Exit EndIf Link to comment Share on other sites More sharing options...
coolness Posted May 22, 2006 Author Share Posted May 22, 2006 [That did not work. Could someone please help? Link to comment Share on other sites More sharing options...
Paulie Posted May 22, 2006 Share Posted May 22, 2006 Do you really wanna use inputboxes here? have you loooked into hotKeyset? HotKeySet("1", "Execute") HotkeySet("2", "Execute") While 1 Sleep(100) Wend Func Execute() Run("Notepad.exe") EndFunc Or, if you really want the inputboxes, $answer = InputBox("Type"," Type 1 or 2 here to open notepad") If $answer = 1 then Run("Notepad.exe") If $answer = 2 then Run("Notepad.exe") If Not $answer = 1 then MsgBox(0,"WRONG","You Typed the wrong thing") If Not $answer = 2 then MsgBox(0,"WRONG","You Typed the wrong thing") Link to comment Share on other sites More sharing options...
herewasplato Posted May 22, 2006 Share Posted May 22, 2006 (edited) Do you really wanna use inputboxes here? have you loooked into hotKeyset? HotKeySet("1", "Execute") HotkeySet("2", "Execute") While 1 Sleep(100) Wend Func Execute() Run("Notepad.exe") EndFunc Or, if you really want the inputboxes, $answer = InputBox("Type"," Type 1 or 2 here to open notepad") If $answer = 1 then Run("Notepad.exe") If $answer = 2 then Run("Notepad.exe") If Not $answer = 1 then MsgBox(0,"WRONG","You Typed the wrong thing") If Not $answer = 2 then MsgBox(0,"WRONG","You Typed the wrong thing")You might try:$answer = InputBox("Type", " Type 1 or 2 here to open notepad") If $answer = 1 Or $answer = 2 Then Run("Notepad.exe") If $answer <> 1 And $answer <> 2 Then MsgBox(0, "WRONG", "You typed the wrong thing.")oÝ÷ ØGb´êÚºÚ"µÍÌÍØ[ÝÙH[]Þ ][ÝÕI][ÝË ][ÝÈHHÜHÈÜ[ÝY ][ÝÊBY ÌÍØ[ÝÙHHÜ ÌÍØ[ÝÙH[[ ][ÝÓÝY^I][ÝÊB[ÙBÙÐÞ ][ÝÕÔÓÉ][ÝË ][ÝÖ[ÝHYHÜÛÈ[É][ÝÊB[Y Edited May 22, 2006 by herewasplato [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
bucky002 Posted May 22, 2006 Share Posted May 22, 2006 (edited) I thought you wanted it to work when "1" was pressed, but I didn't understand from your first post you wanted 1 AND 2. How about this? $One = 1 $Two = 2 $text = InputBox("test", "enter""1"" in this box, and press enter. to open notepad") If @error = 1 Then Exit EndIf ; They clicked OK, but did they type the right thing? If $text = $One Then Run("notepad.exe") Sleep(600) Send("success") ElseIf $text = $Two Then Run("notepad.exe") Sleep(600) Send("success") Else MsgBox(4096, "Error", "You typed in the wrong thing - try again!") Exit EndIf Edited May 22, 2006 by bucky002 Link to comment Share on other sites More sharing options...
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