AutoHotkey Community

It is currently May 27th, 2012, 2:13 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 11 posts ] 
Author Message
PostPosted: February 3rd, 2010, 2:10 pm 
Offline

Joined: September 2nd, 2008, 4:20 pm
Posts: 50
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                                                               
               }


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 3rd, 2010, 2:54 pm 
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]


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 3rd, 2010, 4:20 pm 
Offline

Joined: July 6th, 2009, 9:58 pm
Posts: 678
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 3rd, 2010, 4:54 pm 
Offline
User avatar

Joined: March 19th, 2008, 12:43 am
Posts: 5480
Location: the tunnel(?=light)
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

_________________
Image
Try Quick Search for Autohotkey or see the tutorial for newbies.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 3rd, 2010, 5:47 pm 
... and if you wanna sacrifice readability ...
Code:
pixelgetcolor, color, 1137, 208
Sleep 200
Click, % Color = "0xFBF5F0" ? "1168, 238" : ( Color = "0xCC9966" ? "1168, 208" : "1137, 208" )


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 3rd, 2010, 5:50 pm 
Offline
User avatar

Joined: March 19th, 2008, 12:43 am
Posts: 5480
Location: the tunnel(?=light)
I don't think Click supports expressions, unless I missed it on an update. You could do it with MouseClick, though.

_________________
Image
Try Quick Search for Autohotkey or see the tutorial for newbies.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 3rd, 2010, 6:22 pm 
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 :shock: :
Code:
CoordMode, Mouse, Screen
x := 256
Click, % x, 1188


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 3rd, 2010, 6:29 pm 
Offline

Joined: July 6th, 2009, 9:58 pm
Posts: 678
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 3rd, 2010, 6:44 pm 
Offline
User avatar

Joined: March 19th, 2008, 12:43 am
Posts: 5480
Location: the tunnel(?=light)
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.

_________________
Image
Try Quick Search for Autohotkey or see the tutorial for newbies.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 3rd, 2010, 6:48 pm 
as i remember, one of the pros here mention Click is actually one parameter command, thats why Click, % something will work


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 3rd, 2010, 6:52 pm 
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


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Google Feedfetcher, nimda, poserpro, rbrtryn, sjc1000, Yahoo [Bot] and 15 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group