Jump to content

Help Please My script keep hide


Recommended Posts

This script for hide any window i tybe it name

but when i tybe the window name and press hide the script hide and the window dont hide

another meaning : Hide button : hide the script not the window

What Should i do ?? :unsure:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>


$Form1 = GUICreate("Window Hider", 398, 79, 299, 241)
$input = GUICtrlCreateInput("", 136, 8, 249, 21)
$txt = GUICtrlCreateLabel("Enter Window Name Here", 8, 10, 128, 17)
$hButton = GUICtrlCreateButton("Hide", 160, 40, 75, 33, $WS_GROUP)
$shButton = GUICtrlCreateButton("Show", 16, 40, 75, 33, $WS_GROUP)
$Exit = GUICtrlCreateButton("Exit", 312, 40, 75, 33, $WS_GROUP)
GUISetState(@SW_SHOW)
$Directory = GUICtrlRead($input)


While 1
    $nMsg = GUIGetMsg()
    Select
        Case $nMsg = $GUI_EVENT_CLOSE Or $nMsg = $Exit
            Exit
        Case $nMsg = $hButton
            If $hButton Then
            WinSetState($Directory, "", @SW_HIDE)

        Case $nMsg = $shButton
            If $shButton Then
            WinSetState($Directory, "", @SW_SHOW)
    EndSelect
WEnd
Link to comment
Share on other sites

i revised your code and here is what i got to work:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>


$Form1 = GUICreate("Window Hider", 398, 79, 299, 241)
$input = GUICtrlCreateInput("", 136, 8, 249, 21)
$txt = GUICtrlCreateLabel("Enter Window Name Here", 8, 10, 128, 17)
$hButton = GUICtrlCreateButton("Hide", 160, 40, 75, 33, $WS_GROUP)
$shButton = GUICtrlCreateButton("Show", 16, 40, 75, 33, $WS_GROUP)
$Exit = GUICtrlCreateButton("Exit", 312, 40, 75, 33, $WS_GROUP)
GUISetState(@SW_SHOW)



While 1
    $Directory = GUICtrlRead($input)
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $Exit
            Exit
        Case $hButton
            WinSetState($Directory, "", @SW_HIDE)
        Case $shButton
            WinSetState($Directory, "", @SW_SHOW)
    EndSwitch
WEnd

what i did was change the select loop into a switch loop and took out the if then's. i also made it loop the $directory so that it checks the name every time the loop starts over. hope you learned from that :unsure:

[spoiler]My UDFs: Login UDF[/spoiler]

Link to comment
Share on other sites

i revised your code and here is what i got to work:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>


$Form1 = GUICreate("Window Hider", 398, 79, 299, 241)
$input = GUICtrlCreateInput("", 136, 8, 249, 21)
$txt = GUICtrlCreateLabel("Enter Window Name Here", 8, 10, 128, 17)
$hButton = GUICtrlCreateButton("Hide", 160, 40, 75, 33, $WS_GROUP)
$shButton = GUICtrlCreateButton("Show", 16, 40, 75, 33, $WS_GROUP)
$Exit = GUICtrlCreateButton("Exit", 312, 40, 75, 33, $WS_GROUP)
GUISetState(@SW_SHOW)



While 1
    $Directory = GUICtrlRead($input)
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $Exit
            Exit
        Case $hButton
            WinSetState($Directory, "", @SW_HIDE)
        Case $shButton
            WinSetState($Directory, "", @SW_SHOW)
    EndSwitch
WEnd

what i did was change the select loop into a switch loop and took out the if then's. i also made it loop the $directory so that it checks the name every time the loop starts over. hope you learned from that :unsure:

thnxx bro code is working :>

but why when i press hide b4 tybe anything the script hide ^^

Link to comment
Share on other sites

here:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>


$Form1 = GUICreate("Window Hider", 398, 79, 299, 241)
$input = GUICtrlCreateInput("", 136, 8, 249, 21)
$txt = GUICtrlCreateLabel("Enter Window Name Here", 8, 10, 128, 17)
$hButton = GUICtrlCreateButton("Hide", 160, 40, 75, 33, $WS_GROUP)
$shButton = GUICtrlCreateButton("Show", 16, 40, 75, 33, $WS_GROUP)
$Exit = GUICtrlCreateButton("Exit", 312, 40, 75, 33, $WS_GROUP)
GUISetState(@SW_SHOW)



While 1
    $Directory = GUICtrlRead($input)
    $nMsg = GUIGetMsg()
    $window = WinExists($Directory)
    Switch $nMsg
        Case $Exit
            Exit
        Case $hButton
            If $window = 0 Then
                MsgBox(0, "Error", "window dosen't exist")
            Else
                WinSetState($Directory, "", @SW_HIDE)
            EndIf
        Case $shButton
            If $window = 0 Then
                MsgBox(0, "Error", "window dosen't exist")
            Else
                WinSetState($Directory, "", @SW_SHOW)
            EndIf
    EndSwitch
WEnd

if the window doesn't exist then the script wont hide or show.

edit: fixed the code and discription

Edited by pieeater

[spoiler]My UDFs: Login UDF[/spoiler]

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