AutoHotkey Community

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

All times are UTC [ DST ]




Post new topic Reply to topic  [ 9 posts ] 
Author Message
PostPosted: March 18th, 2010, 12:07 pm 
Offline

Joined: November 9th, 2009, 3:09 pm
Posts: 258
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


Report this post
Top
 Profile  
Reply with quote  
PostPosted: March 18th, 2010, 1:54 pm 
Offline

Joined: April 8th, 2009, 7:49 pm
Posts: 6071
Location: San Diego, California
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 :shock:
How about the other 17,000 registered users who haven't got a clue what the problem is?

Hint-----------------> P.Y.C.
(please :cry: )


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 18th, 2010, 2:26 pm 
Offline

Joined: November 9th, 2009, 3:09 pm
Posts: 258
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 18th, 2010, 3:34 pm 
A_ScriptDir <--


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 19th, 2010, 11:14 am 
Offline

Joined: November 9th, 2009, 3:09 pm
Posts: 258
but it works fine even if i use %A_ScriptDir%


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 19th, 2010, 9:54 pm 
Offline

Joined: April 8th, 2009, 7:49 pm
Posts: 6071
Location: San Diego, California
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 22nd, 2010, 8:02 am 
Offline

Joined: November 9th, 2009, 3:09 pm
Posts: 258
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 ?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 22nd, 2010, 5:59 pm 
Offline

Joined: April 8th, 2009, 7:49 pm
Posts: 6071
Location: San Diego, California
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%


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 23rd, 2010, 7:41 am 
Offline

Joined: November 9th, 2009, 3:09 pm
Posts: 258
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
}


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: rbrtryn and 28 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