AutoHotkey Community

It is currently May 27th, 2012, 12:16 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: September 13th, 2008, 1:51 pm 
Offline

Joined: September 6th, 2008, 3:11 pm
Posts: 84
Ok, consider the following expression

Code:
PixelSearch, OutPutVarX, OutPutVarY, 186, 643, 282, 643, 0x76946D, 25


If the pixel is found, then OutPutVarX, OutPutVarY EXIST
If the pixel is not found, they don't exist.

Is there a way to check if OutPutVarX exists ?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 13th, 2008, 3:51 pm 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
What you had asked for...
Code:
PixelSearch, OutPutVarX, OutPutVarY, 186, 643, 282, 643, 0x76946D, 25
If Not varExist( OutPutVarX )
     ExitApp
 
; www.autohotkey.com/forum/viewtopic.php?p=83371#83371
varExist(ByRef v) { ; Requires 1.0.46+
   return &v = &n ? 0 : v = "" ? 2 : 1
}


..is unneccessary, and the following method is recommended:

Code:
PixelSearch, OutPutVarX, OutPutVarY, 186, 643, 282, 643, 0x76946D, 25
If ( ErrorLevel=1 ) ; means above command failed
   ExitApp


:)

_________________
URLGet - Internet Explorer based Downloader
StartEx - Portable Shortcut Link


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 13th, 2008, 6:39 pm 
Offline

Joined: September 6th, 2008, 3:11 pm
Posts: 84
The reason i asked if var exist is because i want to make the pixel search and then check later if it worked, not right away !


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 13th, 2008, 6:50 pm 
Offline

Joined: September 12th, 2008, 10:48 pm
Posts: 8
Skan, that's a nice one You have there, personally i think this is easier:

Code:
OutX =
OutY = 0

if StrLen(OutX)>0
   MsgBox OutX Exists!
Else
   MsgBox OutX? WTF?

MsgBox % "OutY" ( StrLen(OutY)>0 ? " exists" : "? WTF?" )


The last MsgBox is just the ternary version of the OutX-If-Else-construct.

cheers,

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 14th, 2008, 12:38 am 
Offline
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8667
Location: Salem, MA
you can always test to make sure OutPutVarX is not ""

Code:
If (OutPutVarX != "")
{
  msgbox it exists!
}

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 14th, 2008, 1:00 am 
Offline

Joined: November 8th, 2004, 12:46 am
Posts: 1271
Bytales wrote:
The reason i asked if var exist is because i want to make the pixel search and then check later if it worked, not right away !


You could store the ErrorLevel from PixelSearch in a variable:

Code:
PixelSearch, OutPutVarX, OutPutVarY, 186, 643, 282, 643, 0x76946D, 25
SavedForLater := ErrorLevel

_________________
"Anything worth doing is worth doing slowly." - Mae West
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 14th, 2008, 3:26 am 
Offline

Joined: May 17th, 2007, 9:06 pm
Posts: 421
Location: England
Serenity wrote:
You could store the ErrorLevel from PixelSearch in a variable:

This is the solution I normally choose to use


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], Google Feedfetcher 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