AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

.exe strange error for imagesearch

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Jasdeep



Joined: 09 Nov 2009
Posts: 258

PostPosted: Thu Mar 18, 2010 11:07 am    Post subject: .exe strange error for imagesearch Reply with quote

hi guys in my project i do lot of imagesearch and everything works up to mark but the moment i create a .exe of my .ahk file and when i place a shortcut of it on the desktop then for first few runs its gives error for some images and after say 2 to 3 runs of the project everything again starts to work fine.....i am confused with this dnt know what to do and how to do....any ideas would be greatly appreciated
thanks
Back to top
View user's profile Send private message
Leef_me



Joined: 08 Apr 2009
Posts: 5333
Location: San Diego, California

PostPosted: Thu Mar 18, 2010 12:54 pm    Post subject: Re: .exe strange error for imagesearch Reply with quote

Jasdeep wrote:
.....i am confused with this dnt know what to do and how to do....any ideas would be greatly appreciated

Hey Jasdeep buddy - You think you are confused Shocked
How about the other 17,000 registered users who haven't got a clue what the problem is?

Hint-----------------> P.Y.C.
(please Crying or Very sad )
Back to top
View user's profile Send private message
Jasdeep



Joined: 09 Nov 2009
Posts: 258

PostPosted: Thu Mar 18, 2010 1:26 pm    Post subject: Reply with quote

well i dont know what kind of clue i should give and also i cant place my project here as it is more than 7000 lines of code well as i said the problem was sometimes the imagesearch operation gives error if i run the .exe (but not when i double click the same .ahk file) but now i think i fixed the bug, i just changed the variable names and now its not giving error for .exe...
something like below
Code:

 ;;;;; Section 1
version=%A_OSVersion%

if(version="2000")
{
sbt1imageboard=%A_ScriptDir%\Images\Start1.bmp
}

if(version="WIN_XP")
{
sbt1imageboard=%A_ScriptDir%\Images\Board1.bmp
}

if(version="WIN_VISTA")
{
 sbt1imageboard=%A_ScriptDir%\Images\Start2.bmp
}
WinActivate,INCA/MAC
ImageSearch, OutputVarX, OutputVarY, 5,0 , Width, Height,*100 %sbt1imageboard%

;;; Section 2
version=%A_OSVersion%

if(version="2000")
{
sbt2imageboard=%A_ScriptDir%\Images\Start1.bmp ;;; previously i gave the same variable name as sbt1imageboard (like above)
}

if(version="WIN_XP")
{
sbt2imageboard=%A_ScriptDir%\Images\Board1.bmp
}

if(version="WIN_VISTA")
{
sbt2imageboard=%A_ScriptDir%\Images\Start2.bmp
}



as you can see i placed two sections of my code but when i changed the variable name it started working (still not 100% sure if the correct result will be given again the next day )

well sorry for not giving details at first
Back to top
View user's profile Send private message
Guest






PostPosted: Thu Mar 18, 2010 2:34 pm    Post subject: Reply with quote

A_ScriptDir <--
Back to top
Jasdeep



Joined: 09 Nov 2009
Posts: 258

PostPosted: Fri Mar 19, 2010 10:14 am    Post subject: Reply with quote

but it works fine even if i use %A_ScriptDir%
Back to top
View user's profile Send private message
Leef_me



Joined: 08 Apr 2009
Posts: 5333
Location: San Diego, California

PostPosted: Fri Mar 19, 2010 8:54 pm    Post subject: Reply with quote

Jasdeep wrote:
but when i changed the variable name it started working

Pardon, but you are like the cameraman who forgot his zoom lens, trying to film an elephant.
So, he gives us close shots on the tip of the ear, the toenails, part of the
trunk and a really tight shot on the side.

But no matter how much film he uses, no one knows what the whole elephant looks like
because he is afraid to film the whole elephant for fear that it will be out of focus or unable to be seen.

So, if you have bothered to read this far, how does this apply?

Instead of trying to show us pieces of you code, for fear that it will be too big (I agree, 7000 is pretty big)
Arrow Take you script and make a smaller script that run and illustrates the problem.
Back to top
View user's profile Send private message
Jasdeep



