Jump to content

Can I make this shorter?


Recommended Posts

Can I make this script shorter?

; ===================================================================

HotKeySet("^!h", "_hide")
HotKeySet("^!u", "_unhide")
HotKeySet("^!#x", "_exit")

; ===================================================================

TraySetToolTip("Window Hider")

; ===================================================================

$msgbox = ""                                  ; Especially Here
                                                      ; Especially Here
Do                                                  ; Especially Here
    MsgBox(0, "Info", "info")           ; Especially Here
    $msgbox = "ok"                       ; Especially Here
Until $msgbox = "ok"                        ; Especially Here

; ===================================================================

While 1
WEnd

; ===================================================================

Func _hide()
    $in_hide = InputBox("Hide Window", "Enter window title:")
    If @error Then Return
    WinSetState($in_hide, "", @SW_HIDE)
EndFunc

Func _unhide()
    $in_unhide = InputBox("Unhide Window", "Enter window title:")
    WinSetState($in_unhide, "", @SW_SHOW)
EndFunc

; ===================================================================

Func _exit()
    $msg = MsgBox(1, "Exit Script", "Are you sure?")
    If $msg = 1 Then
        Exit
    EndIf
EndFunc

; ===================================================================

Thank You

Edited by Hello Me You
Random
Link to comment
Share on other sites

  • Moderators

HotKeySet("^!h", "_hide")
HotKeySet("^!u", "_unhide")
HotKeySet("^!#x", "_exit")
TraySetToolTip("Window Hider")
MsgBox(0, 'Info', 'info');There's only one button, it's always going to = 1 ("ok")
While 1
    Sleep(10);Have to add this line, or risk hurting yoru CPU
WEnd
Func _hide()
    WinSetState(InputBox("Hide Window", "Enter window title:"), "", @SW_HIDE)
EndFunc
Func _unhide()
    WinSetState(InputBox("Unhide Window", "Enter window title:"), "", @SW_SHOW)
EndFunc
Func _exit()
    If MsgBox(4, "Exit Script", "Are you sure?") = 6 Then Exit
EndFunc
I am not commenting on your method or if it's sound, only showing how you can merge functions.

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.

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...