Jump to content

Make a window visible BUT not active


DLXS
 Share

Go to solution Solved by BrewManNH,

Recommended Posts

Hi,

I have two windows overlapped (can't be different). I'm taking screenshots at them as fast as possible (this has to be the fastest the better) in a loop as I want to detect changes in them.

However, when I do so, as I have to make the windows active in order to show them on the screen and take the screenshot, I can't do anything else as the script doesn't stop making these windows' active and therefore, I lose focus on anything else.

Is it possible to put a window in front (or make it visible, show...) WITHOUT activating it? This way, window will be put in front but I can carry on using the computer for other stuff. Script will take a screenshot and do whatever it has to do.

Any ideas?

The code of this part:

For $i = 1 To  UBound($ventanas)-1
   If $ventanas[$i][0] <> ""  Then

        ;WinActivate($ventanas[$i][0]) This one makes computer useless
    ;WinSetState($ventanas[$i][0], "", @SW_SHOW)  Also makes computer useless
    $handle = WinGetHandle($ventanas[$i][0])    
    if $screens <> "" Then
        _GDIPlus_ImageDispose($screens) 
    EndIf

    _ScreenCapture_CaptureWnd(@MyDocumentsDir & $filename, $handle) 

    $screens = _GDIPlus_ImageLoadFromFile(@MyDocumentsDir & $filename)....

$ventanas comes from a function which returns a winlist(). Basically, in order to use _ScreenCapture_CaptureWnd, the window has to be on top even if I pass the handle (unless I'm wrong), and I don't know how to do it without making it active and avoiding converting the computer into something useless.

Thanks

Link to comment
Share on other sites

  • Solution

You can use WinSetState and @SW_SHOWNOACTIVATE to show the window but not make it active, it might work but no guarantees that it would be possible considering you're taking screenshots of a window, but trying to still use the other windows in the background.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Hi,

This should work. However, for some reason it doesn't, even if I use SW_SHOW. That's weird. With SW_SHOW it should work. Any ideas why it doesnt? I can't see the window using SW_SHOW. If SW_SHOW works, have no reason to think @SW_SHOWNOACTIVATE won't and this will sort my problems out.

For $i = 1 To  UBound($ventanas)-1
   If $ventanas[$i][0] <> ""  Then

    ;WinActivate($ventanas[$i][0]) THIS WORKS
    ;WinSetState($ventanas[$i][0], "", @SW_SHOW)  THIS DOESNT, WHY?
    $handle = WinGetHandle($ventanas[$i][0])    
    if $screens <> "" Then
        _GDIPlus_ImageDispose($screens) 
    EndIf

    _ScreenCapture_CaptureWnd(@MyDocumentsDir & $filename, $handle) 

    $screens = _GDIPlus_ImageLoadFromFile(@MyDocumentsDir & $filename)....

Another option, how to take a screenshot from a hidden window. I think in that case I may have to call a user32dll.

Another question related: sw_hide also hides the window in the taskbar? Because I've tried to use SW_HIDE + SW_SHOW and I think it works but some windows dissapeared even from the taskbar. Not sure if it's not working properly, it it closes windows... A bit lost.

Edited by DLXS
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...