infernothebest Posted September 28, 2008 Share Posted September 28, 2008 (edited) if i make a second gui in my first gui how can i comunnicate between the gui's, lets say string data? i add a little example with the button get data i wanna gt the data from the second gui #include <GUIConstantsEx.au3> GUICreate("My GUI") GUISetState(@SW_SHOW) $Button_1 = GUICtrlCreateButton("Run Notepad", 10, 30, 100) $Button_2 = GUICtrlCreateButton("get data", 150, 30, 100) While 1 $msg = GUIGetMsg() if $msg =$Button_2 then msgbox(0,"",$stringdata) endif if $msg = $Button_1 Then secondgui() EndIf If $msg = $GUI_EVENT_CLOSE Then Exit WEnd Func secondgui() GUICreate("second GUI") $stringdata=GUICtrlCreateLabel("Line 1 Cell 1", 10, 30, 70) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd EndFunc Edited September 28, 2008 by infernothebest Apple Keybord shortcuts for XP Link to comment Share on other sites More sharing options...
DW1 Posted September 28, 2008 Share Posted September 28, 2008 There are many ways to do this, but a simple way would be like this: #include <GUIConstantsEx.au3> EnvSet('StringData', 'Nothing yet.') Global $stringdata, $SecondGUI $mainGUI = GUICreate("My GUI") GUISetState(@SW_SHOW) $Button_1 = GUICtrlCreateButton("Run Notepad", 10, 30, 100) $Button_2 = GUICtrlCreateButton("get data", 150, 30, 100) While 1 $msg = GUIGetMsg(1) If $msg[0] = $Button_2 Then MsgBox(0, "", EnvGet('StringData')) EndIf If $msg[0] = $Button_1 Then secondgui() EndIf If $msg[0] = $GUI_EVENT_CLOSE and $msg[1] = $mainGUI Then Exit If $msg[0] = $GUI_EVENT_CLOSE and $msg[1] = $SecondGUI Then GUIDelete($SecondGUI) WEnd Func secondgui() $SecondGUI = GUICreate("second GUI") $stringdata = GUICtrlCreateLabel("Line 1 Cell 1", 10, 30, 70) GUISetState(@SW_SHOW) If GUICtrlRead($stringdata) <> EnvGet('StringData') Then EnvSet('StringData', GUICtrlRead($stringdata)) EndFunc ;==>secondgui AutoIt3 Online Help Link to comment Share on other sites More sharing options...
infernothebest Posted September 28, 2008 Author Share Posted September 28, 2008 boh thx , i was looking for ages for this:) is it possible to get the data anyway? even if it isnt opent Apple Keybord shortcuts for XP Link to comment Share on other sites More sharing options...
DW1 Posted September 28, 2008 Share Posted September 28, 2008 boh thx , i was looking for ages for this:) is it possible to get the data anyway? even if it isnt opentI have no idea what you are trying to say... AutoIt3 Online Help Link to comment Share on other sites More sharing options...
infernothebest Posted September 28, 2008 Author Share Posted September 28, 2008 (edited) nevermind got it, i dont know how you do it without 2 while's because you got 2 gui's can you explain a litlle bit? i made a extra button on the other gui if you can make this working then i think i understand #include <GUIConstantsEx.au3> EnvSet('StringData', 'Nothing yet.') Global $stringdata, $SecondGUI $mainGUI = GUICreate("My GUI") GUISetState(@SW_SHOW) $Button_1 = GUICtrlCreateButton("other gui", 10, 30, 100) $Button_2 = GUICtrlCreateButton("get data", 150, 30, 100) While 1 $msg = GUIGetMsg(1) If $msg[0] = $Button_2 Then MsgBox(0, "", EnvGet('StringData')) EndIf If $msg[0] = $Button_1 Then run("notepad.exe") EndIf If $msg[0] = $Button_1 Then secondgui() EndIf If $msg[0] = $GUI_EVENT_CLOSE and $msg[1] = $mainGUI Then Exit If $msg[0] = $GUI_EVENT_CLOSE and $msg[1] = $SecondGUI Then GUIDelete($SecondGUI) WEnd Func secondgui() $SecondGUI = GUICreate("second GUI") $stringdata = GUICtrlCreateLabel("Line 1 Cell 1", 10, 30, 70) $Button_3 = GUICtrlCreateButton("Run Notepad", 10, 30, 100) GUISetState(@SW_SHOW) If GUICtrlRead($stringdata) <> EnvGet('StringData') Then EnvSet('StringData', GUICtrlRead($stringdata)) EndFunc ;==>secondgui Edited September 28, 2008 by infernothebest Apple Keybord shortcuts for XP Link to comment Share on other sites More sharing options...
DW1 Posted September 28, 2008 Share Posted September 28, 2008 Are you just needing a global variable? #include <GUIConstantsEx.au3> Global $stringdata, $SecondGUI, $data = 'is this what you mean? there is still information here but no GUI.' $mainGUI = GUICreate("My GUI") GUISetState(@SW_SHOW) $Button_1 = GUICtrlCreateButton("Run Notepad", 10, 30, 100) $Button_2 = GUICtrlCreateButton("get data", 150, 30, 100) While 1 $msg = GUIGetMsg(1) If $msg[0] = $Button_2 Then MsgBox(0, "", $data) EndIf If $msg[0] = $Button_1 Then secondgui() EndIf If $msg[0] = $GUI_EVENT_CLOSE and $msg[1] = $mainGUI Then Exit If $msg[0] = $GUI_EVENT_CLOSE and $msg[1] = $SecondGUI Then $data = 'is this what you mean? there is still information here but no GUI.' GUIDelete($SecondGUI) EndIf WEnd Func secondgui() $SecondGUI = GUICreate("second GUI") $data = 'GUI' $stringdata = GUICtrlCreateLabel($data, 10, 30, 70) GUISetState(@SW_SHOW) EndFunc ;==>secondgui AutoIt3 Online Help Link to comment Share on other sites More sharing options...
infernothebest Posted September 28, 2008 Author Share Posted September 28, 2008 read previous reply:) thx for al the help Apple Keybord shortcuts for XP Link to comment Share on other sites More sharing options...
DW1 Posted September 28, 2008 Share Posted September 28, 2008 What do you want the get data button to do? Grab the text that is currently in notepad? Also... I thought you were wanting to run two separate scripts which is why I suggested Env variables.. since it is 2 guis in the same script we just want to stick to global vars. AutoIt3 Online Help Link to comment Share on other sites More sharing options...
DW1 Posted September 28, 2008 Share Posted September 28, 2008 If I understand what you want, which I am starting to doubt... #include <GUIConstantsEx.au3> Global $stringdata, $SecondGUI, $Button_3, $data $mainGUI = GUICreate("My GUI") GUISetState(@SW_SHOW) $Button_1 = GUICtrlCreateButton("other gui", 10, 30, 100) $Button_2 = GUICtrlCreateButton("get data", 150, 30, 100) While 1 $msg = GUIGetMsg(1) If $msg[0] = $Button_2 Then MsgBox(0, "", $data) EndIf If $msg[0] = $Button_3 And $msg[0] <> 0 Then Run("notepad.exe") EndIf If $msg[0] = $Button_1 Then secondgui() EndIf If $msg[0] = $GUI_EVENT_CLOSE And $msg[1] = $mainGUI Then Exit If $msg[0] = $GUI_EVENT_CLOSE And $msg[1] = $SecondGUI Then GUIDelete($SecondGUI) If GUICtrlRead($stringdata) <> $data Then $data = GUICtrlRead($stringdata) WEnd Func secondgui() $SecondGUI = GUICreate("second GUI") $stringdata = GUICtrlCreateLabel("Line 1 Cell 1", 10, 100, 70) $Button_3 = GUICtrlCreateButton("Run Notepad", 10, 30, 100) GUISetState(@SW_SHOW) EndFunc ;==>secondgui AutoIt3 Online Help Link to comment Share on other sites More sharing options...
infernothebest Posted September 28, 2008 Author Share Posted September 28, 2008 (edited) exactly that thx for helping me you are quicker then me reacting hahah thx Edited September 28, 2008 by infernothebest Apple Keybord shortcuts for XP 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