Sign in to follow this  
Followers 0
AnonymousX

[Solved] All windows taken off WinSetOnTop

3 posts in this topic

#1 ·  Posted (edited)

Hello,

I'm wondering if there is a way to remove all windows with the status set on top? 

I know this can be easily done if you know the title or have the window as an active window, but I'm wondering if there is something that will apply to all windows at once to remove this status?

Thanks

Edited by AnonymousX

Share this post


Link to post
Share on other sites



#3 ·  Posted

15 hours ago, spudw2k said:

You can try using the WinList function in conjuntion with the _WinAPI_SetWindowPos function.

https://www.autoitscript.com/autoit3/docs/functions/WinList.htm

https://www.autoitscript.com/autoit3/docs/libfunctions/_WinAPI_SetWindowPos.htm


 

Thanks that was exactly what I needed. 

For future reference here's the function I used:

HotKeySet("^\", "Toggletop"); toggles window from being set to top
Global $topstatus = 0; determins if a window has been set on top

while true
wend

Func Toggletop()

    if $topstatus== 0 Then;No window is on top
        $hWnd = WinGetHandle("[ACTIVE]")
        $topstatus=1
        WinSetOnTop($tWnd,"",$topstatus)
    Else;A window is on top
        $topstatus=0
        $allwind = WinList()
        For $i=0 to UBound($allwind)-1 step 1
            WinSetOnTop($allwind[$i][0],"",$topstatus)
        Next
    EndIf

    ;WinSetOnTop($window,"",1);My GUI that I permanently want on top

EndFunc

 

1 person likes this

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

  • Similar Content

    • algiuxas
      By algiuxas
      Hello,
      I'm trying to make cursor for my program, and I need to make it on top but not active when pressed on start menu, taskbar or etc. (cursor appears behind taskbar/start menu).
      Somebody could help me with this problem?
      ; A bit of my script #include <GUIConstants.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> #include <GDIPlus.au3> #include <GuiListBox.au3> Global $Bitmap_Mouse_Pic_Dir = @ScriptDir&"\Cursor.png" Global $Bitmap_Mouse_Pic = _GetWHI($Bitmap_Mouse_Pic_Dir) Global $Bitmap_Mouse_PicSel_Dir = @ScriptDir&"\Selection.png" Global $Bitmap_Mouse_PicSel = _GetWHI($Bitmap_Mouse_PicSel_Dir) Global $Bitmap_Mouse_Opt = 255 ; ... For $i = 0 to 0 $GP_guicur[$i] = GUICreate("GP Cursor", 64, 64, $POS[$i][0], $POS[$i][1], $WS_POPUP, $WS_EX_LAYERED, $GUI) WinSetOnTop($GP_curgui[$i],"",1) SetBitmap($GP_curgui[$i], $Bitmap_Mouse_Pic, $Bitmap_Mouse_Opt) GUISetState(@SW_SHOW) Next ; ... For ; ... Sleep(1000) MouseClick("left",5,@DesktopHeight-5) ; ... Next Exit ;______________________________________________________________________; ; Original program by Ejoc ; ; Improved by Adam1213 (autoit 3.2 compatiblity + improved labels; ;______________________________________________________________________; ; $sImage = Path to your image ; Returns = Array[3] ; $Array[0] = Width ; $Array[1] = Height ; $Array[2] = handle to a HBITMAP ; when the image is no longer needed use _WinAPI_DeleteObject($Array[2]) Func _GetWHI($sImage) Local $hImage, $aBitmap[3] _GDIPlus_Startup() $hImage = _GDIPlus_ImageLoadFromFile($sImage) $aBitmap[0] = _GDIPlus_ImageGetWidth($hImage) $aBitmap[1] = _GDIPlus_ImageGetHeight($hImage) $aBitmap[2] = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown() Return $aBitmap EndFunc ;==>_GetWHI ; I changed this so I could shutdown gdiplus once an image has been loaded by _GetWHI() ; just pass it the array returned by _GetWHI() Func SetBitmap($hGUI, $aBitmap, $iOpacity) Local Const $AC_SRC_ALPHA = 1 Local $hScrDC, $hMemDC, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend $hScrDC = _WinAPI_GetDC(0) $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC) $hOld = _WinAPI_SelectObject($hMemDC, $aBitmap[2]) $tSize = DllStructCreate($tagSIZE) $pSize = DllStructGetPtr($tSize) DllStructSetData($tSize, "X", $aBitmap[0]) DllStructSetData($tSize, "Y", $aBitmap[1]) $tSource = DllStructCreate($tagPOINT) $pSource = DllStructGetPtr($tSource) $tBlend = DllStructCreate($tagBLENDFUNCTION) $pBlend = DllStructGetPtr($tBlend) DllStructSetData($tBlend, "Alpha", $iOpacity) DllStructSetData($tBlend, "Format", $AC_SRC_ALPHA) _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA) _WinAPI_ReleaseDC(0, $hScrDC) _WinAPI_SelectObject($hMemDC, $hOld) _WinAPI_DeleteDC($hMemDC) EndFunc ;==>SetBitmap
      Thanks
    • shmuelw1
      By shmuelw1
      I have a script to open a bunch of programs when I start the computer. I was using WinWaitActive to activate a window then type some text, but it was not working. It could be I was opening too many things at the same time. So I found an alternative to use WinSetOnTop, type the text, then use WinSetOnTop again to make it not be on top anymore.

      Just thought I'd mention that alternative in case it helps someone out there in AutoIt-land.