 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
iguru42
Joined: 02 Sep 2008 Posts: 49
|
Posted: Wed Feb 03, 2010 1:10 pm Post subject: Problems modifying if else.... |
|
|
So I have the following code in one of my scripts, it was working perfectly until they changed a page and now in certain conditions the color at 1137, 208 can also be FBF5F0 and if that happens I need to click 1168, 238, and I'm having problems working it out. It seems so damn simple but I'm not getting it.
| Code: | pixelgetcolor, color, 1137, 208
sleep 200
if (Color = 0xCC9966)
{
Click 1168, 208
}
else
{
Click 1137, 208
}
|
Is this valid? It's just a wild assed guess on my part.
| Code: | pixelgetcolor, color, 1137, 208
sleep 200
if (Color = 0xFBF5F0)
{
Click 1168, 238
}
if (Color = 0xCC9966)
{
Click 1168, 208
}
else
{
Click 1137, 208
}
|
|
|
| Back to top |
|
 |
Szillard Guest
|
Posted: Wed Feb 03, 2010 1:54 pm Post subject: |
|
|
Not sure, but you might need extra 'else':
| Code: | pixelgetcolor, color, 1137, 208
sleep 200
if (Color = 0xFBF5F0)
{
Click 1168, 238
}
else if (Color = 0xCC9966)
{
Click 1168, 208
}
else
{
Click 1137, 208
}
| [/code] |
|
| Back to top |
|
 |
randallf
Joined: 06 Jul 2009 Posts: 678
|
Posted: Wed Feb 03, 2010 3:20 pm Post subject: |
|
|
The color won't ever be two values:
| Code: | pixelgetcolor, color, 1137, 208
sleep 200
if (Color = 0xFBF5F0) ;if color
{
Click 1168, 238 ;fire click
}
if (Color = 0xCC9966) ;won't ever fire if the first one does
{
Click 1168, 208
}
else
{
Click 1137, 208 ;won't ever fire if the first one does, will if the second one doesn't
} |
In my experience, avoid:
| Code: | if (Color = 0xFBF5F0) ;if color
{
Click 1168, 238 ;fire click
}
if (Color = 0xCC9966) ;won't ever fire if the first one does
{
Click 1168, 208
} |
Use this when using no-true brace (standard? ? ) styling:
| Code: |
if (Color = 0xFBF5F0) ;if color
{
Click 1168, 238 ;fire click
}
if (Color = 0xCC9966) ;won't ever fire if the first one does
{
Click 1168, 208
} |
If that doesn't work add some msgbox's to make sure what value 'color' is. |
|
| Back to top |
|
 |
sinkfaze
Joined: 18 Mar 2008 Posts: 5043 Location: the tunnel(?=light)
|
Posted: Wed Feb 03, 2010 3:54 pm Post subject: |
|
|
Really for one-line branches you don't even need the braces or parentheses unless you really want them:
| Code: | pixelgetcolor, color, 1137, 208
Sleep 200
if Color = 0xFBF5F0
Click 1168, 238
if Color = 0xCC9966
Click 1168, 208
else
Click 1137, 208 |
_________________ Try Quick Search for Autohotkey or see the tutorial for newbies. |
|
| Back to top |
|
 |
answer4u Guest
|
Posted: Wed Feb 03, 2010 4:47 pm Post subject: |
|
|
... and if you wanna sacrifice readability ... | Code: | pixelgetcolor, color, 1137, 208
Sleep 200
Click, % Color = "0xFBF5F0" ? "1168, 238" : ( Color = "0xCC9966" ? "1168, 208" : "1137, 208" ) |
|
|
| Back to top |
|
 |
sinkfaze
Joined: 18 Mar 2008 Posts: 5043 Location: the tunnel(?=light)
|
|
| Back to top |
|
 |
answer4u Guest
|
Posted: Wed Feb 03, 2010 5:22 pm Post subject: |
|
|
| sinkfaze wrote: | | I don't think Click supports expressions, unless I missed it on an update. You could do it with MouseClick, though. |
Interesting ... it think it might mean that Click doesn't support expressions like the other Commands, since its parameters are dynamic. For instance, the following works fine on my computer: | Code: | CoordMode, Mouse, Screen
x := 256
y := 1188
Click, % x "," y |
However, this throws an error: | Code: | CoordMode, Mouse, Screen
x := 256
Click, %x%, % 594*2 | ... and the following is no good at all : | Code: | CoordMode, Mouse, Screen
x := 256
Click, % x, 1188 |
|
|
| Back to top |
|
 |
randallf
Joined: 06 Jul 2009 Posts: 678
|
Posted: Wed Feb 03, 2010 5:29 pm Post subject: |
|
|
| Code: | CoordMode, Mouse, Screen
x := 256
y := 1188
Click, % x "," y |
As I understand it % forces an expression, just as if you were using the assignment operator :=
So since % x "," y (which to me seems to be a valid epxression?) works...
PostPosted: Wed Feb 03, 2010 5:22 pm Post subject:
sinkfaze wrote:
I don't think Click supports expressions, unless I missed it on an update. You could do it with MouseClick, though.
Interesting ... it think it might mean that Click doesn't support expressions like the other Commands, since its parameters are dynamic. For instance, the following works fine on my computer:
Code:
CoordMode, Mouse, Screen
x := 256
y := 1188
Click, % x "," y
| Code: |
Click, %x%, % 594*2
Click, % x, 1188 |
Simply not valid expressions, mixes of command syntax and expression operators.
So to me it seems that Click can accept an expression, but not an expression as an operator.
If I am incorrect in my thinking please correct me, trying to understand this exactly
Does this work?
| Code: | | Click, % x . "," . y |
|
|
| Back to top |
|
 |
sinkfaze
Joined: 18 Mar 2008 Posts: 5043 Location: the tunnel(?=light)
|
Posted: Wed Feb 03, 2010 5:44 pm Post subject: |
|
|
Huh! You're right answer4u. The language in the manual for Click explicitly states that it does not support expressions, but I'm not sure whether that would necessarily be a flaw in the documentation or not since you wouldn't want people to experiment with forcing an expression in a way that is non-intuitive compared to other commands. _________________ Try Quick Search for Autohotkey or see the tutorial for newbies. |
|
| Back to top |
|
 |
Guest
|
Posted: Wed Feb 03, 2010 5:48 pm Post subject: |
|
|
| as i remember, one of the pros here mention Click is actually one parameter command, thats why Click, % something will work |
|
| Back to top |
|
 |
answer4u Guest
|
Posted: Wed Feb 03, 2010 5:52 pm Post subject: |
|
|
| randallf wrote: | Simply not valid expressions, mixes of command syntax and expression operators.
So to me it seems that Click can accept an expression, but not an expression as an operator.
If I am incorrect in my thinking please correct me, trying to understand this exactly |
What I was getting at with "dynamic parameters" is click seems to work with a single expression, but not multiple expression parameters - ie: | Code: | Click, % <expression> ; works
Click, % <expression, % <expression> ; doesn't work |
|
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|