blink314 Posted September 15, 2005 Share Posted September 15, 2005 I've searched in the help file and on the forums here but still cant figure this out. I have a GUI window I made ($main) and at some point I create and bring another GUI window to the front ($GUI2). I can work with GUI2 as much as I want, I can even close it... but I cannot get focus to go back to Main. I've tried using GUISwitch after closing GUI2, I've tried using GUISetState... nothing works. I am using events for Main and while I tried to have GUI2 use events, GUI2 wouldnt even work. Once I used events on Main and Polling on GUI2, GUI2 works fine, but I still cant get back to Main correctly. The example in the helpfile, while it creates another GUI, does not actually show it so I'm lost there. Any suggestions? Kevin Link to comment Share on other sites More sharing options...
GaryFrost Posted September 15, 2005 Share Posted September 15, 2005 posting the code you can't get to work would help, here's an example, not using the OnEvent tho. expandcollapse popup#include <GuiConstants.au3> $main = GUICreate("MyGUI", 392, 322) $Button_1 = GUICtrlCreateButton("Input", 140, 190, 70, 30) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button_1 GUISetState(@SW_DISABLE, $main) _Input() GUISetState(@SW_ENABLE, $main) GUISetState(@SW_SHOW) Case Else ;;; EndSelect WEnd Exit Func _Input() $popup = GUICreate("PopUP", 191, 85, -1, -1, $WS_DLGFRAME, $WS_EX_TOPMOST) $Input_1 = GUICtrlCreateInput("Input1", 0, 0, 180, 20) $Button_2 = GUICtrlCreateButton("OK", 60, 40, 60, 20) GUISetState() While 1 $msg2 = GUIGetMsg() Select Case $msg2 = $Button_2 ExitLoop Case Else ;;; EndSelect WEnd GUIDelete($popup) EndFunc;==>_Input SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
jpm Posted September 15, 2005 Share Posted September 15, 2005 I've searched in the help file and on the forums here but still cant figure this out. I have a GUI window I made ($main) and at some point I create and bring another GUI window to the front ($GUI2). I can work with GUI2 as much as I want, I can even close it... but I cannot get focus to go back to Main. I've tried using GUISwitch after closing GUI2, I've tried using GUISetState... nothing works. I am using events for Main and while I tried to have GUI2 use events, GUI2 wouldnt even work. Once I used events on Main and Polling on GUI2, GUI2 works fine, but I still cant get back to Main correctly.The example in the helpfile, while it creates another GUI, does not actually show it so I'm lost there. Any suggestions? Kevin<{POST_SNAPBACK}>You need to use Winactivate($GUIMAIN). The Guiswitch does not act on focus but just allow nex GUI functions to work on the specific window it is need if you want to create new control. modification working with ControlID does not even need to have a GuiSwitch before. Link to comment Share on other sites More sharing options...
blink314 Posted September 16, 2005 Author Share Posted September 16, 2005 Ok, I continued to play around and couldnt get anything to work. I did get your code to work gaFrost so I know it's my implementation! Here is a quick overview of my GUI handling. I tried various configurations of guiswitch() and winactivate() to no effect. Any further suggestions? expandcollapse popup#include <GuiConstants.au3> opt ("GUIOnEventMode", 1) $Main = GUICreate("Sort Anything!!", 600, 560, 400, 400, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS) GUISetOnEvent($GUI_EVENT_CLOSE, "GUIevent");This line tells the GUI to close when the "X" is clicked GUISetState(@sw_show,$Main) While 1 Sleep(8000) WEnd Exit Func GUIevent() Exit EndFunc ;==>GUIevent Func SomeOtherFunc() ;Pressing a button (not in this example!) on the $Main GUI brings you to this function. It runs and then I want to display ; the second GUI... _2ndGUIDisplay($DataArray, $main, True, "") Endfunc Func _2ndGUIDisplay(ByRef $adArray, $adParentWindow,$FirstDimCol = True, $adTitle = "Display") Opt("GUIOnEventMode", 0) ;0=disabled, 1=OnEvent mode enabled ;Layout GUI $MainGUI = GUICreate($adTitle, $adGUIwidth, $adGUIHeight, -1, -1, BitOR($WS_POPUP, $WS_CAPTION, $WS_SIZEBOX, $WS_MAXIMIZEBOX,$WS_EX_TOPMOST)) GUISetState (@SW_SHOW, $Maingui) ;Wait for user to close box Do $msg = GUIGetMsg() if $msg = $GUI_EVENT_CLOSE Then $AllDone = 1 EndIf Until $AllDone GUIDelete($MainGUI) EndFunc ;==>_2ndGUIDisplay Link to comment Share on other sites More sharing options...
GaryFrost Posted September 16, 2005 Share Posted September 16, 2005 (edited) This works, might be a problem with switching between OnEvent and GuiEvent CODE ;========================================================================= #include <GuiConstants.au3> opt("GUIOnEventMode", 1) Dim $Main = GUICreate("Sort Anything!!", 600, 560) GUISetOnEvent($GUI_EVENT_CLOSE, "GUIevent");This line tells the GUI to close when the "X" is clicked $button = GUICtrlCreateButton("test", 10, 10) GUICtrlSetOnEvent($button, "SomeOtherFunc") GUISetState(@sw_show, $Main) While 1 Sleep(250) WEnd Exit Func GUIevent() Exit EndFunc ;==>GUIevent Func SomeOtherFunc() ;Pressing a button (not in this example!) on the $Main GUI brings you to this function. It runs and then I want to display ; the second GUI... GUISetState(@SW_DISABLE, $Main) ;~ _2ndGUIDisplay($DataArray, $Main, True, "") opt("GUIOnEventMode", 0) ;0=disabled, 1=OnEvent mode enabled _2ndGUIDisplay() opt("GUIOnEventMode", 1) ;0=disabled, 1=OnEvent mode enabled GUISetState(@SW_ENABLE, $Main) WinActivate($Main) EndFunc ;==>SomeOtherFunc ;~ Func _2ndGUIDisplay(ByRef $adArray, $adParentWindow, $FirstDimCol = True, $adTitle = "Display") Func _2ndGUIDisplay($adTitle = "Display") ;Layout GUI $ChildGUI = GUICreate($adTitle, 500, 500, -1, -1, BitOR($WS_POPUP, $WS_CAPTION, $WS_SIZEBOX, $WS_MAXIMIZEBOX, $WS_EX_TOPMOST)) GUISetState(@SW_SHOW, $ChildGUI) ;Wait for user to close box Do $msg = GUIGetMsg() Until $msg = $GUI_EVENT_CLOSE GUIDelete($ChildGUI) EndFunc ;==>_2ndGUIDisplay Edited September 23, 2005 by gafrost SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
mr_carter Posted September 16, 2005 Share Posted September 16, 2005 I think my problem is on the same subject as this one so I will post here. Attached is my script. I have a menu called Desktop Configuration, When I select a site (Vancouver) it brings up another GUI when I exit that GUI I no long can use any of the controls on the first GUI . Any help would be greatly appreciated. Sorry if the code is a mess Im still a newbie.. Thanks in advance for you help -C2 : info.zip Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted September 17, 2005 Moderators Share Posted September 17, 2005 Looks like this project will be fun for you. 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. 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