Jump to content

Recommended Posts

Posted

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

  • Developers
Posted

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

<{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.
  :)

Posted (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 by Burrup

qq

Posted

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]

Posted

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?

Posted

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

Posted (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 by Burrup

qq

Posted (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.

HotKeySet("{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 by CrewXp
Posted

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

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...