Sign in to follow this  
Followers 0
matthewgutz

Hiding and Showing Window in Foreground

7 posts in this topic

Hello, i just recently started to use autoit and it's AWESOME!!!

I've made a few simple programs that do random stuff, but now i want to do something worth while xD.

Today, my windows hide program trial ran out, so i was thinking about making my own.

I can't seem to find a way to show the windows I've hidden though, so please help :D.

This is what i have so far:

HotKeySet("^z", "hide")
hotkeyset("^x", "show")

#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("hide", 52, 15, 193, 125, -1, $WS_EX_TOOLWINDOW)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Func hide()
    WinSetState("","",@SW_HIDE )
EndFunc

func show()

EndFunc

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hello, i just recently started to use autoit and it's AWESOME!!!

I've made a few simple programs that do random stuff, but now i want to do something worth while xD.

Today, my windows hide program trial ran out, so i was thinking about making my own.

I can't seem to find a way to show the windows I've hidden though, so please help :D.

This is what i have so far:

HotKeySet("^z", "hide")
hotkeyset("^x", "show")

#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("hide", 52, 15, 193, 125, -1, $WS_EX_TOOLWINDOW)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Func hide()
    WinSetState("","",@SW_HIDE )
EndFunc

func show()

EndFunc
You were very close. The way you have referenced the window using "" for the title and the text means that the currently active window is the target. Once you make your window hidden it cannot be the currently active window. So you simply need to use the window handle to make sure the correct window is shown again.

HotKeySet("^z", "hide")
hotkeyset("^x", "show")

#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("hide", 52, 15, 193, 125, -1, $WS_EX_TOOLWINDOW)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Func hide()
    WinSetState($Form1,"",@SW_HIDE )
EndFunc

func show()
   WinSetState($Form1,"",@SW_SHOW )
EndFunc
Edited by martin

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

thanks for the fast reply, but i'm trying to hide the active window, then show that previous window. Is there someway to do that?

Share this post


Link to post
Share on other sites

thanks for the fast reply, but i'm trying to hide the active window, then show that previous window. Is there someway to do that?

Ah I see.

You just need to get the handle to the active window, then use that again when you show it.

$ActiveHandle = WingetHandle(WinGetTitle("",""))


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

omg, thanks so much it works perfectly =).

now that i think about it, is there also a way that i can have an infinite number of windows hidden?

then instead of showing that 1 window, it shows all of the hidden ones?

(sorry for all the trouble)

Edited by matthewgutz

Share this post


Link to post
Share on other sites

omg, thanks so much it works perfectly =).

now that i think about it, is there also a way that i can have an infinite number of windows hidden?

then instead of showing that 1 window, it shows all of the hidden ones?

(sorry for all the trouble)

Have an array to remember all the windows that have been hidden. Well, something like this, no gui needed so I left that out.

HotKeySet("^z", "hide")
HotKeySet("^x", "show");show all windows
HotKeySet("^u", "Unhide");show last hidden window
HotKeySet("^e", "Leave")
Dim $p[20];start with 20 windows allowed for
;use $p[0] for number we have hidden

While 1
    Sleep(30)
WEnd

;hide the currently active window
Func hide()
    Local $activeWh = WinGetHandle(WinGetTitle("", ""))
    If $activeWh <> "" Then
        $p[0] += 1
        If $p[0] > UBound($p) Then ReDim $p[$p[0] + 5]
        WinSetState($activeWh, "", @SW_HIDE)
        $p[$p[0]] = $activeWh
    EndIf

    
EndFunc  ;==>hide

;show all the windows we hid
Func show()
    Local $n
;bring back in reverse order so that the windows might end up in the original order
    If $p[0] > 0 Then
    For $n = $p[0] To 1 Step -1
        WinSetState($p[$n], "", @SW_SHOW)
        WinActivate($p[$n])
    Next
    $p[0] = 0
EndIf

EndFunc  ;==>show

;show last hidden window
Func Unhide()
    If $p[0] Then
        WinSetState($p[$p[0]], "", @SW_SHOW)
        $p[0] -= 1
    EndIf
EndFunc  ;==>Unhide


Func Leave()
    show()
    Exit
EndFunc  ;==>Leave

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

wow u helped me so much thanks :D.

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