CrewXp Posted April 14, 2005 Posted April 14, 2005 How do I specify multiple statements in a IF statement? I want the program to do a certain thing if $name = a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y, or z If not (Else), then it does something. I know how to do the rest. I just don't know how to tell If to look for the 26 letters. Thx
sylvanie Posted April 14, 2005 Posted April 14, 2005 hello, just for this case, you can use this way : $dec=asc($name) if $dec>=97 or $dec<=122 then
Developers Jos Posted April 14, 2005 Developers Posted April 14, 2005 How do I specify multiple statements in a IF statement?I want the program to do a certain thing if $name = a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y, or zIf not (Else), then it does something. I know how to do the rest. I just don't know how to tell If to look for the 26 letters. Thx<{POST_SNAPBACK}>one way is:If StringInStr("|a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z|", "|" & $name & "|") then ; true Else ; false EndIf SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
buzz44 Posted April 14, 2005 Posted April 14, 2005 (edited) #include <GUIConstants.au3> GUICreate("Test", 320,120, @DesktopWidth/2-160, @DesktopHeight/2-45, -1, $name = GUICtrlCreateInput ( "", 10, 5, 300, 20) GUISetState () $test = StringSplit("a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z",",") While 1 For $i = 1 To $test[0] If GUICtrlRead($name) = $test[$i] Then ;Insert Code Here EndIf Next Wend Edit: Always one step ahead JdeB lol. Edited April 14, 2005 by Burrup qq
sylvanie Posted April 14, 2005 Posted April 14, 2005 oops sorry, it's : $dec=asc($name) if $dec>=97 and $dec<=122 then
MSLx Fanboy Posted April 14, 2005 Posted April 14, 2005 If you can accept numbers as well, StringIsAlNum() would work too Writing AutoIt scripts since _DateAdd("d", -2, _NowCalcDate())
zcoacoaz Posted April 15, 2005 Posted April 15, 2005 thats not really what he meant... To have multiple ways for it to be true then do something like this $Var = 9 $UglyVar = 25987235923857092385 If $UglyVar = 1 Or $Var = 9 Then MsgBox ( 0, 'aoskjfhkajs', 'sljdfhaslkdjf' ) [font="Times"] If anyone remembers me, I am back. Maybe to stay, maybe not.----------------------------------------------------------------------------------------------------------[/font][font="Times"]Things I am proud of: Pong! in AutoIt | SearchbarMy website: F.R.I.E.S.A little website that is trying to get started: http://thepiratelounge.net/ (not mine)[/font][font="Times"] ----------------------------------------------------------------------------------------------------------[/font][font="Arial"]The newbies need to stop stealing avatars!!! It is confusing!![/font]
CrewXp Posted April 19, 2005 Author Posted April 19, 2005 I have this, but a problem HotKeySet("{F6}", "_222Customt") Func _222Customt() $alpha = 1 $name = 1 While $alpha = 1 Send("^a") Sleep(50) Send("{END}") Sleep(50) Send("{SHIFTDOWN}") Sleep(50) Send("{LEFT}") Sleep(50) Send("{SHIFTUP}") Sleep(200) Send("^c") Sleep(200) Send("^c") Sleep(200) Send("^c") Sleep(200) $name = ClipGet() MsgBox(0, "Value of $name is:", $name) If $name = StringSplit("a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z",",") then Exit Else Send("{DEL}") EndIf WEnd EndFunc ;==>_Exit It deletes the characters at the end of the text in teh text box because it's not a letter. Its a space or a blank line. But when it finds the letters it's supposed to, it doesn't stop like its supposed to. It tells me it copied one of those letters in the msgbox i made, but it keeps going. Whats wrong?
Developers Jos Posted April 19, 2005 Developers Posted April 19, 2005 If $name = StringSplit("a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z",",") then Exit<{POST_SNAPBACK}>This isn't a correct statement........ SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
CrewXp Posted April 19, 2005 Author Posted April 19, 2005 How can I correct it then... I want it to be If $name = a or b or c or... so on. I've tried every one of the above, but I dont think I'm doing it righ
Ejoc Posted April 19, 2005 Posted April 19, 2005 Burrup's example should work just fine Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs
buzz44 Posted April 20, 2005 Posted April 20, 2005 (edited) Burrup's example should work just fine<{POST_SNAPBACK}>Correct, I have now commented it for you.#include <GUIConstants.au3> GUICreate("Test", 320,120, @DesktopWidth/2-160, @DesktopHeight/2-45, -1, $name = GUICtrlCreateInput ( "", 10, 5, 300, 20) GUISetState () $test = StringSplit("a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z",",") While 1 ;$test[0] contains the number or string above which is 26, the alphabet ;$test[1] is the first string, which is letter "a" ;$test[2] is the second string, which is letter "b", 3 = "c", 4 = "d" and so on... ; so below we start the count at $i = 1, because its the first letter, and we go ;"to" $test[0] which is how many there are For $i = 1 To $test[0] ; It now checks the input box to see if any letters are in the input box If GUICtrlRead($name) = $test[$i] Then ;Insert Code Here ;If it finds any letter it will do the where "Insert code here" is located EndIf Next Wend Edited April 20, 2005 by Burrup qq
CrewXp Posted April 20, 2005 Author Posted April 20, 2005 (edited) I tested the script and it works great! When I type a letter in the GUI, it exits like I told it to. But I don't need a GUI. I need the things to be done in the program. But again... It doesn't work. expandcollapse popupHotKeySet("{ESC}", "_Exit") Func _Exit() Exit EndFunc;==>_Exit HotKeySet("{F2}", "_2Exit") Func _2Exit() #include <GUIConstants.au3> $name = 1 ;While $alpha = 1 Send("^a") Sleep(50) Send("{END}") Sleep(50) Send("{SHIFTDOWN}") Sleep(50) Send("{LEFT}") Sleep(50) Send("{SHIFTUP}") Sleep(200) Send("^c") Sleep(200) Send("^c") Sleep(200) Send("^c") Sleep(200) $name = ClipGet() ;GUICreate("Test", 320,120, @DesktopWidth/2-160, @DesktopHeight/2-45, -1,) ;$name = GUICtrlCreateInput ( "", 10, 5, 300, 20) ;GUISetState () $test = StringSplit("a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z",",") While 1 ;$test[0] contains the number or string above which is 26, the alphabet ;$test[1] is the first string, which is letter "a" ;$test[2] is the second string, which is letter "b", 3 = "c", 4 = "d" and so on... ; so below we start the count at $i = 1, because its the first letter, and we go ;"to" $test[0] which is how many there are For $i = 1 To $test[0] ; It now checks the input box to see if any letters are in the input box If $name = $test[$i] Then ;Insert Code Here Exit MsgBox(0, "WORKNumber of People in the box: ", $name) Else ;Else Code Here MsgBox(0, "Number of People in the box: ", $name) Send("{DEL}") Send("{SHIFTDOWN}") Sleep(50) Send("{LEFT}") Sleep(50) Send("{SHIFTUP}") Sleep(200) Send("^c") Sleep(200) Send("^c") Sleep(200) Send("^c") Sleep(200) $name = ClipGet() ;Send("{DEL}") ;If it finds any letter it will do the where "Insert code here" is located EndIf Next Wend EndFunc;==>_Exit While 1 Wend As you can tell from above, if it selects a letter, it should stop. But if it isn't a letter (a space or return charcter), then it keeps deleting those characters until it finds a letter. Here is what I am working with, except its lower-case: Edited April 20, 2005 by CrewXp
buzz44 Posted April 21, 2005 Posted April 21, 2005 I think you will have to use WinGetText () so you can first get the text of the window if it isnt a GUI one. Then you can split up what it returns. qq
CyberSlug Posted April 21, 2005 Posted April 21, 2005 What exactly are you trying to do?If you are just trying to remove white space from a bunch of text, I recommend copying the text into a text editor (such as SciTe or TextPad that supports regular expression searchs and replacements. Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
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