Jump to content

Get Pixel Color from Minimized Window


Splash
 Share

Recommended Posts

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:
Link to comment
Share on other sites

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?

Link to comment
Share on other sites

  • Moderators

Thanks, anyone have an ideia about it?

Something wrong with your search feature?

http://www.autoitscript.com/forum/index.ph...xel%2BMinimized

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.

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

  • Moderators

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.

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

  • Moderators

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.

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

  • Moderators

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.

Link to comment
Share on other sites

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!

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...