Joined: 09 Nov 2009
Posts: 258

PostPosted: Mon Mar 22, 2010 7:02 am    Post subject: Reply with quote

ok Mr here is a part of the script
Code:

;§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§ This file contains the function which is called by the button "Start" of "Online test" tab §§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§

#SingleInstance Force  ;;; it allows to run the script even if it is already in a running state
#NoEnv ;;; Avoids checking empty variables to see if they are environment variables (recommended for all new scripts).
#NoTrayIcon ;;;Disables the showing of a tray icon.

SetBatchLines -1 ;;; Determines how fast a script will run (affects CPU utilization) in this case -1 means runs at maximum speed
;Process, Priority, , High

;SendMode,Input

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Online test function;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Function name:hardwareboarddetect
;Calling Control: Start button of "Online test" tab.
;Function Parameters:-
;reg:-It contains the value C:\ETAS\ETKControlPanel%ed% where %ed% is 6.4,6.3 or any other depending upon the ETK Version selected by the user at Startup.
;hd,bc,hdbc:-Are the states of the radio control and if anyone of it is selected then value 1 will be passed to corresponding parameter of this function.


 Run  C:\ETAS\ETKControlPanel6.4\ETKControlPanel.exe -n                ; %reg%\ETKControlPanel.exe -n ;;;%reg% contains the value C:\ETAS\ETKControlPanel6.4 (if version 6.4 is selected or it will be 6.3,6.4....depending upon the version selected by the user) which is read from the registry
 WinWaitActive INCA/MAC
 WinActivate INCA/MAC
 winset,alwaysontop,on,INCA/MAC ;;;INCA/MAC is displayed above all windows if there are any pop ups still it will place INCA/MAC on top of all.
 WinActivate,INCA/MAC
 WinMove, INCA/MAC,, (A_ScreenWidth/2)-(Width/2), (A_ScreenHeight/2)-(Height/2)
 sleep 1000
 WinGetPos,,, Width, Height, INCA/MAC
 
 buttonw=50   
 buttonh=15
WinActivate,INCA/MAC
WinGetActiveStats, Title, Width, Height, X, Y

sleep 2000
version=%A_OSVersion%

if(version="2000")
{
;imageboard=%A_ScriptDir%\Images\Start1.bmp
}

if(version="WIN_XP")
{
imageboard=%A_ScriptDir%\Images\Board1.bmp
}

if(version="WIN_VISTA")
{
 ;imageboard=%A_ScriptDir%\Images\Start2.bmp
}
WinActivate,INCA/MAC
ImageSearch, OutputVarX, OutputVarY, 5,0 , Width, Height,*100 %imageboard%

if (errorlevel=1)
  {
    winset,alwaysontop,off,INCA/MAC
    FileAppend,Error in detecting the "BOARD" button so further operation of board connect cannot be performed if the button image is change then please place the new image of this button into the images folder with filename as Board1.bmp `n `n,%A_ScriptDir%\txt files\Logfile.txt
    FileRead,filecontents,%A_ScriptDir%\txt files\Logfile.txt
    GuiControl,2:,logfile,%filecontents%
    FileAppend,Error in detecting the "BOARD" button so further operation of board connect cannot be performed if the button image is change then please place the new image of this button into the images folder with filename as Board1.bmp `n `n,%A_ScriptDir%\txt files\History.txt
    msgbox,16,Error, Error in detecting the "BOARD" button ,3
   }
else
 {
  winset,alwaysontop,on,INCA/MAC
   mousemove, OutputVarX, OutputVarY, 1
   mousemove, buttonw/2, buttonh/2, 50, r
   click
}

as far as images are concerned i am not able to upload it from company (its the same panel pictures which i uploaded few months back)
well today morning when i started my tool from the shortcut (of the .exe file) it again gave error but when i started it from the .exe file which is placed in the d: directory it worked and when i again run the tool from the shortcut placed on the desktop it started to work

Conclusion: Everytime i have to first run it from the original .exe and then no errors if i try to run from the shortcut so in short if the .exe is run then only its shortcut works otherwise error.....why ?
Back to top
View user's profile Send private message
Leef_me



