charvi 0 Report post Posted November 29, 2008 Hi, I have written a program with several windows [handles created by GUICreate()]. One among them is a window with a simple List (GUICtrlCrateList) where I display miscellaneous information, including the content of variables, you may consider it being a clone of ConsoleWrite() Before I focus to the window containing the List, I need to know the current focus. How do I do that ? Thanks in advance! Share this post Link to post Share on other sites
oMBRa 1 Report post Posted November 29, 2008 WinGetTitle("[active]") Share this post Link to post Share on other sites
Madza91 0 Report post Posted November 29, 2008 WinGetHandle("","") [quote name='dbzfanatic' post='609696' date='Nov 26 2008, 08:46 AM']This is a help forum not a "write this for me" forum.[/quote](Sorry for bad English) :) Share this post Link to post Share on other sites
charvi 0 Report post Posted November 29, 2008 (edited) Thanks oMBra and n3nE for your reply. expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GuiEdit.au3> #include <GuiMenu.au3> #include <GuiToolBar.au3> #include <GuiComboBoxEx.au3> #include <Array.au3> #include <Constants.au3> Global $winCount $hWin1 = guicreate("",800,400,10,10) $winCount = $winCount + 1 GUISetBkColor(0x838b83,$hWin1) $qubutton = guictrlcreatebutton("Quit",200, 50, 60) GUISetState() $hWin2 = GUICreate("You",300,300,260,200, $ws_popup, $ws_ex_dlgmodalframe) $winCount = $winCount + 1 GUISetBkColor(0xeecbad,$hWin2) $q2button = guictrlcreatebutton("Quit",200, 50, 60) GUISetState() GUICtrlSetState($q2button,$gui_focus) ConsoleWrite("$hWin2="& number($hWin2) & @crlf) debug("$hWin2="& number($hWin2) & @crlf) While 1 $event = GUIGetMsg() Select Case $event = $q2button GUIDelete($hWin2) $winCount = $winCount - 1 Case $event = $GUI_EVENT_CLOSE or ($winCount=1 and $event=$qubutton) ExitLoop EndSelect WEnd Func Debug($var) Global $debug, $hDebug, $hDebugList $hCf = WinGetHandle("","") ConsoleWrite("$hCf="& number($hCf) & @crlf) if $debug = 0 Then $hDebug = GUICreate("Debug window",300,600,630,30,$ws_sysmenu,$ws_ex_topmost) $hDebugList = GUICtrlCreateList("", 0,0, 300,550) GUISetState() $debug = 1 EndIf GUICtrlSetState($hDebug,$gui_focus) GUICtrlSetData($hDebugList, $var) GUICtrlSetState($hCf,$gui_focus) EndFunc The answer of n3nE was the correct answer for my problem. But now, why is the last line of the Function Debug() not working? [GUICtrlSetState($hCf,$gui_focus)] The Quit button of the salmon window was prefocused, so hitting the [Enter] key is the same as clicking it. When the Debug window showed up, hitting [Enter] should have closed the salmon window, but it does not. What am I missing here? Edited November 29, 2008 by charvi Share this post Link to post Share on other sites
oMBRa 1 Report post Posted November 29, 2008 (edited) change GUICtrlSetState($hCf, $gui_focus) to WinActivate($hCf) because $hCf is the handle of a WINDOW not of a CONTROL Edited November 29, 2008 by oMBra Share this post Link to post Share on other sites
charvi 0 Report post Posted November 29, 2008 You are right oMBra! Your change is working perfectly. Thank you! Share this post Link to post Share on other sites