Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #SingleInstance, Force
- /*
- Brad, I wrote this scirpt because I am under the impression that it is what you are looking for, if this is not what you
- need let me know and i'll have a closer look
- */
- ;I assume that "admin", "bwsr", "crs" etc are litterial text
- ; if that is true, when you do a if statement that has () around what you are testing, the text needs to have quotes
- ; if(The_Info_Stored_In_My_Variable = "Litterial text")
- ;I assume that when you have a if statement with () and the variables have %% around them, you don't mean that you are
- ; checking for the name of a variable stored in those variables. If that is the case it should be like this.
- ;if(Var1 = Var2)
- ;Some things in AutoHotkey are not very straight forward, variables are one of them, and it will take time to know the ins and outs.
- ;Ok here is a dummy script that I think covers what you are trying to do. I am using my own values,
- ;so you would have to take how I do this and edit it for your own use
- ;List of vars used later:
- Var1:= "Some random value 1"
- Var2:= "Some random value 2"
- Var3:= 1234 ;real numbers not text
- Var4:= 5678
- :C:Ryan::
- i:= 0 ; This Variable will track how many times we have looped.
- Loop 2
- {
- InputBox,User_Input,Getting User Input, Please enter your info
- Sleep, 100
- Msgbox, % User_Input
- ;I don't know if you want case senstive or not. if you want case sensitive then in the if statement use == if not use =
- ;because I don't know what you want, I am going with it not mattering how it is entered (Not case sensitive).
- if(User_Input = "admin")
- {
- Output := "The output for this is 0001" ;setting the output, can be w/e you want
- msgbox, The Variable "Output" now has a value of `n`n%Output%`n`nThe loop will now exit.
- break ;because we found what we wanted we will exit the loop
- }
- else if(User_Input = "bwsr")
- {
- Output := "The output for this is 0002" ;setting the output, can be w/e you want
- msgbox, The Variable "Output" now has a value of `n`n%Output%`n`nThe loop will now exit.
- break ;because we found what we wanted we will exit the loop
- }
- else if(User_Input = "crs")
- {
- Output := "The output for this is 0003" ;setting the output, can be w/e you want
- msgbox, The Variable "Output" now has a value of `n`n%Output%`n`nThe loop will now exit.
- break ;because we found what we wanted we will exit the loop
- }
- ;This next part will show how to compare the user input to the value of variables. I have placed the vars near the top of the script
- else if(User_Input = Var1)
- {
- Output := "The output for this is 0004" ;setting the output, can be w/e you want
- msgbox, The Variable "Output" now has a value of `n`n%Output%`n`nThe loop will now exit.
- break ;because we found what we wanted we will exit the loop
- }
- else if(User_Input = Var2)
- {
- Output := "The output for this is 0005" ;setting the output, can be w/e you want
- msgbox, The Variable "Output" now has a value of `n`n%Output%`n`nThe loop will now exit.
- break ;because we found what we wanted we will exit the loop
- }
- else if(User_Input = Var3)
- {
- Output := "The output for this is 0006" ;setting the output, can be w/e you want
- msgbox, The Variable "Output" now has a value of `n`n%Output%`n`nThe loop will now exit.
- break ;because we found what we wanted we will exit the loop
- }
- else if(User_Input = Var4)
- {
- Output := "The output for this is 0007" ;setting the output, can be w/e you want
- msgbox, The Variable "Output" now has a value of `n`n%Output%`n`nThe loop will now exit.
- break ;because we found what we wanted we will exit the loop
- }
- ; Now that we are done all the tests, if the loop has not been broken by now we will pop up a message saying to retry.
- ; I have set the loop to go twice, if after the second try we will show another message saying that they need to relaunch this to try again.
- ;The way I will set this up is by making a variable the has one added to it each time it goes through this, and depending on the value of that
- ; variable, it will show the message that goes along with what is happening.
- i++ ;Adding 1 to the value of "i"
- if(i=1)
- {
- msgbox, Your input didn't match what we were looking for.`nYou will now be brought back to the beginning to try again.
- }
- else if(i = 2)
- {
- msgbox, Your input didn't match twice now.`nPlease contact so and so, or run the script again.`n`nThis part of the script will now exit.
- }
- }
- MsgBox, we are now outside that part of the script. `n`nYou can do w/e you need to from here.
- return
- esc::ExitApp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement