Jump to content
Sign in to follow this  
Shade

Window Hider

Recommended Posts

Hey, I'm pretty new to AutoIt. I wrote this script that hides a window and then shows it again. Check it out, tell me what you think. :)

Welcome to AutiIt Shade, well done on your first script.

You'll find many useful (and not so useful) things that AutoIt can do

If you're never sure about something just ask in the appropriate forum as generally someone somewhere is always watching

rick


Who needs puzzles when we have AutoIt!!

Share this post


Link to post
Share on other sites

Very Good job!

Can't get this to work!

Trying to make it so you can hide 2 windows.

HotKeySet ("^+z", "Hide")
HotKeySet ("^+x", "Show")
HotKeySet ("+z", "Hide2")
HotKeySet ("+x", "Show2")
Opt("TrayIconHide", 1)
$hidden = "no"
$hidden2 = "no"
While 1
    If $hidden = "yes" Then
        Sleep (10)
    Else
        Global $title = WinGetTitle("")
        Sleep (10)
    EndIf
    If $hidden2 = "yes" Then
        Sleep(10)
    Else
        Global $title2 = WinGetTitle("")
        Sleep(10)
    EndIf
WEnd

Func Hide()
    $hidden = "yes"
    If WinExists("" & $title) Then
    WinSetState ("" & $title, "", @SW_HIDE)
    EndIf
EndFunc

Func Show()
    $hidden = "no"
    If WinExists("" & $title) Then
    WinSetState ("" & $title, "", @SW_SHOW)
    EndIf
EndFunc

Func Hide2()
    $hidden2 = "yes"
    If WinExists("" & $title2) Then
    WinSetState ("" & $title2, "", @SW_HIDE)
    EndIf
EndFunc

Func Show2()
    $hidden2 = "no"
    If WinExists("" & $title2) Then
    WinSetState ("" & $title2, "", @SW_SHOW)
    EndIf
EndFunc

[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Share this post


Link to post
Share on other sites

Think this work

HotKeySet ("^+z", "Hide")
HotKeySet ("^+x", "Show")
HotKeySet ("+z", "Hide2")
HotKeySet ("+x", "Show2")
Opt("TrayIconHide", 1)
$hidden = "no"
$hidden2 = "no"
While 1
    If $hidden = "yes" Then
        Sleep (10)
    Else
        Global $title = WinGetTitle("")
        Sleep (10)
    EndIf
    If $hidden2 = "yes" Then
        Sleep(10)
    Else
        Global $title2 = WinGetTitle("")
        Sleep(10)
    EndIf
WEnd

Func Hide()
    $hidden = "yes"
    If WinExists($title) Then
    WinSetState ($title, "", @SW_HIDE)
    EndIf
EndFunc

Func Show()
    $hidden = "no"
    If WinExists( $title) Then
    WinSetState ($title , "", @SW_SHOW)
    EndIf
EndFunc

Func Hide2()
    $hidden2 = "yes"
    If WinExists($title2 ) Then
    WinSetState ($title2, "", @SW_HIDE)
    EndIf
EndFunc

Func Show2()
    $hidden2 = "no"
    If WinExists($title2) Then
    WinSetState $title2 ,"", @SW_SHOW)
    EndIf
EndFunc

My Scripts:Radioblog Club Music DownloaderOther stuff:Fun movieIm serious read the help file it helps :PFight 'Till you drop. Never stop, You Cant give up. Til you reach the top Fight! you’re the best in town Fight!

Share this post


Link to post
Share on other sites

Well actually that doesn't work, but this does (came from you rambo, just some mistakes fixed):

HotKeySet ("^z", "Hide")
HotKeySet ("^!z", "Show")
HotKeySet ("^x", "Hide2")
HotKeySet ("^!x", "Show2")
Opt("TrayIconHide", 1)
$hidden = "no"
$hidden2 = "no"
While 1
    If $hidden = "yes" Then
        Sleep (10)
    Else
        Global $title = WinGetTitle("")
        Sleep (10)
    EndIf
    If $hidden2 = "yes" Then
        Sleep(10)
    Else
        Global $title2 = WinGetTitle("")
        Sleep(10)
    EndIf
WEnd

Func Hide()
    $hidden = "yes"
    If WinExists($title) Then
    WinSetState ($title, "", @SW_HIDE)
    EndIf
EndFunc

Func Show()
    $hidden = "no"
    If WinExists( $title) Then
    WinSetState ($title , "", @SW_SHOW)
EndIf
EndFunc

Func Hide2()
    $hidden2 = "yes"
    If WinExists($title2 ) Then
    WinSetState ($title2, "", @SW_HIDE)
    EndIf
EndFunc

Func Show2()
    $hidden2 = "no"
    If WinExists($title2) Then
    WinSetState ($title2 ,"", @SW_SHOW)
    EndIf
EndFunc

Regards

Edited by marfdaman

Don't take my pic to serious...~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~You Looked, but you did not see!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Share this post


Link to post
Share on other sites

It still only hides 1 window for me. Please fix.

LOL, as long as you've been here, you would think you would try to contribute a fix yourself if it didn't work right.

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.

Share this post


Link to post
Share on other sites

Firestorm -

I am using the one that marfdaman used:

HotKeySet ("^+z", "Hide")
HotKeySet ("^+x", "Show")
HotKeySet ("^!z", "Hide2")
HotKeySet ("^!x", "Show2")
Opt("TrayIconHide", 1)
$hidden = "no"
$hidden2 = "no"
While 1
    If $hidden = "yes" Then
        Sleep (10)
    Else
        Global $title = WinGetTitle("")
        Sleep (10)
    EndIf
    If $hidden2 = "yes" Then
        Sleep(10)
    Else
        Global $title2 = WinGetTitle("")
        Sleep(10)
    EndIf
WEnd

Func Hide()
    $hidden = "yes"
    If WinExists($title) Then
    WinSetState ($title, "", @SW_HIDE)
    EndIf
EndFunc

Func Show()
    $hidden = "no"
    If WinExists( $title) Then
    WinSetState ($title , "", @SW_SHOW)
    EndIf
    If WinExists($title2) Then
        WinSetState($title2, "", @SW_SHOW)
    EndIf
EndFunc

Func Hide2()
    $hidden2 = "yes"
    If WinExists($title2 ) Then
    WinSetState ($title2, "", @SW_HIDE)
    EndIf
EndFunc

Func Show2()
    $hidden2 = "no"
    If WinExists($title2) Then
    WinSetState ($title2 ,"", @SW_SHOW)
    EndIf
EndFunc

I edited the hotkeys, Hide 1 is CTRL-SHIFT-Z, Show 1 is CTRL-SHIFT-X, Hide 2 is CTRL-ALT-Z, Show 2 is CTRL-ALT-X. This should work out for you.

Share this post


Link to post
Share on other sites

MsgBox(48, "Window 1", "After clicking OK, please bring the first window you want to hide to the front of your screen within 2 seconds.")
Sleep(2000)
Dim $hWnd1 = WinGetTitle("")

MsgBox(48, "Window 2", "After clicking OK, please bring the second window you want to hide to the front of your screen within 2 seconds.")
Sleep(2000)
Dim $hWnd2 = WinGetTitle("")


;...


Func Show2()
    $hidden2 = "no"
    If WinExists($hWnd2) Then
    WinSetState ($hWnd2,"", @SW_SHOW)
    EndIf
EndFunc
;et cetera

Share this post


Link to post
Share on other sites

Cool script! :(

Did anyone notice that it can hide all the icons on your desktop? :)

taurus905


"Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs

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  

×
×
  • Create New...