devilyn Posted March 12, 2006 Share Posted March 12, 2006 My sql query tool I have a problem with this code I added another GUI in the second part (tool bar GUI) The problem is when I click the button of the toolbar the script doesnt continue And when I don't click its ok I can run a query on the sql 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() While 1 $msg = GUIGetMsg() Select Case $msg = $button5 #include <GuiConstants.au3> GuiCreate("ToolBar", 80, 410,711, 147 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS)) GUISetBkColor (0xa70e3d) $Button1 = GuiCtrlCreateButton("Hosts Query", 10, 10, 80, 40) $Button_2 = GuiCtrlCreateButton("Application Servers Query", 10, 60, 80, 40 , $BS_MULTILINE ) $Button_3 = GuiCtrlCreateButton("Titles Query", 10, 110, 80, 40) $Button_4 = GuiCtrlCreateButton("Rundown Query", 10, 160, 80, 40, $BS_MULTILINE ) $Button_5 = GuiCtrlCreateButton("Station Query", 10, 210, 80, 40) $Button_6 = GuiCtrlCreateButton("Studio Query", 10, 260, 80, 40) $Button_7 = GuiCtrlCreateButton("JobBroker Query", 10, 310, 80, 40, $BS_MULTILINE ) $Button_8 = GuiCtrlCreateButton("Your Own Query", 10, 360, 80, 40 , $BS_MULTILINE ) ;GUICtrlSetColor($Button_8,0xdd7897) GuiSetState() While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop case $msg = $Button1 ControlClick("Enter your sql-query","",3) send("Select * From Hosts") ;send("{F5}") Case $msg = $button2 $query = GUICtrlRead($edit1) ExitLoop Case Else ;;; EndSelect WEnd ; Case $msg = $button2 ; $query = GUICtrlRead($edit1) ; ExitLoop EndSelect WEnd $out = getData($DSN) ToolTip("") MsgBox(0, "Rows fetched", $out) While 1 $msg = GUIGetMsg() Select Case $msg = $button3 ExitLoop EndSelect WEnd Func getData($DSN) ; some things are a bit harder to understand in this part ; .Fields("address").Value is the Value of the Field named "address" ; access database would be the same, but you should call out the full table as well ; like .Fields("Tablename.Fieldname").Value ; and EOF is universal for End Of File $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 Link to comment Share on other sites More sharing options...
cdkid Posted March 12, 2006 Share Posted March 12, 2006 (edited) Well, right off the bat i notice this While 1 $msg = GUIGetMsg() Select Case $msg = $button5 #include <GuiConstants.au3> GuiCreate("ToolBar", 80, 410,711, 147 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS)) GUISetBkColor (0xa70e3d) $Button1 = GuiCtrlCreateButton("Hosts Query", 10, 10, 80, 40) $Button_2 = GuiCtrlCreateButton("Application Servers Query", 10, 60, 80, 40 , $BS_MULTILINE ) $Button_3 = GuiCtrlCreateButton("Titles Query", 10, 110, 80, 40) $Button_4 = GuiCtrlCreateButton("Rundown Query", 10, 160, 80, 40, $BS_MULTILINE ) $Button_5 = GuiCtrlCreateButton("Station Query", 10, 210, 80, 40) $Button_6 = GuiCtrlCreateButton("Studio Query", 10, 260, 80, 40) $Button_7 = GuiCtrlCreateButton("JobBroker Query", 10, 310, 80, 40, $BS_MULTILINE ) $Button_8 = GuiCtrlCreateButton("Your Own Query", 10, 360, 80, 40 , $BS_MULTILINE ) ;GUICtrlSetColor($Button_8,0xdd7897) GuiSetState() While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop You never a( finish your first While 1 loop b( close your select before opening another one... try something like this While 1 $msg = GUIGetMsg() Select Case $msg = $button5 #include <GuiConstants.au3> GuiCreate("ToolBar", 80, 410,711, 147 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS)) GUISetBkColor (0xa70e3d) $Button1 = GuiCtrlCreateButton("Hosts Query", 10, 10, 80, 40) $Button_2 = GuiCtrlCreateButton("Application Servers Query", 10, 60, 80, 40 , $BS_MULTILINE ) $Button_3 = GuiCtrlCreateButton("Titles Query", 10, 110, 80, 40) $Button_4 = GuiCtrlCreateButton("Rundown Query", 10, 160, 80, 40, $BS_MULTILINE ) $Button_5 = GuiCtrlCreateButton("Station Query", 10, 210, 80, 40) $Button_6 = GuiCtrlCreateButton("Studio Query", 10, 260, 80, 40) $Button_7 = GuiCtrlCreateButton("JobBroker Query", 10, 310, 80, 40, $BS_MULTILINE ) $Button_8 = GuiCtrlCreateButton("Your Own Query", 10, 360, 80, 40 , $BS_MULTILINE ) ;GUICtrlSetColor($Button_8,0xdd7897) Case $msg = $GUI_EVENT_CLOSE ExitLoop Endselect WEnd Edited March 12, 2006 by cdkid AutoIt Console written in C#. Write au3 code right at the console :D_FileWriteToLineWrite to a specific line in a file.My UDF Libraries: MySQL UDF Library version 1.6 MySQL Database UDF's for AutoItI have stopped updating the MySQL thread above, all future updates will be on my SVN. The svn location is:kan2.sytes.net/publicsvn/mysqlnote: This will still be available, but due to my new job, and school hours, am no longer developing this udf.My business: www.hirethebrain.com Hire The Brain HireTheBrain.com Computer Consulting, Design, Assembly and RepairOh no! I've commited Scriptocide! Link to comment Share on other sites More sharing options...
Nuffilein805 Posted March 13, 2006 Share Posted March 13, 2006 you could build both guis before you run the loop maybe just hide the 2nd 1 and make it child of the 1st so your $msg = guigetmsg() will get the actions made on both guis just a little guess my little chatmy little encryption toolmy little hidermy unsafe clickbot 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