Joined: 08 Apr 2009
Posts: 5333
Location: San Diego, California

PostPosted: Mon Mar 22, 2010 4:59 pm    Post subject: Reply with quote

I understand your description, but not the reason why a shortcut would not work until after the original program is run.

referring/interpreting Guest's suggestion, I suggest you add diagnostics.
perhaps there is something wrong with the way scriptdir is being set up.
Code:

...
; prior code based on windows version
...
if(version="WIN_VISTA")
{
sbt2imageboard=%A_ScriptDir%\Images\Start2.bmp
}

...

msgbox %A_ScriptDir% ; <------------------


ifexist,%sbt1imageboard%  ; <------------------
msgbox exists: %sbt1imageboard%
else
msgbox does not exist: %sbt1imageboard%

ifexist,%sbt2imageboard%  ; <------------------
msgbox exists: %sbt1imageboard%
else
msgbox does not exist: %sbt1imageboard%
Back to top
View user's profile Send private message
Jasdeep



Joined: 09 Nov 2009
Posts: 258

PostPosted: Tue Mar 23, 2010 6:41 am    Post subject: Reply with quote

well thanks buddy but the image also exists so not an issue on that what i did yesterday is i added imagesearch command twice and i removed setbatchlines -1 command from the script and i perform approx.20 runs so no error till now i hope i wont get it again in future
Code:

Run  C:\ETAS\ETKControlPanel6.4\ETKControlPanel.exe -n                ; %reg%\ETKControlPanel.exe -n ;;;%reg% contains the value C:\ETAS\ETKControlPanel6.4 (if version 6.4 is selected or it will be 6.3,6.4....depending upon the version selected by the user) which is read from the registry
 WinWaitActive INCA/MAC
 WinActivate INCA/MAC
 winset,alwaysontop,on,INCA/MAC ;;;INCA/MAC is displayed above all windows if there are any pop ups still it will place INCA/MAC on top of all.
 WinActivate,INCA/MAC
 WinMove, INCA/MAC,, (A_ScreenWidth/2)-(Width/2), (A_ScreenHeight/2)-(Height/2)
 sleep 1000
 WinGetPos,,, Width, Height, INCA/MAC
 
 buttonw=50   
 buttonh=15
WinActivate,INCA/MAC
WinGetActiveStats, Title, Width, Height, X, Y

sleep 2000
version=%A_OSVersion%

if(version="2000")
{
;imageboard=%A_ScriptDir%\Images\Start1.bmp
}

if(version="WIN_XP")
{
imageboard=%A_ScriptDir%\Images\Board1.bmp
}

if(version="WIN_VISTA")
{
 ;imageboard=%A_ScriptDir%\Images\Start2.bmp
}
WinActivate,INCA/MAC
ImageSearch, OutputVarX, OutputVarY, 5,0 , Width, Height,*100 %imageboard%

if (errorlevel=1)
  {
     ImageSearch, OutputVarX, OutputVarY, 5,0 , Width, Height,*100 %imageboard% ;;;added once again
    if(errorlevel=1)
  { 
    winset,alwaysontop,off,INCA/MAC
    FileAppend,Error in detecting the "BOARD" button so further operation of board connect cannot be performed if the button image is change then please place the new image of this button into the images folder with filename as Board1.bmp `n `n,%A_ScriptDir%\txt files\Logfile.txt
    FileRead,filecontents,%A_ScriptDir%\txt files\Logfile.txt
    GuiControl,2:,logfile,%filecontents%
    FileAppend,Error in detecting the "BOARD" button so further operation of board connect cannot be performed if the button image is change then please place the new image of this button into the images folder with filename as Board1.bmp `n `n,%A_ScriptDir%\txt files\History.txt
    msgbox,16,Error, Error in detecting the "BOARD" button ,3
}
   }
else
 {
  winset,alwaysontop,on,INCA/MAC
   mousemove, OutputVarX, OutputVarY, 1
   mousemove, buttonw/2, buttonh/2, 50, r
   click
}
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group