Sign in to follow this  
Followers 0
coolness

Problem with scripting inputbox. want it to run, when 1 or 2 is pressed, then ok.

7 posts in this topic

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 :D

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.

Share this post


Link to post
Share on other sites



pleas help if you can.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

[That did not work. Could someone please help?

Share this post


Link to post
Share on other sites

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")

Share this post


Link to post
Share on other sites

#6 ·  Posted (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 by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

#7 ·  Posted (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 by bucky002

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0