AutoHotkey Community

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

All times are UTC [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: June 15th, 2009, 11:42 pm 
Offline

Joined: November 21st, 2006, 9:00 pm
Posts: 210
The following code works perfectly in Vista - only if you are in Windows Classic Mode.

If you are using the defualt Vista theme, it locks up tight. Any ideas how to solve this issue?

Please excuse the messy code, it was the only way I could get it to reproduce the issue.

Code:
Start:

ControlGetPos, X13, Y13, W, H
EnvAdd, X13, 1
EnvAdd, Y13, 1
ControlGetPos, X14, Y14, W, H
EnvAdd, X14, 2
EnvAdd, Y14, 2
PixelSearch, , , %X13%, %Y13%, %X14%, %Y14%, 0FFFFFF, 255, Fast
If ErrorLevel = 0
{
   Random, num, 1, 2
   Goto, Spot%num%
}

Sleep, 1000
Goto, Start








Spot1:
MsgBox, Spot 1

ControlGetPos, X1, Y1, W, H
EnvAdd, X1, 100
EnvAdd, Y1, 100
ControlGetPos, X2, Y2, W, H
EnvAdd, X2, 200
EnvAdd, Y2, 200
PixelSearch, x30, y30, %X1%, %Y1%, %X2%, %Y2%, 0x200000
If ErrorLevel = 0
{
   MsgBox, Match 1
   Sleep, 1000
}

MsgBox, Leaving Spot 1
Goto, Start








Spot2:
MsgBox, Spot 2

ControlGetPos, X1, Y1, W, H
EnvAdd, X1, 100
EnvAdd, Y1, 100
ControlGetPos, X2, Y2, W, H
EnvAdd, X2, 200
EnvAdd, Y2, 200
PixelSearch, x30, y30, %X1%, %Y1%, %X2%, %Y2%, 0x200000
If ErrorLevel = 0
{
   MsgBox, Match 2
   Sleep, 1000
}

MsgBox, Leaving Spot 2
Goto, Start


[Title edited. Please write descriptive titles for your topics. ~jaco0646]


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 16th, 2009, 7:51 am 
The appearance of a window might be slightly different based on the used theme eg the titlebar is higher/smaller. So you've to adjust minimum the coordinates. Another thing is to check if the color is still matching with your preset at PixelSearch


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 16th, 2009, 7:24 pm 
Offline

Joined: November 21st, 2006, 9:00 pm
Posts: 210
No, that is not the issue.

If you run this script yourself, you will see that the message box fails to appear and the script locks up.

The only way to fix it is to ctrl-alt-del and end the process that way.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 16th, 2009, 7:45 pm 
Offline

Joined: July 30th, 2007, 11:32 pm
Posts: 581
My theory:

The script locks up because it is stuck in a loop.
The script is stuck in a loop because it can't find the pixel you're searching.
And it can't find the pixel you're searching because of the different themes (and therefore colours).


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 17th, 2009, 1:47 pm 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7502
Location: Australia
I wrote:
Actually, using
Code:
PixelSearch, x, y, 1500, 0, 1680, 200, 0x333300  ; no ,, Fast
the script becomes permanently unresponsive. :?
Source: AutoHotkey Forums: Speed - ImageSearch or PixelSearch?
(I was using Vista at the time of that post, though it looks like I failed to mention it.)
Ensure the "Fast" option is present in every PixelSearch call, then see how it goes.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 17th, 2009, 7:28 pm 
Offline

Joined: November 21st, 2006, 9:00 pm
Posts: 210
TheGood wrote:
My theory:

The script locks up because it is stuck in a loop.
The script is stuck in a loop because it can't find the pixel you're searching.
And it can't find the pixel you're searching because of the different themes (and therefore colours).


If you have a look at my code, I wrote the test script up so it matches any pixel.

Code:
PixelSearch, , , %X13%, %Y13%, %X14%, %Y14%, 0FFFFFF, 255, Fast


It will always find a match no matter what. I have tried added 'fast' to the end of all the pixel searches and that did not help. It will loop only 3-4 times tops and lock up tight.

However in Windows Classic Mode, the code works perfectly and will run for days without any issues whatsoever.


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

All times are UTC [ DST ]


Who is online

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