Jump to content

A small problem


Recommended Posts

My script has an inputbox, you type a window name in it and it hides the window. But when you press ctrl+alt+h (hotkey to the input box) and you press cancel, it hides the active window. How can I stop this?

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

While 1
WEnd

Func _hide()
    $in_hide = InputBox("Hide Window", "Enter window title:")
    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
Random
Link to comment
Share on other sites

Hi,

make a GLOBAL variable to store the title otherwise .... :whistle:

And put a sleep into your while wend.

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

not tested.. but it may work.

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

While 1
WEnd

Func _hide()
    $in_hide = InputBox("Hide Window", "Enter window title:")
if $in_hide = "" then
return
else


    WinSetState($in_hide, "", @SW_HIDE)
endif
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
Edited by t0ddie

Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Link to comment
Share on other sites

  • Developers

My script has an inputbox, you type a window name in it and it hides the window. But when you press ctrl+alt+h (hotkey to the input box) and you press cancel, it hides the active window. How can I stop this?

Test the returned @error for the inputbox ...

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Test the returned @error for the inputbox ...

that would also work. it will give an error if blank.

i just used code to check to see if the variable was blank...

either way will work. jdeb method would actually be better theres a couple of words less to code. lol

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

While 1
WEnd

Func _hide()
    $in_hide = InputBox("Hide Window", "Enter window title:")
if @error  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
Edited by t0ddie

Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

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