Ahmed97 Posted May 22, 2011 Share Posted May 22, 2011 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 ?? #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 More sharing options...
pieeater Posted May 23, 2011 Share Posted May 23, 2011 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 [spoiler]My UDFs: Login UDF[/spoiler] Link to comment Share on other sites More sharing options...
Ahmed97 Posted May 23, 2011 Author Share Posted May 23, 2011 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 thnxx bro code is working but why when i press hide b4 tybe anything the script hide ^^ Link to comment Share on other sites More sharing options...
Ahmed97 Posted May 23, 2011 Author Share Posted May 23, 2011 (edited) i changed input code to >> " $input = GUICtrlCreateInput("here", 136, 8, 249, 21) " maybe this better Edited May 23, 2011 by TheMaster Link to comment Share on other sites More sharing options...
pieeater Posted May 23, 2011 Share Posted May 23, 2011 (edited) here: expandcollapse popup#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 May 23, 2011 by pieeater [spoiler]My UDFs: Login UDF[/spoiler] Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now