Jump to content
Sign in to follow this  
angelo88

How do the coords work in pixel operations.

Recommended Posts

angelo88

Hello again.

I allowed myself 2 dumb questions here every 10 days.

I hope you all allow me these too. Sadly, it is my second one.

Please bear with me.

I am trying to grasp basics of this language, and

making a basic "bot" for a game thats over 20 years old.

I dont really understand the "bottom top left right" concept

in pixelling. I have added my full code till now after this question

if anyone cares.

Please meet Mr screen:

Posted Image

Mr screen is ~500x500 pixels.

Approx. What "left, top, right, bottom" would the copyright symbol

be in the bottomleft ? Just a guess will do..

Based on that info, I can understand the concept and adapt it to my needs

and never forget. :idea:

I basically want to do an action when the area covering these pixels

has changed. Here is a (not much saying) attempt.

Run("C:\angelo\emu\NES\FCEU\fceux.exe PINBALL.nes","C:\angelo\emu\NES\FCEU")
WinWaitActive ( "FCEUX 2.1.3: PINBALL" )
sleep (2000)
Send("{r}")
sleep (1000)
Send("{r}")
sleep (5000)
Send("{f down}") ;Holds the f key down
sleep (3000)
Send("{f up}") ;Releases the A key
$checksum = PixelChecksum(257, 411, 156, 411)
AutoItSetOption ( "PixelCoordMode", 0 ) 
while 1
; Wait for the region to change
While $checksum = PixelChecksum(257, 411, 156, 411)
Sleep(100)
WEnd
Send("{d up}")
sleep (500)
Send("{d down}")
WEnd

Share this post


Link to post
Share on other sites
Melba23

angelo88,

Think of the screen as a grid like this:

0  1  2  3  4  5
0  .  .  .  .  .  .
1  .  .  .  A  .  .
2  .  .  .  .  .  .
3  .  .  .  .  .  .
4  .  Z  .  X  X  X
5  .  .  .  X  X  X
6  .  .  .  X  X  X

Point A is at coordinates 3, 1 - that is 3 across and 1 down.

Point Z is at 1, 4 - that is 1 across and 4 down.

The area covered by the Xs has the following coordinates:

Left: 3

Top: 4

Right: 5

Bottom: 6

Does that make more sense? :idea:

As to where your copyright symbol is situated - you need to decide what reference to take. AutoIt offers you a choice of 3 - which you can set with the Opt("PixelCoordMode", #) command. The 3 options are:

0 = relative coords to the defined window (this means that you start from the top left of the window itself)

1 = absolute screen coordinates (default) (this means that you start from the top left of the screen)

2 = relative coords to the client area of the defined window (this means that you start from the top left of the internal part of the window)

I suggest we stick with the default for the moment - i.e. relative to the whole screen! :)

Still with me?

One way to determine where your copyright symbol is located is to use the Au3 Window Info tool - you can find it at "C:\Program Files\AutoIt3\Au3Info.exe" if you have a standard installation. Once you have started it, use the arrows to move to the right until you can see the "Mouse" tab. Then move the "crosshairs" over the copyright symbol and read the position. Then move the "crosshairs" to the very top left of the window itself, next to the icon. The difference between these two positions is where the symbol is relative to the window.

But, I hear you cry, you said we would be working relative to the screen? Yes, but will your window always be in the same place? Probably not. :(

So even though we can get the positon of the window with WinGetPos, we also need to know where the symbol is relative to the window. Let us guess that the symbol is at 100, 480 on the window itself. You would therefore calculate the position relative to the screen (so we can use PixelSearch) like this:

; get the window position
$aPos = WinGetPos("FCEUX 2.1.3: PINBALL")
; Calculate the symbol position
$iLeft = $aPos[0] + 100
$iTop = $aPos[1] + 480
$iRight = $iLeft + 20 ; let us assume it is about 20 pixels aross, you can check with the Window Info tool!
$iBottom = $iTop + 20

And there you have your parameters for the PixelSearch command.

Ask again if anything is unclear. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
angelo88

incredibly clear, thank you very much.

:idea:

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.