Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Can not get the IF statement to work



  • Please log in to reply
4 replies to this topic
MR2
  • New members
  • 2 posts
  • Last active: Oct 02 2015 08:02 PM
  • Joined: 01 Oct 2015
#M:: ;Sends commands to oracle to move from 10 Queue to 20 To move
ClipBoard = ; Clears ClipBoard
send {click 267,669}
send {up 1}
send {ENTER}
send {click 324,670}
send +{TAB}
send 10
send {TAB 1}
send ^c ;copy field to clipboard
sleep 1000
If (ClipBoard = Queue) {  ; Check to see if clipboard equals "Queue"
send {TAB 2} ; If so then preform the following
send T
send {TAB}
send !s
sleep, 2000
send {F4}
send {enter}
}
else { ; If not then perform the following
send +{TAB}
send 20
send {TAB 3}
send T
send {TAB}
send !s
sleep, 2000
send {F4}
send {enter}
}
ClipBoard = ; Clear Clipboard
return
 
 
On the above code everything seems to work fine except that the if statement is always true. If I write IF(ClipBoard = "Queue") then it is always false. Any ideas would be great and sorry that the script looks like this as I do not know why to copy it to here and make it look nice.


gilliduck
  • Members
  • 109 posts
  • Last active: Nov 09 2015 01:07 AM
  • Joined: 19 Dec 2013

Where is Queue defined?



Exaskryz
  • Members
  • 3249 posts
  • Last active: Nov 20 2015 05:30 AM
  • Joined: 23 Aug 2012
✓  Best Answer

I was going to say that using If (ClipBoard = "Queue") should work. So, what might be going on is whitespace characters being included in the copy and paste. I would guess, not knowing your program, that a "`n" and/oor "`r" character is being captured on the end of the string. Check using to make sure:

StringReplace, ClipBoard, ClipBoard, `n, LF|, 1 ; identifies newline or linefeed (LF) characters
StringReplace, ClipBoard, ClipBoard, `r, CR|, 1 ; identifies carriage return (CR) characters
StringReplace, ClipBoard, ClipBoard, `t, TAB|, 1 ; identifies tab characters
StringReplace, ClipBoard, ClipBoard, %A_Space%, SPACE|, 1 ; identifies space characters
MsgBox %ClipBoard%

This will detect if there's any whitespaces captured.



gilliduck
  • Members
  • 109 posts
  • Last active: Nov 09 2015 01:07 AM
  • Joined: 19 Dec 2013
My question was silly, disregard. Too much time spent staring at the computer to see what's in front of me.

MR2
  • New members
  • 2 posts
  • Last active: Oct 02 2015 08:02 PM
  • Joined: 01 Oct 2015

Thank you for that suggestion I ran it and did not come back with any special characters. I also copied the field that I need and then pasted that into my code so that I would pickup anything that I might have missed and yet it still does not change.

 

But I was able to find what was wrong. So I added a msgbox into the code so that I could see what was in the clipboard when the program ran. What I found was the send ^C was going off before I was in the field that I needed to be in so by adding a sleep 1000 to the code before the send ^c it give the program enough time to get into the field that I needed copied. working code below

 

#M:: ;Sends commands to oracle to move from 10 Queue to 20 To move
ClipBoard = ; Clears ClipBoard
send {click 267,669}
send {up 1}
send {ENTER}
send {click 324,670}
send +{TAB}
send 10
send {TAB 1}
sleep 1000
send ^c ;copy field to clipboard
sleep 1000
;msgbox %ClipBoard%   ; Added temp to see what it was picking before going to the next line
;keywait, enter, d
If (ClipBoard ="Queue"){  ; Check to see if clipboard equals "Queue"
send {TAB 2} ; If so then preform the following
send T
send {TAB}
send !s
sleep, 2000
send {F4}
send {enter}
}
else{ ; If not then perform the following
send +{TAB}
send 20
send {TAB 3}
send T
send {TAB}
send !s
sleep, 2000
send {F4}
send {enter}
}
ClipBoard = ; Clear Clipboard

return

 

Thanks for the idea to use the msgbox to see what was being copied.