I need help to figure out what i am doing wrong ...
I'm trying to read the pixel color on a game screen to determin whether the user is playing in a small / large screen. If so, move the the approperate coords and Left Click and a bunch of other stuff .. (like killing popups)
The problem is .. it works great the first time around. When it comes to doing it the 2nd or 3rd time , its not reading pixel color location it should be reading. Thus going to Click2 sub, not Click1.
I tried reseting the x,y back to 0 each time it loops .. but i still get the same problem.
Any help would be appreciated!
Label>Start
GetWindowPos>Game room*,X,Y
Let>X=72
Let>Y=270
GetPixelColor>X,Y,PC
Label>popup
WaitWindowOpen>Your*
SetFocus>Your*
Wait>.5
Press Enter
Wait>.5
If>%PC%=10079436,Click1
If>%PC%=10276814,Click1
If>%PC%10079436,Click2
If>%PC%10276814,Click2
Let>X=0
Let>Y=0
Goto>Start
Label>Click1
....
Goto>Start
Label>Click2
...
Goto>Start
Scratching my head ...
Moderators: Dorian (MJT support), JRL
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
It is not possible yet to have a complete picture of what you are doing. But it looks to me like the problem may be at the very beginning. With GetWindowPos> you are defining the values of X,Y. In the next two lines you are redefining X,Y...........for what purpose? Why bother to do GetWindowPos>?
Since the window may be in different positions each time it opens, then the values of X,Y can change. Did you get the values of 72,270 from the first time it opened? I suspect you just need to eliminate those two lines and do GetPixelColor> immediately. Something like this:Label>Start
GetWindowPos>Game room*,X,Y
Let>X=72
Let>Y=270
GetPixelColor>X,Y,PC
But it is very likely that I don't have a complete picture. To recap, the current method looks at pixel color at 72,270 no matter where the Game room window may be positioned. The monitoring has no relationship to the position of the window.Label>Start
GetWindowPos>Game room*,X,Y
GetPixelColor>%X%,%Y%,PC
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!
Bob
A humble man and PROUD of it!
What i was trying to do was :
a) Get the game screen position
b) Click on a button at a fixed place on the game window
Like i said in my previous post .. my script clicks the correct button the first time.
When the script goes to do it a second time, it click the wrong location. (game screen position didn't change)
Was just curious why it would work correctly the first time around, but anytime after that it doesn't.
a) Get the game screen position
b) Click on a button at a fixed place on the game window
Like i said in my previous post .. my script clicks the correct button the first time.
When the script goes to do it a second time, it click the wrong location. (game screen position didn't change)
Was just curious why it would work correctly the first time around, but anytime after that it doesn't.
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
As I said in MY previous post:
GetPixelColor>72,270 has no relation to where the window is. Any values there are pure coincidence. You have nothing here to guarantee that X,Y are inside the game window, whether or not it moves. I would strongly encourage you to calculate GetPixelColor>X,Y based on your earlier GetWindowPos> values.
Also noticed you are later changing X,Y to 0,0, for what purpose? If some lines are being skipped, then you may be getting pixel color of 0,0 vs. 72,270. Some steps could be "skipped" because of Trailing spaces.
You never answered by earlier question:
Did you try using variables %X%, %Y% from my earlier post?
What are the values of X,Y, PC when you single step through the macro?
Does your log show you the steps and values being processed?
Using variables in all commands will allow the log to show the values at the same time the steps are being executed.
GetPixelColor>72,270 has no relation to where the window is. Any values there are pure coincidence. You have nothing here to guarantee that X,Y are inside the game window, whether or not it moves. I would strongly encourage you to calculate GetPixelColor>X,Y based on your earlier GetWindowPos> values.
Also noticed you are later changing X,Y to 0,0, for what purpose? If some lines are being skipped, then you may be getting pixel color of 0,0 vs. 72,270. Some steps could be "skipped" because of Trailing spaces.
You never answered by earlier question:
Did you Remove All Trailing Spaces?With GetWindowPos> you are defining the values of X,Y. In the next two lines you are redefining X,Y...........for what purpose? Why bother to do GetWindowPos>?
Did you try using variables %X%, %Y% from my earlier post?
What are the values of X,Y, PC when you single step through the macro?
Does your log show you the steps and values being processed?
Using variables in all commands will allow the log to show the values at the same time the steps are being executed.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!
Bob
A humble man and PROUD of it!
I dunno, i guess i don't know what i am doing. I'm just trying anything and everything to get this working.With GetWindowPos> you are defining the values of X,Y. In the next two lines you are redefining X,Y...........for what purpose? Why bother to do GetWindowPos>?
I removed the trailing spaces.
no because that would only give me the pixel color of 0,0 of my game window.Did you try using variables %X%, %Y% from my earlier post?
I cannot do a single step method because i need macro scheduler minimized for this macro to work otherwise it messes up. Too many windows are on the screen .. can't even get to that button.
Logs files show the steps being taken .. like i said in my previous post, the macro works fine the first time around ... its just every other time it does not.
This is a frustrating app to work with ..
All i want to do is :
a) get the macro to get the X,Y coords of the game screen
b) get pixel color at 72,270 relevent to that game screen
thanks for you patience in this matter .. any help wold be appreciated.
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
AHA...the major clue may be relevent, did you mean relative?:
Open the window.
Move the mouse to the relative position 72,720
Get the absolute coordinates of where the mouse is
Get the pixel color at that point., needs absolute coordinates
Code will look something like this, untested, possible errors:
If>%PC%=10276814,Click1,Click2
NOTE 2: There is no exit to this macro, it will run indefinitely.
NOTE 3: You should still be able to Single Step and look at values in watch list. Key is that Focus is set to the game window. When single stepping, the focus window will acrivate, the line will execute, and the Single Step screen will come back so you can press F8 for the next step to execute.
NOTE 4: I have no explanation why it runs once only at this point, but would like to get some basic issues out of the way first.
Another reminder to Remove All Trailing Spaces if you Cut/Paste from forum.
What you need to do in concept:b) get pixel color at 72,270 relevent to that game screen
Open the window.
Move the mouse to the relative position 72,720
Get the absolute coordinates of where the mouse is
Get the pixel color at that point., needs absolute coordinates
Code will look something like this, untested, possible errors:
NOTE 1: The comments I inserted mean you could delete both of those lines, and change the second IF> statement to this:Label>Start
WaitWindowOpen>Game room*
SetFocus>Game room*
WaitReady>1
MouseMoveRel>72,270
GetCursorPos>X,Y
GetPixelColor>%X%,%Y%,PC
If>%PC%=10079436,Click1
If>%PC%=10276814,Click1
//NOTE: According to the next 2 IF lines you will always go to Click2
If>%PC%10079436,Click2
//NOTE: If do not go to Click2 in previoius line then the next line will always do Click2 because the color must = 10079436
If>%PC%10276814,Click2
Goto>Start
Label>Click1
....
Goto>Start
Label>Click2
...
Goto>Start
If>%PC%=10276814,Click1,Click2
NOTE 2: There is no exit to this macro, it will run indefinitely.
NOTE 3: You should still be able to Single Step and look at values in watch list. Key is that Focus is set to the game window. When single stepping, the focus window will acrivate, the line will execute, and the Single Step screen will come back so you can press F8 for the next step to execute.
NOTE 4: I have no explanation why it runs once only at this point, but would like to get some basic issues out of the way first.
Another reminder to Remove All Trailing Spaces if you Cut/Paste from forum.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!
Bob
A humble man and PROUD of it!