Jump to content
Sign in to follow this  
Splash

Get Pixel Color from Minimized Window

Recommended Posts

Splash

It's possible get a pixel color from a minimized window with the Windows API?

I need this to make a game automation.

Sorry my poor english, is not my primary language :)

Thanks, Splash


Automatic Update UDF - IP Address UDF - WinPcap AutoIt _FindDevice()[font="Verdana"][size="2"]AutoIt Spanish/Brasil/World community!!![/size][/font]Use you wanna a dot.tk domain please use my link:

Share this post


Link to post
Share on other sites
Reyzor

It's possible get a pixel color from a minimized window with the Windows API?

I need this to make a game automation.

Sorry my poor english, is not my primary language :)

Thanks, Splash

I need to know for my game too.. =(

Share this post


Link to post
Share on other sites
Marlo

I'm not 100% sure but i think that if a window is hidden/minimized then you cannot retrieve the pixel color as the window has not been "drawn".

There could be a way however but im just not aware of it.


Click here for the best AutoIt help possible.Currently Working on: Autoit RAT

Share this post


Link to post
Share on other sites
Reyzor

I'm not 100% sure but i think that if a window is hidden/minimized then you cannot retrieve the pixel color as the window has not been "drawn".

There could be a way however but im just not aware of it.

Thanks, anyone have an ideia about it?

Share this post


Link to post
Share on other sites
monoceres

I'm not 100% sure but i think that if a window is hidden/minimized then you cannot retrieve the pixel color as the window has not been "drawn".

There could be a way however but im just not aware of it.

This is only true versions of windows before vista, nowadays with dwm everything is drawn all the time (well maybe not totally true, but at least when it's minimized), on xp it can be still be done with the PrintWindow function.

This thread contains useful info:

http://www.autoitscript.com/forum/index.php?showtopic=86061


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites
SmOke_N

This is only true versions of windows before vista, nowadays with dwm everything is drawn all the time (well maybe not totally true, but at least when it's minimized), on xp it can be still be done with the PrintWindow function.

This thread contains useful info:

http://www.autoitscript.com/forum/index.php?showtopic=86061

Interesting enough... I heard Chris speak of the memory thing with Vista.

However, the PrintWindow method you're speaking about with XP, still won't get the data from a minimized windows client area. It gets its taskbar window I believe.

Edited by SmOke_N

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
monoceres

Interesting enough... I heard Chris speak of the memory thing with Vista.

However, the PrintWindow method you're speaking about with XP, still won't get the data from a minimized windows client area. It gets its taskbar window I believe.

Whose Chris? :)

Nope, I think everything is copied, check the msdn page:

http://msdn.microsoft.com/en-us/library/dd162869(VS.85).aspx


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites
SmOke_N

Whose Chris? :)

Nope, I think everything is copied, check the msdn page:

http://msdn.microsoft.com/en-us/library/dd162869(VS.85).aspx

It says handle to the device context as the 2nd parameter. In XP the device context is not drawn other than the taskbar window when minimized. Edited by SmOke_N

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
monoceres

It says handle to the device context as the 2nd parameter. In XP the device context is not drawn other than the taskbar window when minimized.

The DC does not belong to the window you're targeting, it's your dc with a bitmap selected into it.


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites
SmOke_N

The DC does not belong to the window you're targeting, it's your dc with a bitmap selected into it.

Yeah, I tried that... Compatible DC from Bitmap, and still only got the taskbar window with Printwindow.

Edit:

Interesting enough, I think I got it to work hidden (not 100% tested), but it doesn't like minimized. No time to play at the moment.

Edit2:

Ok, so using the above method (PrintWindow).

1. Check if window is minimized.

2. If window is minimized - Get transparency level

3. If window is not 100% transparent - Make window transparent

4. Restore window

5. Use PrintWindow/Compatible DC bitmap method

6. Minimize window

7. Restore original transparency state if necessary

That could work more than likely (not tested).

Or..

1. Check if window is minimized.

2. If window is minimized - Hide window

3. Restore

4. Use PrintWindow/Compatible DC bitmap method

5. Minimize window

6. Unhide window

That might work as well other than the taskbar disappearing and reappearing, but you'll have action in the taskbar as well with restore/minimize.

My preference, if/when I can verify 100% it's working, would be to just hide windows in restored mode, rather than worrying about always restoring or minimizing.

Maybe even make a dummy taskbar window minimized, that when activated it shows the window and deletes the dummy gui so you have something in the taskbar.

Edited by SmOke_N

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
monoceres

It looks like it could work, however I don't think you'll ever get a result that is comparable to what you can get on vista/win7, and yeah hidden restored state is much better than that transparency stuff, seems like an dirty hack to me.

Oh and I hope you also tried the WM_PRINT message, I don't think PrintWindow and WM_PRINT are very different, but still :)


Broken link? PM me and I'll send you the file!

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.