AutoHotkey Community

It is currently May 26th, 2012, 6:05 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: February 4th, 2009, 5:21 am 
Offline

Joined: August 20th, 2007, 6:57 pm
Posts: 185
I'm using a series of images and want certain events to happen when the images appear but when I try to see if "Picture = picture path" it give's me an Illegal character error.
Code:
  Loop, C:\Pics\*.png
   {
      ImageSearch Varx, Vary, 0, 0, A_ScreenWidth, A_ScreenHeight, %A_LoopFileLongPath%
;Illegal Character error - following is an illegal variable A.png
      If %A_LoopFileName% = A.png
 gosub, Alabel
      Else If  %A_LoopFileName% = b.png
           gosub, Blabel
      Else
         {         
  return                               
         }
   }

How would I reference what picture it found and go that label?
I'm kinda of at a lost and can't understand why If %A_LoopFileName% = a.png will not work but
msgbox, %A_LoopFileName% will show A.png
the only thing that worked was
Code:
%A_LoopFileName% = %clipboard%
if %clipboard% = A.png
 gosub, Alabel


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 4th, 2009, 5:49 am 
Offline

Joined: May 28th, 2008, 2:11 am
Posts: 739
Location: Minnesota, USA
FAQ: When exactly are variable names enclosed in percent signs?

Code:
  Loop, C:\Pics\*.png
   {
      ImageSearch Varx, Vary, 0, 0, A_ScreenWidth, A_ScreenHeight, %A_LoopFileLongPath%
;Illegal Character error - following is an illegal variable A.png
      If A_LoopFileName = A.png
 gosub, Alabel
      Else If  %A_LoopFileName% = b.png
           gosub, Blabel
      Else
         {         
  return                               
         }
   }


Note that the "working" code you posted probably wasn't actually doing much of anything...
Code:
; This line does nothing useful...
; (Likely sets a variable equal to clipboard, I'm surprised it doesn't result in an error)
%A_LoopFileName% = %clipboard%
; This line compares an expression with the current clipboard comments with A.png
; For example, if clipboard contained "the" it would compare %the% with A.png
if %clipboard% = A.png
 gosub, Alabel
 

_________________
Unless otherwise stated, all code is untested

(\__/) This is Bunny.
(='.'=) Cut, copy, and paste bunny onto your sig.
(")_(") Help Bunny gain World Domination.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 6th, 2009, 9:52 am 
Offline

Joined: August 20th, 2007, 6:57 pm
Posts: 185
Thanks for the help your solution worked and read over the FAQ's thanks
your right about my code late night desperation tricked me and my code was just continuing to the first routine.


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: BrandonHotkey, hilalpro, just me, tic and 71 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