Sign in to follow this  
Followers 0
Aru

Virtual Machine Pixel Functions (VirtualBox)

7 posts in this topic

#1 ·  Posted (edited)

I'm playing with my new virtual machine and I can't get my scripts to see any colors correctly on it. I'm running autoit from my real computer, and trying to get colors/checksum differences/pixelsearches on my VM window, but none of them work. I opened paint in my VM and made a big red square on a white background, and autoit tells me it's a completely different color.

The Window Info works perfectly over the VM, but the functions give completely off results. I've been trying to figure this out for three nights now, many many hours, and I've gotten nowhere. I can't figure out why the window info works just fine, why the functions don't, or where the strange color codes are coming from.

Screenshot

Please help :(

Edited by Aru

Share this post


Link to post
Share on other sites



Its customary to provide some code you have been trying, as there could be any number of reasons its failing.

We could guess all day long, but we would be wasting time on all parts.

Welcome to the forums by the way.

Post your code in [code]your code here[autoit]your code here[/autoit] tags (without the bold bracket)

You will recieve help a lot quicker.


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Awww, thank you for the welcome :3 *hug*

I don't know what good it will do, my code works fine everywhere else and it gradually boiled down to just some simple tests to see if I could get anything to work.

AutoItSetOption("MouseCoordMode",2) ;client mode, maximized and windowed coords are the same

Sleep(2000)

;#cs
MsgBox(0,"Color fetching test", Hex(PixelGetColor(300,300)))
#ce

#cs
MouseMove(206,205,0)
Sleep(100)
MouseMove(206,204,0)

;429 575
#ce

#cs
While True
MsgBox(0,"Color fetching test", Hex(PixelGetColor(737, 553)))
Sleep(200)
WEnd
#ce
; 737,553 B0C4E0

#cs
$coord = PixelSearch(0,0,600,800,0x019285)
MsgBox(0, "X and Y are:", $coord[0] & "," & $coord[1])
#ce

#cs
$checksum = PixelChecksum(20,56,265,436)

; Wait for the region to change, the region is checked every 100ms to reduce CPU load
While $checksum = PixelChecksum(20,56,265,436)
  Sleep(100)
WEnd

MsgBox(0, "", "Something in the region has changed!")
#ce

Here are my tests, not one of them work. Some of them are copied directly out of the AutoIt help file.

Excluding the mouse move one, that works (and so do Send and MouseClick).

Edited by Aru

Share this post


Link to post
Share on other sites

Wow.. that.. fixed it, somehow o.O

It still should have been working without that pixelcoordmode, though, it should have only offset things by a little bit.. things like the checksum difference detector and pixelsearch still should have worked, so there's still something wrong.. but I'm using the new option now and it works, so I guess it doesn't matter anymore.

Very strange though.. if anyone has any idea why it doesn't work without the option, I'm still curious.

Share this post


Link to post
Share on other sites

When you're dealing with a specific application, it's always best to use client coordinates rather than screen coordinates.

This way, no matter where the application interface is open on your desktop, the coordinates are always a constant ( providing the interface doesn't change sizes ).

Moving the application 1 pixel would screw everything up if you were in screen mode.

If you look at the help file, for the options provided for you, you'd see that Opt("MouseCoordMode", 2) and Opt("PixelCoordMode", 2) both tell their perspective counterparts to use "Client Coordinates" rather than "Screen" or "Window" coordinates.

Now, having said this, it's imperative when using the AutoInfo tool to set the options menu for your coordinates to client.

----

Now for my silly question... Why are you doing pixel searches on a VM that you control on the server side and not within the VM machine client itself?


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

Now, having said this, it's imperative when using the AutoInfo tool to set the options menu for your coordinates to client.

----

Now for my silly question... Why are you doing pixel searches on a VM that you control on the server side and not within the VM machine client itself?

I did xD I just forgot the pixel mode.. I kind of thought the mouse mode covered all of it >.>

Also, because I want my script to open and run the VM as well as do things with it :3 unless you want it to open it and then run another script in the VM and close, but that seems roundabout hehe. Thank you very very much John and Smoke, it's a mistake I'll not make again. Maybe one day I'll be knowledgeable enough to help others on here, if you guys keep this up :3

How do I mark the thread resolved so I don't waste people's time?

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  
Followers 0