OrthodoxyUSA Posted August 9, 2008 Share Posted August 9, 2008 (edited) expandcollapse popup#include <GuiConstantsEx.au3> #include <AVIConstants.au3> #include <TreeViewConstants.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <ListviewConstants.au3> #include <ProgressConstants.au3> #include <file.au3> #include <GUIListBox.au3> #include <GuiListView.au3> #include <GuiTreeView.au3> #include <Date.au3> ; #AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 GuiCreate("CSA Toolbox v1.0", 600, 660, @DesktopWidth / 4 - 160, @DesktopHeight / 10 - 45, -1, 0x00000018) GuiSetIcon(@SystemDir & "\wpabaln.exe", 0) ; MENU GuiCtrlCreateMenu("File") ; TAB GuiCtrlCreateTab(10, 0, 580, 630) GuiCtrlCreateTabItem("Distribute Files") ; BUTTONS $SelectAll = GUICtrlCreateButton("Select All", 20, 30, 90, 20) $DeSelectAll = GUICtrlCreateButton("De-Select All", 120, 30, 90, 20) $Run = GuiCtrlCreateButton("Run Now", 470, 560, 100, 20) $Schedule = GuiCtrlCreateButton("Add to Batch", 470, 585, 100, 20) $Browse = GuiCtrlCreateButton("Browse", 240, 537, 100, 20) $ToProduction = GuiCtrlCreateCheckbox("Copy File to Production Library?", 17, 587, 200, 20) ; LABELS $Instructions = " Brief Instructions: 1. Select the Utilities for distribution. 2. Drag and Drop the file to distribute into the box below. 3. Click 'Run Now' or 'Add to Batch'. Files of know types: (*.exe, *.dll, *.rpt, *.package, *.cmd, *.sql) will be copied to their appropriate folders. Unknown file types will not be processed. Notepad will open, and an email will be sent, with the results." GuiCtrlCreateLabel($Instructions, 250, 55, 300, 280, $SS_LEFT, $WS_EX_CLIENTEDGE) GuiCtrlCreateLabel("Drag and Drop the file to be Distributed below:", 15, 543) GuiCtrlCreateLabel("Type in your Load Requst Form Information.", 250, 435) GuiCtrlCreateLabel("Action Request #:", 250, 467) GuiCtrlCreateLabel("Control #:", 290, 487) ; Variables inside this TAB Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES) Local $SelectAll, $DeSelectAll, $Schedule, $Run, $msg, $file, $aRecords, $sItems, $TF, $AR, $ctrl, $AR1, $ctrl1, $utilityfile, $util, $companydb, $dbip, $termip, $runstring, $filetype, $tTime, $aTime, $resultstring, $Browse, $ToProduction Local $hItem[40] ; Create Item List from the above file If Not _FileReadToArray("c:\csatoolbox\utility.idx",$aRecords) Then MsgBox(4096,"Error", " Error reading c:\csatoolbox\utility.idx to Array error:" & @error) Exit EndIf $hTree = GuiCtrlCreateTreeView(15, 55, 200, 470, $iStyle, $WS_EX_CLIENTEDGE) _GUICtrlTreeView_BeginUpdate($hTree) For $x = 1 to $aRecords[0] $hItem[$x] = GUICtrlCreateTreeViewItem($aRecords[$x], $hTree) Next _GUICtrlTreeView_Sort($hTree) _GUICtrlTreeView_EndUpdate($hTree) ; INPUT (Drag and Drop file for Distribution) $file = GuiCtrlCreateInput("", 15, 560, 440, 20) GUICtrlSetState(-1, $GUI_DROPACCEPTED) $msg = 0 ; INPUT (Type in your Action Request) $AR = GuiCtrlCreateInput("", 352, 462, 100, 20) $msg = 0 ; INPUT (Type in your Control Number) $ctrl = GuiCtrlCreateInput("", 352, 485, 100, 20) $msg = 0 ;GuiCtrlCreateTabItem("Process SQL Commands") ;GuiCtrlCreateTabItem("Check File Versions") ;GuiCtrlCreateTabItem("Issue 'AT' Commands") ;GuiCtrlCreateTabItem("Domain and GP Users Setup") ;GuiCtrlCreateTabItem("Utility Setup") ;GuiCtrlCreateTabItem("System Settings") GUISetState() While GuiGetMsg() <> $GUI_EVENT_CLOSE $msg = GUIGetMsg() ; Select what happens when a button is pushed. Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $SelectAll For $x = 1 to $aRecords[0] GuiCtrlSetState($hItem[$x], $GUI_CHECKED) Next Case $msg = $DeSelectAll For $x = 1 to $aRecords[0] GuiCtrlSetState($hItem[$x], $GUI_UNCHECKED) Next Case $msg = $Run For $x = 1 to $aRecords[0] $TF = _GUICtrlTreeView_GetChecked($hTree, $hItem[$x]) If $TF = "True" Then ;If not GUICtrlRead($AR,0) Then ; MsgBox(4160,"Error:", "Please enter an 'Action Request' number.") ; ContinueLoop ; EndIf ;If not GUICtrlRead($ctrl,0) Then ; MsgBox(4160,"Error:", "Please enter a 'Control' number.") ; ContinueLoop ; EndIf ;If not GUICtrlRead($file,0) Then ; MsgBox(4160,"Error:", "Please enter a 'File' to send.") ; ContinueLoop ; EndIf $AR1 = GUICtrlRead($AR,0) $ctrl1 = GUICtrlRead($ctrl,0) $file1 = GUICtrlRead($file) $file2 = '"'&$file1&'"' $filetype = StringRight($file1, 3) $util = StringFormat("%d", $aRecords[$x]) $utilityfile = FileOpen("c:\csatoolbox\"&$util&".txt",0) $companydb = FileReadLine($utilityfile,1) $dbip = FileReadLine($utilityfile,2) $root = FileReadLine($utilityfile,3) $companyterm = FileReadLine($utilityfile,5) $termip = FileReadLine($utilityfile,6) $exe = FileReadLine($utilityfile,7) ; Get current datetime for 'results' file name. $tTime = _Date_Time_GetSystemTime() $aTime = _Date_Time_SystemTimeToArray($tTime) $datetime = StringFormat($aTime[2]& $aTime[0]& $aTime[1]& $aTime[3]& $aTime[4]& $aTime[5]) $resultstring = "c:\\csatoolbox\\results\\"&$datetime&"_results_from_copy_"&$filetype&"_to_"&$util&".txt" ;MsgBox(4160,"Filetype:", $resultstring) Run(@ComSpec & " /c " & "echo copy "&$file2&" "&$termip&$exe&" >>"&$resultstring) EndIf Next Case $msg = $Browse ShellExecute ("c:\windows\explorer.exe" , "\\Oprsvr1\opnvis\CIS-NG\Programming Guidelines\Version9_CSA_Customizations") ContinueLoop EndSelect WEnd Files needed... c:\csatoolbox\utility.idx 270 Alcorn 550 Barbourville 275 Blue Ridge 027 Bolivar 032 Bristol 031 Brownsville 256 Camden 043 Cleveland 065 Elizabethton 593 North Anderson 133 Mayfield 500 Middle TN 144 Morristown 146 Mount Pleasant 174 Paris 182 Pulaski 195 Scottsboro 206 Shelbyville 363 TVEC 551 Wilson c:\csatoolbox\27.txt Bolivardb "\\10.14.2.3\ c$" 0 Bolivarterm "\\10.14.2.4\ c$\Program Files (x86)\Microsoft Dynamics\GP\Addins" 0 Clicking a button hardly ever works the first time. Most of the time I have to click a button several times to get it to work. For instance... try the "Select All" and "De-Select All" button. They should work the first time right? Every button seems to have the same problem. Any ideas? Thanks Much... Paul Edited August 9, 2008 by OrthodoxyUSA Link to comment Share on other sites More sharing options...
Juppie7 Posted August 9, 2008 Share Posted August 9, 2008 (edited) yes ive run into this, and it's an autoit issue as far as I know. I never actually tried to fix it, but if anyone knows the answer that'd be fantastic. I believe it has to do with the dispatching of window events, so it's possible that theres another way to listen & respond to window events. I'll play with it and see if I can get anything done. *EDIT. I found your fix bro. Just change 'While GuiGetMsg() <> $GUI_EVENT_CLOSE' to 'While 1' and problem is solved. You have a dispatch event for GUI_EVENT_CLOSE inside your loop, so checking 'GuiGetMsg() <> $GUI_EVENT_CLOSE' to see if the message is different from closing is redundant in this light. And it also explains your delay, it's checking for a message first and comparing it to event_close, and then grabbing a second message. meaning your initial message that was checked @ the while line is being overwritten with the second one.( GUIGetMsg() should be called once, and used globally - per GUI window) Edited August 9, 2008 by Juppie7 Link to comment Share on other sites More sharing options...
OrthodoxyUSA Posted August 10, 2008 Author Share Posted August 10, 2008 yes ive run into this, and it's an autoit issue as far as I know.I never actually tried to fix it, but if anyone knows the answer that'd be fantastic.I believe it has to do with the dispatching of window events, so it's possible that theres another way to listen & respond to window events.I'll play with it and see if I can get anything done.*EDIT. I found your fix bro.Just change 'While GuiGetMsg() <> $GUI_EVENT_CLOSE' to 'While 1' and problem is solved. You have a dispatch event for GUI_EVENT_CLOSE inside your loop, so checking 'GuiGetMsg() <> $GUI_EVENT_CLOSE' to see if the message is different from closing is redundant in this light. And it also explains your delay, it's checking for a message first and comparing it to event_close, and then grabbing a second message. meaning your initial message that was checked @ the while line is being overwritten with the second one.( GUIGetMsg() should be called once, and used globally - per GUI window)Thanks so much for your insight!I look forward to trying it on Monday!Forgive me...Paul Link to comment Share on other sites More sharing options...
OrthodoxyUSA Posted August 10, 2008 Author Share Posted August 10, 2008 I couldn't wait... I tried it and it worked beautifully! 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