AutoHotkey Community

It is currently May 26th, 2012, 11:49 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: November 11th, 2009, 10:03 pm 
Hey guys,
i have set up a macro using PixelGetColor.
script works, but its only and evey time doing the ELSE action [no matter if the statement is tru/false], and i cant figure what did i mess up.
any help please?
[its only a part of the script, and i`ll loop it, but left the loop part,and others out,untill i figure this one]

here is the code:
Code:
m::
{
PixelGetColor, color1, 78,360
if color1=0x9B8363
Sleep 10000

else
{
Send {2 down}
Sleep 50
Send {2 up}
Sleep 100
Send {LButton down}
Sleep 50
Send {Lbutton up}
Sleep 5000
}
}
return


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 11th, 2009, 10:07 pm 
Offline

Joined: December 24th, 2008, 3:25 am
Posts: 1401
Location: :noitacoL
Try these changes in 'red' and see if it helps
Code:

m::
PixelGetColor, color1, 78,360
if (color1 = 0x9B8363)
{
Sleep 10000
;your only action if the statment is true, is to wait 10 seconds?
return  ;since you have no other actions?  Check this
}  ;you should not need the '{', '}' if all you are doing is sleeping 10 seconds


else
{
Send {2 down}
Sleep 50
Send {2 up}
Sleep 100
Send {LButton down}
Sleep 50
Send {Lbutton up}
Sleep 5000
}

return


Last edited by Carcophan on November 11th, 2009, 11:15 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 11th, 2009, 10:17 pm 
tried the changes u said:
- if i remove {} i get missing { error. - left them
return has been inserted, no help, still only ELSE actions are made,everytime :(


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 11th, 2009, 10:46 pm 
Code:
m::
PixelGetColor, color1, 78,360
If (color1 = "0x9B8363")
{
   Sleep,  10000
   Return
   } else {
   Send {2 down}
   Sleep 50
   Send {2 up}
   Sleep 100
   Send {LButton down}
   Sleep 50
   Send {Lbutton up}
   Sleep 5000
   }
Return


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 11th, 2009, 10:51 pm 
Thx for u`r help, but not solving my problem.
somehow, its always doing the same thng, like wouldnt keep track aof the returned value,cause ELSE is executed,if true, and if false also.
:(


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 11th, 2009, 11:14 pm 
Offline

Joined: December 24th, 2008, 3:25 am
Posts: 1401
Location: :noitacoL
Our code snippets should help you.


Quote:
its only a part of the script, and i`ll loop it, but left the loop part,and others out,untill i figure this one
Maybe something else is causing it to not function.


Next step is to post all of your code, for better assistance.


Report this post
Top
 Profile  
Reply with quote  
 Post subject: all the code
PostPosted: November 11th, 2009, 11:43 pm 
all code,as it looks now [after 4 hours of searching around - as i`m a noob]
Code:
CoordMode, ToolTip, Screen

m::
PixelGetColor, color1, 78,360, Alt
If (color1 = "0x9B8363")
{
   SoundBeep, 200, 10000
   Return
   } else {
   Send {2 down}
   Sleep 50
   Send {2 up}
   Sleep 100
   Send {LButton down}
   Sleep 50
   Send {Lbutton up}
   Sleep 5000
   }
   
Return


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 12th, 2009, 12:04 am 
Offline

Joined: February 23rd, 2008, 6:52 pm
Posts: 30
I've been working with PixelSearch lately and I like to use this small script just to see if it is finding / not finding the target color correctly:

This makes the assumption that Notepad is your target window, change as needed:

Code:
CoordMode, Pixel, Screen
CoordMode, Mouse, Screen

#p::
WinGetPos, X, Y, Width, Height, Notepad
PixelSearch, Px, Py, X, Y, X+Width, Y+Height, 0x9B8363, 0, Slow
if ErrorLevel
{
MouseMove, X, Y
MsgBox, That color was not found: %x% %y% %width% %height%.
}
else
{
MouseMove, Px, Py
MsgBox, Your color was found at X%Px% Y%Py%.
}
Return


Could do something similar to create msgboxes for PixelGetColor to tell you if it is behaving the way to are looking for.


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: hyper_, Leef_me, patgenn123, Pulover, rbrtryn, XstatyK and 21 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