Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

GUI opens new GUI with search results, can't re use original GUI

$
0
0

Hey guys,

 

I've been trying to figure out what I'm doing wrong here... perhaps someone can shed some light on it for me? :)

 

The program works, and does exactly what I want it to, but when the initial program performs the search, and opens the second GUI, the first window is not usable, and I can't close it / run a new search with it.

 

I'd like to be able to close the second GUI that opens, without affecting the first GUI.

I'd also like to be able to run another search, and have multiple windows open.

 

Not sure If I'm doing this right, or if I'm completely off the right track!

 

Here's my code so far.

AutoIt         
#include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include <Excel.au3> #include <array.au3>   #include <ButtonConstants.au3> #include <EditConstants.au3> #include <StaticConstants.au3>    ; read in the Excel file    Global $sFilePath1 = @ScriptDir & "\Test.xls" ; directory of file    Global $datasheet = _ExcelBookOpen($sFilePath1)    ; Confirm if file exists       Dim $test1           $test1 = @error       If @error = 1 Then           MsgBox(0, "Error!", "Can't open excel object")           _ExcelBookClose($datasheet)           Exit                 ElseIf @error = 2 Then           MsgBox(0, "Error!", "File not found")           Exit        EndIf        ; End check _Main() Func _Main()    Global $Input_partnumber, $Input_Description, $Stock_Quantity    Global $Input_ReOrder, $Input_Location, $Input_Buy    Global $Input_Sell, $Input_Orderfrom    Global $sColumn = 1    $aArray = _ExcelReadSheetToArray($datasheet) ;Reads excel data into the array    ; input GUI       $Form1 = GUICreate("Search window", 615, 438, 192, 124)       $Button1 = GUICtrlCreateButton("Check", 8, 88, 75, 25)       $Button2 = GUICtrlCreateButton("Exit", 88, 88, 75, 25)       $Label1 = GUICtrlCreateLabel("Enter part number to search", 8, 8, 148, 33)       $Input1 = GUICtrlCreateInput("", 8, 56, 153, 21)       GUISetState(@SW_SHOW)       While 1           $nMsg = GUIGetMsg()           Switch $nMsg               Case $GUI_EVENT_CLOSE                   Exit                  ;               Case $Button1                         $input = GUICtrlRead($Input1)                         $iIndex = _ArraySearch($aArray, $input, "", "", "", "", 0, $sColumn)                                                 If @error Then                             MsgBox(0, "Not Found", $input & " was not found")                             _ExcelBookClose($datasheet)                             Exit                         Else                            Local $partnumber = _ExcelReadCell($datasheet, $iIndex, 1)                            Local $Description = _ExcelReadCell($datasheet, $iIndex, 2)                            Local $Quantity = _ExcelReadCell($datasheet, $iIndex, 3)                            Local $ReOrder = _ExcelReadCell($datasheet, $iIndex, 4)                            Local $Location = _ExcelReadCell($datasheet, $iIndex, 5)                            Local $Buy = _ExcelReadCell($datasheet, $iIndex, 6)                            Local $Sell = _ExcelReadCell($datasheet, $iIndex, 7)                            Local $Orderfrom = _ExcelReadCell($datasheet, $iIndex, 8)                            ; GUI                             GUICreate("Results", 400, 400, (@DesktopWidth - 300) / 2, (@DesktopHeight - 400) / 2, $WS_OVERLAPPEDWINDOW + $WS_CLIPSIBLINGS)                             GUICtrlCreateLabel("Part Number", 10, 10, 150, 20)                             GUICtrlCreateLabel("Description", 10, 40, 150, 20)                             GUICtrlCreateLabel("Quantity", 10, 70, 150, 20)                             GUICtrlCreateLabel("Re Order Level", 10, 100, 150, 20)                             GUICtrlCreateLabel("Location", 10, 130, 150, 20)                             GUICtrlCreateLabel("Buy Price", 10, 160, 150, 20)                             GUICtrlCreateLabel("Sell Price", 10, 190, 150, 20)                             GUICtrlCreateLabel("Order from", 10, 220, 150, 20)                             $Input_partnumber = GUICtrlCreateLabel("" & $partnumber, 180, 10, 280, 20)                             $Input_Description = GUICtrlCreateLabel("" & $Description, 180, 40, 280, 20)                             $Stock_Quantity = GUICtrlCreateLabel("" & $Quantity, 180, 70, 280, 20)                             $Input_ReOrder = GUICtrlCreateLabel("" & $ReOrder, 180, 100, 280, 20)                             $Input_Location = GUICtrlCreateLabel("" & $Location, 180, 130, 280, 20)                             $Input_Buy = GUICtrlCreateLabel("" & $Buy, 180, 160, 280, 20)                             $Input_Sell = GUICtrlCreateLabel("" & $Sell, 180, 190, 280, 20)                             $Input_Orderfrom = GUICtrlCreateLabel("" & $Orderfrom, 180, 220, 280, 20)                             EndIf                             GUISetState()                                While 1                                    $msg = GUIGetMsg()                                    Select                                        Case $msg = $GUI_EVENT_CLOSE                                            ExitLoop                                         Case Else                                            _ExcelBookClose($datasheet)                                    EndSelect                                WEnd                          Exit               Case $Button2                  _ExcelBookClose($datasheet)                  Exit           EndSwitch       WEnd EndFunc   ;==>_Main

Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>