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 

code works in Vista - only in Windows Classic Mode

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



Joined: 21 Nov 2006
Posts: 191

PostPosted: Mon Jun 15, 2009 10:42 pm    Post subject: code works in Vista - only in Windows Classic Mode Reply with quote

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]
Back to top
View user's profile Send private message
RTFM
Guest





PostPosted: Tue Jun 16, 2009 6:51 am    Post subject: Reply with quote

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
Back to top
ecksphore



Joined: 21 Nov 2006
Posts: 191

PostPosted: Tue Jun 16, 2009 6:24 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
TheGood



Joined: 30 Jul 2007
Posts: 580

PostPosted: Tue Jun 16, 2009 6:45 pm    Post subject: Reply with quote

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).
Back to top
View user's profile Send private message Visit poster's website
Lexikos



Joined: 17 Oct 2006
Posts: 7295
Location: Australia

PostPosted: Wed Jun 17, 2009 12:47 pm    Post subject: Reply with quote

I wrote:
Actually, using
Code:
PixelSearch, x, y, 1500, 0, 1680, 200, 0x333300  ; no ,, Fast
the script becomes permanently unresponsive. Confused
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.
Back to top
View user's profile Send private message Visit poster's website
ecksphore



Joined: 21 Nov 2006
Posts: 191

PostPosted: Wed Jun 17, 2009 6:28 pm    Post subject: Reply with quote

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.
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