jvanegmond Posted July 12, 2006 Posted July 12, 2006 (edited) I'm looking for a way to close a child window, by pressing it's X. Currently, it closes the whole App. Edit: What really would be PERFECT, is a way to get the active window. Edit2: Case $msg = -3 $Hwnd = WinGetHandle("") Select Case $Hwnd = $MainGUI Exit Case Else GUIDelete($Hwnd) EndSelect Sooo obvious!! Here's the code: expandcollapse popup#include <GUIConstants.au3> $GameTitle = "Name" $MainGUI = GUICreate($GameTitle & " Map Editor", 1024,768,0,0) $FileMenu = GUICtrlCreateMenu("File") $New = GUICtrlCreateMenuItem("New",$FileMenu) GUICtrlCreateMenuItem("",$FileMenu) $Exit = GUICtrlCreateMenuItem("Exit",$FileMenu) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = -3 Exit Case $msg = $Exit Exit Case $msg = $New $Form1 = GUICreate("New", 359, 155, -1,-1,-1,$WS_EX_TOPMOST,$MainGUI) GUICtrlCreateLabel("Name:", 5, 10, 48, 17) $Input1 = GUICtrlCreateInput("Grass Test", 55, 5, 191, 22) GUICtrlCreateGroup("", 5, 35, 260, 115) GUICtrlCreateLabel("Width:", 15, 60, 53, 17) $Input2 = GUICtrlCreateInput("500", 75, 55, 176, 21,$ES_NUMBER) GUICtrlCreateLabel("Height:", 15, 90, 53, 17) $Input3 = GUICtrlCreateInput("500", 75, 85, 176, 21,$ES_NUMBER) GUICtrlCreateLabel("Background:", 10, 120, 60, 17) $Input4 = GUICtrlCreateCombo("Empty", 75, 115, 176, 21) GUICtrlSetData(-1,"Grass|Stone|Dirt","Grass") $Button1 = GUICtrlCreateButton("Ok", 270, 5, 85, 20) $Button2 = GUICtrlCreateButton("Cancel", 270, 30, 85, 20) GUICtrlCreateLabel("Good Luck", 270, 60, 83, 92) GUISetState(@SW_SHOW) While 1 $msg = GuiGetMsg() Select Case $msg = -3 OR $msg = $Button2 ExitLoop Case $msg = $Button1 $Name = GUICtrlRead($Input1) $Width = GUICtrlRead($Input2) $Height = GUICtrlRead($Input3) $Background = GUICtrlRead($Input4) If $Name = "" OR $Width = "" OR $Height = "" Then ExitLoop EndIf GUICreate($Name & ".map - Editor",$Width,$Height,-1,-1,-1,$WS_EX_TOPMOST,$MainGUI) Select Case $Background = "Empty" $File = "" Case $Background = "Grass" $File = @ScriptDir & "\Maps\Textures\Grass1.jpg" Case $Background = "Dirt" $File = @ScriptDir & "\Maps\Textures\Dirt1.jpg" Case $Background = "Stone" $File = @ScriptDir & "\Maps\Textures\Stone1.jpg" EndSelect If $File <> "" Then For $x = 0 to $Width/50 For $y = 0 to $Height/50 GUICtrlCreatePic($File,$x*50,$y*50,50,50) Next Next $File = "" EndIf GUISetState() ExitLoop EndSelect WEnd GUIDelete($Form1) EndSelect WEnd Edited July 12, 2006 by Manadar github.com/jvanegmond
Xenobiologist Posted July 12, 2006 Posted July 12, 2006 Hi, maybe some day you could use this, too: MsgBox(0,'', _WinGetActive()) Func _WinGetActive() $OptWSC = Opt('WinSearchChildren', 1) $aWinList = WinList() For $iCount = 1 To $aWinList[0][0] If $aWinList[$iCount][0] <> '' And WinActive($aWinList[$iCount][0]) Then Opt('WinSearchChildren', $OptWSC) Return $aWinList[$iCount][0] EndIf Next Opt('WinSearchChildren', $OptWSC) Return 0 EndFunc 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
Moderators SmOke_N Posted July 12, 2006 Moderators Posted July 12, 2006 Should probably just make it a different function:expandcollapse popup#include <GUIConstants.au3> Dim $NewGUI = 0 $GameTitle = "Name" $MainGUI = GUICreate($GameTitle & " Map Editor", 1024,768,0,0) $FileMenu = GUICtrlCreateMenu("File") $New = GUICtrlCreateMenuItem("New",$FileMenu) GUICtrlCreateMenuItem("",$FileMenu) $Exit = GUICtrlCreateMenuItem("Exit",$FileMenu) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = -3 Exit Case $msg = $Exit Exit Case $msg = $New $Form1 = GUICreate("New", 359, 155, -1,-1,-1,$WS_EX_TOPMOST,$MainGUI) GUICtrlCreateLabel("Name:", 5, 10, 48, 17) $Input1 = GUICtrlCreateInput("Grass Test", 55, 5, 191, 22) GUICtrlCreateGroup("", 5, 35, 260, 115) GUICtrlCreateLabel("Width:", 15, 60, 53, 17) $Input2 = GUICtrlCreateInput("500", 75, 55, 176, 21,$ES_NUMBER) GUICtrlCreateLabel("Height:", 15, 90, 53, 17) $Input3 = GUICtrlCreateInput("500", 75, 85, 176, 21,$ES_NUMBER) GUICtrlCreateLabel("Background:", 10, 120, 60, 17) $Input4 = GUICtrlCreateCombo("Empty", 75, 115, 176, 21) GUICtrlSetData(-1,"Grass|Stone|Dirt","Grass") $Button1 = GUICtrlCreateButton("Ok", 270, 5, 85, 20) $Button2 = GUICtrlCreateButton("Cancel", 270, 30, 85, 20) GUICtrlCreateLabel("Good Luck", 270, 60, 83, 92) GUISetState(@SW_SHOW) While 1 $msg = GuiGetMsg() Select Case ($msg = -3 OR $msg = $Button2) And Not WinExists($NewGUI) ExitLoop Case $msg = -3 And WinExists($NewGUI) GUIDelete($NewGUI) Case $msg = $Button1 $Name = GUICtrlRead($Input1) $Width = GUICtrlRead($Input2) $Height = GUICtrlRead($Input3) $Background = GUICtrlRead($Input4) If $Name = "" OR $Width = "" OR $Height = "" Then ExitLoop EndIf _ChildGUI($Name, $Width, $Height, $Background) EndSelect WEnd GUIDelete($Form1) EndSelect WEnd Func _ChildGUI($Name, $Width, $Height, $Background) $NewGUI = GUICreate($Name & ".map - Editor",$Width,$Height,-1,-1,-1,$WS_EX_TOPMOST,$MainGUI) Select Case $Background = "Empty" $File = "" Case $Background = "Grass" $File = @ScriptDir & "\Maps\Textures\Grass1.jpg" Case $Background = "Dirt" $File = @ScriptDir & "\Maps\Textures\Dirt1.jpg" Case $Background = "Stone" $File = @ScriptDir & "\Maps\Textures\Stone1.jpg" EndSelect If $File <> "" Then For $x = 0 to $Width/50 For $y = 0 to $Height/50 GUICtrlCreatePic($File,$x*50,$y*50,50,50) Next Next $File = "" EndIf GUISetState() While 1 $msg2 = GUIGetMsg() If $msg2 = -3 Then ExitLoop WEnd GUIDelete($NewGUI) EndFunc 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.
jvanegmond Posted July 13, 2006 Author Posted July 13, 2006 Thanks Meger. Smoke, i already did that yesterday. So i kinda beat you to it just kiddin, thanks for the help. github.com/jvanegmond
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