Jump to content
WoodGrain

move window to front without focus

Recommended Posts

Hi All,

I'd like to move a window to the top of the stack without it being active.
I think it's called z-order in programming?

I've tried these 2 options (commenting out 1 at a time obviously), but the 1st doesn't seem to do anything, and the 2nd prevents it from being moved behind the other programs even after clicking on it and then clicking on another window behind it:

Local $hWnd = WinGetHandle("[CLASS:MSPaintApp]")
_WinAPI_SetWindowPos($hWnd, $HWND_TOP, 0, 0, 0, 0, BitOR($SWP_FRAMECHANGED, $SWP_NOMOVE, $SWP_NOSIZE))
_WinAPI_SetWindowPos($hWnd, $HWND_TOPMOST, 0, 0, 0, 0, BitOR($SWP_FRAMECHANGED, $SWP_NOMOVE, $SWP_NOSIZE))

What can I do to move something to the top of the z-order while allowing it to be manually moved back in the z-order?

Thanks!

Share this post


Link to post
Share on other sites

Thanks JohnOne, I've added that in, however I'm still in the same position, $HDND_TOP doesn't move the window to the top of the z-order, actually it doesn't seem to move it at all in the z-order, any ideas how I can get it to move to the top of the z-order without it permanently remaining the top of the z-order (which $HWND_TOPMOST seems to do)?

This is my current code:
Local $hWnd = WinGetHandle("[CLASS:MSPaintApp]")
_WinAPI_SetWindowPos($hWnd, $HWND_TOP, 0, 0, 0, 0, BitOR($SWP_FRAMECHANGED, $SWP_NOACTIVATE, $SWP_NOMOVE, $SWP_NOSIZE))

Share this post


Link to post
Share on other sites

How about something like this?

#include <Constants.au3>
#include <WinApi.au3>

Local $hWnd = WinGetHandle("[ACTIVE]", "")

$iPID = Run("notepad.exe")
Sleep(200)
WinActivate($hWnd)
Sleep(500)

$hWnd = WinGetHandle("[CLASS:Notepad]")
_WinAPI_SetWindowPos($hWnd, $HWND_TOPMOST, 0, 0, 0, 0, BitOR( $SWP_NOACTIVATE, $SWP_NOMOVE, $SWP_NOSIZE))
_WinAPI_SetWindowPos($hWnd, $HWND_NOTOPMOST, 0, 0, 0, 0, BitOR( $SWP_NOACTIVATE, $SWP_NOMOVE, $SWP_NOSIZE))

Sleep(2000)
ProcessClose($iPID)

 

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

  • Similar Content

    • By LWC
      I have multiple network adapters but only one is actually connected.
      I thus use @IPAddress1 in my scripts whereas @IPAddress2-4 return 0.0.0.0
      But recently I've installed the VirtualBox emulator and it took over @IPAddress1 which means my real connection is now @IPAddress2.
      Why is that? Is there a way to make AutoIt skip to @IPAddress2 if @IPAddress1 is used by an emulator?
      In the attached screenshot it's temporarily disabled so I can revive my scripts which all already use @IPAddress1.

       
      Update: here's the solution.
    • By ThePoro
      Hi everyone.
      I want to ask about this : 
      I want it runs from 1 to 100 and It opens 10 firefox profiles then access youtube. After I close a firefox window, the loop runs and wait for another window close until loop ends
      I have a loop like this.
      Func launch() Local $from = Int(GUICtrlRead($input1)) Local $to = Int(GUICtrlRead($input2)) If $to <> "" Then While $from <= $to Local $profile = $to _RunDos("start firefox.exe -p " & $profile & " -no-remote youtube.com") $to=$to+1 WEnd Else Local $profile = $to _RunDos("start firefox.exe -p " & $profile & " -no-remote youtube.com") EndIf EndFunc Is there any solution?
      Thank you!
    • By Rhidlor
      I was wondering if there was a library or something which provides the capability to Send() to inactive windows, and I know what you're thinking, I could just use ControlSend(); the reason I can't use that in this situation is because I need to hold down keys for specific prolonged periods of time. Also activating the window, Send()ing then de-activating the window isn't really an option here, I need the target window to always be in the background. I've looked around the forums for an adequate amount of time and didn't find anything useful, perhaps because the threads were all 10 years old, nevertheless, if anyone has any suggestions they would be greatly appreciated.
      Thanks!
    • By bbProg
      Hi,
       
      how can I wait activate for windows with information as in the photos attached?
      Class is not being recognized by the script.
       
      thanks in advanced.



    • By rcmaehl
      A UDF with Extended Functions for Window Management
       
      Notes:
      Fixes WinGetClassList's barbaric returning of a @LF separated string instead of an array.
       
      Potential Uses:
      Automating applications that change their controls' handles/classes on each launch (e.g. half of Cisco's programs)
       
      Functions:
      _WinGetClassList
      _WinGetClassNNList
      _WindowGetHandleList
      _WindowGetHandleListFromPos
       
      Download: 
      WindowEx.zip  (v0.4)
       
      Changelog:
      10/04/2016 (v0.4): _WinGetClassNNList Fixed : Not Returning an Index when using $2D_ARRAY _WinGetClassNNList Fixed : Not Properly returning $aArray[x][1] on Classes with instances > 9 when using $2D_ARRAY 10/03/2016 (v0.3): _WinGetClassList Added : Exactly the same as WinGetClassList but returns a more civilized Array _WinGetClassNNList Added : Returns Classes and their instances in either a 1D or 2D array depending on Flags _WindowGetHandleList Renamed: _WinGetHandleList SCRIPT BREAKING! _WindowGetHandleListFromPos Renamed: _WinGetHandleListFromPos SCRIPT BREAKING! 10/01/2016 (v0.2): WindowsExConstants.au3 Added : Flags in _WindowGetHandleListFromPos _WindowGetHandleListFromPos Removed: ConsoleWrite left in during debug _WindowGetHandleListFromPos Added : Flag for if part of a Control is at $X, $Y return it as well. 10/01/2016 (v0.1): _WindowGetHandleList Added : Retrieves the handles of classes from a window. _WindowGetHandleListFromPos Added : Retrieves the handles of classes at a specific position from a window. Known and Reported Bugs:
      None reported To Do:
      To Be Decided. Opinions welcome! Upcoming Changes:
      To Be Decided.
×
×
  • Create New...