devilyn Posted March 13, 2006 Share Posted March 13, 2006 hi i need to make "$button5" to open and close another window now it's just opening i can't make it close the window While 1 $msg = GUIGetMsg() Select Case $msg = $button2 $query = GUICtrlRead($edit1) ExitLoop EndSelect if $msg = $button5 And GUICtrlRead($button5) = 0 then MSGBOX (0,"1",guigetmsg($button5),-1); DEBUG $TB = GUISetState(@SW_SHOW) Elseif $msg = $button5 And GUICtrlRead($button5) = 4 then MSGBOX (0,"2",guigetmsg($button5),-1); DEBUG $TB = GUISetState(@SW_hide) ENDIF WEnd Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 13, 2006 Moderators Share Posted March 13, 2006 If $msg = $button5 Then $OpenWindow EndIfNow... you have GUISetState(), is there more than one GUI... because this is going to show the GUI that is currently active. Example:#include <GUICONSTANTS.AU3> $MainGui = GUICreate('1stGUI') $Button = GUICtrlCreateButton('Switch to Secondary', 10, 10) GUISetState() $SecondGUI = GUICreate('2ndGUI') $Button2 = GUICtrlCreateButton('Switch to Main', 10, 10) GUISetState(@SW_HIDE) While 1 $msg = GUIGetMsg() If $msg = - 3 Then Exit If $msg = $Button Then GUISetState(@SW_HIDE, $MainGui) GUISetState(@SW_SHOW, $SecondGUI) EndIf If $msg = $Button2 Then GUISetState(@SW_HIDE, $SecondGUI) GUISetState(@SW_SHOW, $MainGui) EndIf WEnd 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...
devilyn Posted March 13, 2006 Author Share Posted March 13, 2006 yes i have two gui's the example you pasted is using two diffrent buttons i want to use only one button that is on the first gui to open and close the second gui Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 13, 2006 Moderators Share Posted March 13, 2006 yes i have two gui's the example you pasted is using two diffrent buttonsi want to use only one button that is on the first gui to open and close the second guiWell your welcome... How about showing your script... I'd like to see how you are making the first and 2nd gui... and how you plan on having the variable the same on both... 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...
devilyn Posted March 13, 2006 Author Share Posted March 13, 2006 Sorry my firend i was unpolite thank you very much here is my code expandcollapse popup#include <GuiConstants.au3> Dim $ueberschriften = "" Dim $anzahl = 0 Dim $dsncount = 1 Dim $DSN = "" Dim $button3 GUICreate("Choose Your DSN", 392, 400,-1, -1) $listview = GUICtrlCreateListView("DSN|Type|Description", 10, 10, 372, 320) $button = GuiCtrlCreateButton("&OK", 100, 350, 90, 30, $BS_DEFPUSHBUTTON) $var = RegEnumVal("HKEY_CURRENT_USER\Software\ODBC\ODBC.INI\ODBC Data Sources", $dsncount) $wert = RegRead("HKEY_CURRENT_USER\Software\ODBC\ODBC.INI\ODBC Data Sources", $var) While $var <> "" $var = RegEnumVal("HKEY_CURRENT_USER\Software\ODBC\ODBC.INI\ODBC Data Sources", $dsncount) $wert = RegRead("HKEY_CURRENT_USER\Software\ODBC\ODBC.INI\ODBC Data Sources", $var) If $var <> "" Then GUICtrlCreateListViewItem($var & "|" & "USER" & "|" & $wert, $listview) EndIf $dsncount = $dsncount + 1 WEnd $dsncount = 1 $var = RegEnumVal("HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI\ODBC Data Sources", $dsncount) $wert = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\\ODBC Data Sources", $var) While $var <> "" $var = RegEnumVal("HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI\ODBC Data Sources", $dsncount) $wert = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI\ODBC Data Sources", $var) If $var <> "" Then GUICtrlCreateListViewItem($var & "|" & "SYSTEM" & "|" & $wert, $listview) EndIf $dsncount = $dsncount + 1 WEnd GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $button $dsnarray = StringSplit((GUICtrlRead(GUICtrlRead($listview), 2)), "|") $dsn = "DSN=" & $dsnarray [1] ExitLoop EndSelect WEnd GUIDelete(); GUICreate("Enter your sql-query", 392, 400,-1, -1) $edit1 = GUICtrlCreateEdit("", 10, 10, 372, 320) $button2 = GuiCtrlCreateButton("&OK", 100, 350, 90, 30, $BS_DEFPUSHBUTTON) $button5 = GuiCtrlCreateButton("&Quick Query", 200, 350, 90, 30) $query = GUICtrlRead($edit1) HotKeySet("{F5}", "EXECUTE1") Func EXECUTE1() ControlClick("","",$button2) EndFunc GUISetState(@SW_SHOW) $TB=GuiCreate("ToolBar", 80 ,410,800,-1 ,$WS_SYSMENU, $WS_EX_TOOLWINDOW) GUICtrlCreateButton("1",30,30,30,30) $TB= GUISetState(@SW_hide) While 1 $msg = GUIGetMsg() Select Case $msg = $button2 $query = GUICtrlRead($edit1) ExitLoop EndSelect if $msg = $button5 And GUICtrlRead($button5) = 0 then ;MSGBOX (0,"1",guigetmsg($button5),-1); DEBUG $tb = GUISetState(@SW_SHOW) Elseif $msg = $button5 And GUICtrlRead($button5) = 4 then MSGBOX (0,"2",guigetmsg($button5),-1); DEBUG GUISetState(@SW_hide,$TB) ENDIF WEnd $out = getData($DSN) ToolTip("") MsgBox(0, "Rows fetched", $out) While 1 $msg = GUIGetMsg() Select Case $msg = $button3 ExitLoop EndSelect WEnd Func getData($DSN) $cmboVal = "" $adoCon = ObjCreate ("ADODB.Connection") $adoCon.Open ($DSN) $adoRs = ObjCreate ("ADODB.Recordset") $adoSQL = $query $adoRs.CursorType = 2 $adoRs.LockType = 3 $adoRs.Open ($adoSql, $adoCon) GUICreate("Results", 392, 400,-1, -1) $button3 = GuiCtrlCreateButton("&OK", 100, 350, 90, 30, $BS_DEFPUSHBUTTON) $button4 = GuiCtrlCreateButton("&Save", 200, 350, 90, 30) With $adoRs ; Get information about Fields collection For $n = 0 To .Fields.Count - 1 $ueberschriften = $ueberschriften & .Fields ($n).Name & "|" Next $liste = GUICtrlCreateListView(StringTrimRight($ueberschriften, 1), 10, 10, 372, 320) If .RecordCount Then $count = 0 While Not .EOF $count = $count + 1 ToolTip("Counting Query Rows #" & $count, 0, 0) For $colum = 0 To .Fields.Count - 1 $cmboVal = $cmboVal & "" & .Fields ($colum).Value & "|" Next $cmboVal = StringTrimRight($cmboVal, 1) & @CR GUICtrlCreateListViewItem($cmboVal, $liste) $cmboVal = "" .MoveNext WEnd GUISetState() EndIf EndWith $adoCon.Close Return $count EndFunc ;==>getData And Thanks Again Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 13, 2006 Moderators Share Posted March 13, 2006 A Couple of things... 1. When creating GUI's in general, make it a practice to give each GUICreate () a Unique Variable name: Example $MainGUI = GUICreate('Starting') 2. When using GUISetState() ... do not try to make that a variable... Example you have: $TB = GUISetState(@SW_HIDE) ... Should just be GUISetState(@SW_HIDE, $TB) <<< notice the winhandle (GUI). 3. GUIGetMsg() is used to get the information used currently within a GUI, putting a Control Variable such as GUIGetMsg($button5) isn't going to help you get a result, because $button is the Control ID of that Control... I wouldn't be surprised if it only ever returned a '0'. Try this one on for size, and tell me if that is what your trying to achieve:#include <GUICONSTANTS.AU3> $MainGui = GUICreate('1stGUI') $Button = GUICtrlCreateButton('Switch to Secondary', 10, 10) GUISetState() $SecondGUI = GUICreate('2ndGUI') GUISetState(@SW_HIDE) While 1 $msg = GUIGetMsg() If $msg = - 3 And Not BitAND(WinGetState($SecondGUI), 2) Then Exit If $msg = - 3 And BitAND(WinGetState($SecondGUI), 2) Then GUISetState(@SW_HIDE, $SecondGUI) If $msg = $Button Then If Not BitAND(WinGetState($SecondGUI), 2) Then GUISetState(@SW_SHOW, $SecondGUI) Else GUISetState(@SW_HIDE, $SecondGUI) EndIf EndIf WEnd 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...
devilyn Posted March 13, 2006 Author Share Posted March 13, 2006 Yes exactly thanks a lot Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 13, 2006 Moderators Share Posted March 13, 2006 Yes exactlythanks a lotYour quite welcome... If you have questions on how or why I used BitAND() look at WinGetState() in the help file. 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