RedFish Posted April 2, 2014 Share Posted April 2, 2014 Hi all, First time actually posting, but I've been using the forum for a few months now. I've gotten myself neck deep into a utility that probably should have been written with visual studio or something, and need to just push through this. The basic function(s) of this program are: accept an input text file search that text file for a string pattern using regex for each result, use form input to query perforce via command line put the have / head information and file name together in a multi dim array use a modified arraydisplay() function to allow the user to select results for each selected result (for all if none selected) get latest when the button is clicked close the array display window wait for additional user action. I think I was originally having issues because the hacked arraydisplay() function "_Display_GetArray()" was not using onevent mode where the main window was. When it was in the message loop format, the second (child) window would function properly, but the parent would lose event control, so I tried changing it. After making some changes I feel like I'm worse off than I started, because now the child window doesn't display at all, not to mention that the event control is still blown away on the parent. The amount of code is a bit larger than I've typically seen in these forum threads, but I know how useful it can be. Thanks so much in advance for helping me review my monster. expandcollapse popup#Include <GuiMenu.au3> #include <Constants.au3> #include <GUIConstants.au3> #include <GUIConstantsEx.au3> #include <EditConstants.au3> #include <ScrollBarConstants.au3> #include <GuiComboBox.au3> #include <Array.au3> #include <GUIEdit.au3> opt('GUIOnEventMode',1) _Main() Func _Main() ; globals Global $paramIndex = 0 ; the indicator of how many parameters have been provided. Global $Path = '' ; path to search file given by user Global $strRoot = '' ; root directory of the client workspace Global $strViews Global $arGet[1][2] Local $filemenu, $FileOpen, $recentfilesmenu, $separator1, $txtbx Local $hGUI, $hFile, $hEdit, $hHelp, $hMain Local $exititem, $helpmenu, $aboutitem Local $msg, $file Dim $arRecent[1] Dim $arValues[1] Dim $times = 0 #forceref $separator1 ; for the separator in the file menu ; window create Global $Window = GUICreate("Get CopyBook", 500, 500) ; 120) GUISetOnEvent($GUI_EVENT_CLOSE, "_exit") ; create output box $EditStyle = BitOR($GUI_SS_DEFAULT_EDIT, $ES_READONLY) Global $out_box = GUICtrlCreateEdit("",5,125,490,350,$EditStyle) GUICtrlSetLimit($out_box,10000000) Global $head_lbl = GUICtrlCreateLabel('In which file would you like to search.',10,5,300,20) Global $txtbx = GUICtrlCreateInput('',10,20,280,20) ; combo box Global $cb_lbl = GUICtrlCreateLabel('Select the workspace you want me to use.',10,45,300,20) $i = 0 Do Global $cb_Clients = _GuiCtrlComboBox_Create($Window,_get_P4USER_clients(),10,60,280,20) if $arClients[0] <> '' then ExitLoop Until $i = 3 _GUICtrlComboBox_SetEditText($cb_Clients,$arClients[0]) Global $txt2_lbl = GUICtrlCreateLabel("Now select the branch you want have-list info from.",10,85,300,20,$gui_hide) Global $txtbx2 = GUICtrlCreateInput('',10,100,280,20) GUICtrlSetData($txtbx2,"//depot/...") ; buttons Global $okbutton = GUICtrlCreateButton("OK", 295, 100, 100, 20) GUICtrlSetOnEvent($okbutton, "_addProperty") ; file menu $filemenu = GUICtrlCreateMenu("File") $FileOpen = GUICtrlCreateMenuItem("Open...", $filemenu) $GetViews = GUICtrlCreateMenuItem("Get Views...", $filemenu) $separator1 = GUICtrlCreateMenuItem("", $filemenu) $exititem = GUICtrlCreateMenuItem("Exit", $filemenu) ; help menu $helpmenu = GUICtrlCreateMenu("?") $About = GUICtrlCreateMenuItem("About", $helpmenu) GUISetState(@SW_SHOW, $window) GUICtrlSetOnEvent($FileOpen, "_OpenDialog") GUICtrlSetOnEvent($GetViews, "_get_menu") GUICtrlSetOnEvent($exititem, "_exit") GUICtrlSetOnEvent($About,"_about") ; look for user activity While 1 sleep( 1000 ) WEnd EndFunc ;==>_Main Func _get_menu() $str = _get_P4USER_clients() _GUICtrlComboBox_Destroy($cb_Clients) $cb_Clients = _GuiCtrlComboBox_Create($Window,$str,10,25,280,20) _GUICtrlComboBox_SetEditText($cb_Clients,$arClients[0]) EndFunc Func _get_P4USER_clients() ; get p4user environment var for use in commandline $p4user = EnvGet("P4USER") ConsoleWrite("P4USER="&$p4user & @LF) ; run p4 clients command by user $process = Run(@ComSpec & ' /c p4 clients -u ' & $p4user,'',@SW_HIDE,$STDOUT_CHILD) sleep(500) ; use regular expressions to process output of command into array Global $arClients = StringRegExp(StdoutRead($process),"Client (.*?) ",3,1) ; guard empty array processing If UBound($arClients) = 0 Then Return '' ; string results together into a pipe delimited string $sClients = '' for $i = 0 to UBound($arClients) - 1 $sClients &= $arClients[$i] & "|" Next ; trim unnecessary end char $sClients = StringTrimRight($sClients,1) ConsoleWrite("user clients="&$sclients & @lf) ; return delimited string of clients by user Return $sClients EndFunc Func _addProperty() ConsoleWrite("add clicked" & @lf) ; validate and store the file path $Path = ControlGetText('','',$txtbx) if $Path = '' then MsgBox(1,"Empty Parameter Found","A file path is required to continue.") Return EndIf ; set client to selection $Client = _GUICtrlComboBox_GetEditText($cb_Clients) run(@comspec & ' /c p4 set P4CLIENT='&$Client,@SW_HIDE) sleep(500) ; get workspace root from client selected $process = Run(@ComSpec & ' /c p4 info','',@SW_HIDE,$STDOUT_CHILD) sleep(500) ; call regular expressions to search for the client root directory $array = StringRegExp(StdoutRead($process),"Client root: (.+)",3,0) If @error = 0 Then ConsoleWrite("Root found: " & $array[0] & @lf) $strRoot = $array[0] Else $data = @error&@LF) _write($data) return EndIf ; get text from text box $strBranch = ControlGetText('','',$txtbx2) if StringRight($strBranch,1) <> "/" then $strBranch = $strBranch&"/" EndIf ; get copy books from selected file (_GetCopyBooks) $aCopyResults = _GetCopyBooks($Path) ; create results array index var $k=0 ; for each array result from the search file For $i = 0 to UBound($aCopyResults) - 1 $data = "============================================="&@LF _write($data) ; run p4 fstat -T depotFile [branch param + array result] $cmd = ' /c p4 fstat -T depotFile ' & $strBranch & $aCopyResults[$i] $data = "cmd: " & $cmd & @lf _write($data) $process = Run(@ComSpec & $cmd,'',@SW_HIDE,$STDOUT_CHILD+$STDERR_CHILD) ; get the output of the run() process While 1 $stderr = StderrRead($process) $stdout = StdoutRead($process) if $stdout > '' or $stderr > '' then ExitLoop sleep(100) WEnd if $stdout > '' then $data = "Returned: " & $stdout _write($data) else $data = "Errors: " & $stderr _write($data) endif ; parse output for depotFile paths that exist $depotFile = StringRegExp($stdout,"depotFile (.+)",3,1) If IsArray($depotFile) and @error = 0 Then ; for each returned depotFile (accounting for subdirectories of branch param) For $j =0 To UBound($depotFile)-1 ; add space to the array ReDim $arGet[$k+1][2] ; strip returned line end chars $depotFile[$j] = StringStripCR($depotFile[$j]) ; run p4 fstat -T headRev,haveRev [depotFile] $cmd = ' /c p4 fstat -T headRev,haveRev '&$depotFile[$j] $data = 'cmd: '&$cmd&@LF _write($data) $process = Run(@ComSpec & $cmd,'',@sw_hide,$STDOUT_CHILD) ; get the output of the run() process while 1 $stderr = StderrRead($process) $stdout = StdoutRead($process) if $stdout > '' or $stderr > '' then ExitLoop sleep(100) WEnd if $stdout > '' then $data = "Returned: " & $stdout _write($data) else $data = "Errors: " & $stderr _write($data) endif ; parse output for head revision value $head = StringRegExp($stdout,'headRev (.+)',3,1) if @error <> 0 Then $data = "head @err: " & @error&@lf _write($data) $head = 0 Else $head = $head[0] EndIf ; parse output for have reviaion value $have = StringRegExp($stdout,'haveRev (.+)',3,1) if @error <> 0 Then $data = "have @err: " & @error&@lf _write($data) $have = 0 Else $have = $have[0] EndIf ; put the have / head value together $have = $have & "/" & $head $data = $depotFile[0] & ' ' & $have & @LF _write($data) $data = "============================================="&@LF _write($data) ;ConsoleWrite("============================================="&@LF) ; put the depotFile value in the array $arGet[$k][0] = StringStripCR($depotFile[$j]) ; put the have/head value in the array $arGet[$k][1] = $have ; incrament array index $k+=1 Next ; next depotFile returned by perforce ; clear array for next copyfile $depotFile = '' EndIf Next ; display the array and allow user to get latest _Display_GetArray($arGet, 'Depot Files Found', "Count|Depot File|Have") _write("display end") EndFunc Func _GetCopyBooks($sWorkSpaceFile = '', $bDisplayResults = True) ;~ If $bStandAlone <> False ; if no params supplied prompt for them ;~ If ($sWorkSpaceFile = ' ') or ($sWorkSpaceFile = '') Then ;~ $sWorkSpaceFile = InputBox("Path to Branch", "Where is the file?" & @lf & "(include the filename + extinsion)") ;~ If ($sWorkSpaceFile = '') Then Exit ;~ EndIf ;~ EndIf ; open the file ConsoleWrite('opening file' & @LF) $SearchFile = FileOpen($sWorkSpaceFile, 0) ConsoleWrite('searchfile = ' & $searchfile & @LF) If $SearchFile = -1 Then ConsoleWrite("An error occurred while opening the file. Check that it exists at the location provided." & @LF) ConsoleWrite($sWorkSpaceFile) Return -1 EndIf ; read the file and check for errors ConsoleWrite('reading file' & @LF) $SearchTxt = FileRead($SearchFile) If @error = 1 Then ConsoleWrite("An error occurred while reading the file. Check that the proper permission is given for reading." & @LF) ConsoleWrite($sWorkSpaceFile) FileClose($SearchFile) Return 1 ElseIf @error = -1 Then ConsoleWrite("An error occurred. EOF reached on initial read. Check for file integrity." & @LF) ConsoleWrite($sWorkSpaceFile) FileClose($SearchFile) Return 2 EndIf ; clost the file after handle received FileClose($SearchFile) ; offset start of regex search $nOffset = 1 ; use optioin 3 to return an array of all instances of the match $arrResults = StringRegExp( $SearchTxt, ' *?COPY *?"(.*?)"', 3, $nOffset) ; display ;~ If $bDisplayResults = True Then ;~ _ArrayDisplay($arrResults) ;~ EndIf Return $arrResults EndFunc Func _Display_GetArray(Const ByRef $avArray, $sTitle = "Array: ListView Display", $sHeader = "", $iItemLimit = -1, $iTranspose = 0, $sSeparator = "", $sReplace = "|") If Not IsArray($avArray) Then Return SetError(1, 0, 0) ; Dimension checking Local $iDimension = UBound($avArray, 0), $iUBound = UBound($avArray, 1) - 1, $iSubMax = UBound($avArray, 2) - 1 If $iDimension > 2 Then Return SetError(2, 0, 0) ; Separator handling If $sSeparator = "" Then $sSeparator = Chr(124) ; Check the separator to make sure it's not used literally in the array If _ArraySearch($avArray, $sSeparator, 0, 0, 0, 1) <> -1 Then For $x = 1 To 255 If $x >= 32 And $x <= 127 Then ContinueLoop Local $sFind = _ArraySearch($avArray, Chr($x), 0, 0, 0, 1) If $sFind = -1 Then $sSeparator = Chr($x) ExitLoop EndIf Next EndIf ; Declare variables Local $vTmp, $iBuffer = 4094 ; AutoIt max item size Local $iColLimit = 250 Local $iOnEventMode = Opt("GUIOnEventMode", 0), $sDataSeparatorChar = Opt("GUIDataSeparatorChar", $sSeparator) ; Swap dimensions if transposing If $iSubMax < 0 Then $iSubMax = 0 If $iTranspose Then $vTmp = $iUBound $iUBound = $iSubMax $iSubMax = $vTmp EndIf ; Set limits for dimensions If $iSubMax > $iColLimit Then $iSubMax = $iColLimit If $iItemLimit < 1 Then $iItemLimit = $iUBound If $iUBound > $iItemLimit Then $iUBound = $iItemLimit ; Set header up If $sHeader = "" Then $sHeader = "Row " ; blanks added to adjust column size for big number of rows For $i = 0 To $iSubMax $sHeader &= $sSeparator & "Col " & $i Next EndIf ; Convert array into text for listview Local $avArrayText[$iUBound + 1] For $i = 0 To $iUBound $avArrayText[$i] = "[" & $i & "]" For $j = 0 To $iSubMax ; Get current item If $iDimension = 1 Then If $iTranspose Then $vTmp = $avArray[$j] Else $vTmp = $avArray[$i] EndIf Else If $iTranspose Then $vTmp = $avArray[$j][$i] Else $vTmp = $avArray[$i][$j] EndIf EndIf ; Add to text array $vTmp = StringReplace($vTmp, $sSeparator, $sReplace, 0, 1) ; Set max buffer size If StringLen($vTmp) > $iBuffer Then $vTmp = StringLeft($vTmp, $iBuffer) $avArrayText[$i] &= $sSeparator & $vTmp Next Next ; GUI Constants Local Const $_ARRAYCONSTANT_GUI_DOCKBORDERS = 0x66 Local Const $_ARRAYCONSTANT_GUI_DOCKBOTTOM = 0x40 Local Const $_ARRAYCONSTANT_GUI_DOCKHEIGHT = 0x0200 Local Const $_ARRAYCONSTANT_GUI_DOCKLEFT = 0x2 Local Const $_ARRAYCONSTANT_GUI_DOCKRIGHT = 0x4 Local Const $_ARRAYCONSTANT_GUI_EVENT_CLOSE = -3 Local Const $_ARRAYCONSTANT_LVM_GETCOLUMNWIDTH = (0x1000 + 29) Local Const $_ARRAYCONSTANT_LVM_GETITEMCOUNT = (0x1000 + 4) Local Const $_ARRAYCONSTANT_LVM_GETITEMSTATE = (0x1000 + 44) Local Const $_ARRAYCONSTANT_LVM_SETEXTENDEDLISTVIEWSTYLE = (0x1000 + 54) Local Const $_ARRAYCONSTANT_LVS_EX_FULLROWSELECT = 0x20 Local Const $_ARRAYCONSTANT_LVS_EX_GRIDLINES = 0x1 Local Const $_ARRAYCONSTANT_LVS_SHOWSELALWAYS = 0x8 Local Const $_ARRAYCONSTANT_WS_EX_CLIENTEDGE = 0x0200 Local Const $_ARRAYCONSTANT_WS_MAXIMIZEBOX = 0x00010000 Local Const $_ARRAYCONSTANT_WS_MINIMIZEBOX = 0x00020000 Local Const $_ARRAYCONSTANT_WS_SIZEBOX = 0x00040000 ; Set interface up Local $iWidth = 500, $iHeight = 480 Local $hGUI = GUICreate($sTitle, $iWidth, $iHeight, Default, Default, BitOR($_ARRAYCONSTANT_WS_SIZEBOX, $_ARRAYCONSTANT_WS_MINIMIZEBOX, $_ARRAYCONSTANT_WS_MAXIMIZEBOX)) Local $aiGUISize = WinGetClientSize($hGUI) Local $hListView = GUICtrlCreateListView($sHeader, 0, 0, $aiGUISize[0], $aiGUISize[1] - 26, $_ARRAYCONSTANT_LVS_SHOWSELALWAYS) Local $hCopy = GUICtrlCreateButton("Get Latest", 3, $aiGUISize[1] - 23, $aiGUISize[0] - 6, 20) GUICtrlSetResizing($hListView, $_ARRAYCONSTANT_GUI_DOCKBORDERS) GUICtrlSetResizing($hCopy, $_ARRAYCONSTANT_GUI_DOCKLEFT + $_ARRAYCONSTANT_GUI_DOCKRIGHT + $_ARRAYCONSTANT_GUI_DOCKBOTTOM + $_ARRAYCONSTANT_GUI_DOCKHEIGHT) GUICtrlSendMsg($hListView, $_ARRAYCONSTANT_LVM_SETEXTENDEDLISTVIEWSTYLE, $_ARRAYCONSTANT_LVS_EX_GRIDLINES, $_ARRAYCONSTANT_LVS_EX_GRIDLINES) GUICtrlSendMsg($hListView, $_ARRAYCONSTANT_LVM_SETEXTENDEDLISTVIEWSTYLE, $_ARRAYCONSTANT_LVS_EX_FULLROWSELECT, $_ARRAYCONSTANT_LVS_EX_FULLROWSELECT) GUICtrlSendMsg($hListView, $_ARRAYCONSTANT_LVM_SETEXTENDEDLISTVIEWSTYLE, $_ARRAYCONSTANT_WS_EX_CLIENTEDGE, $_ARRAYCONSTANT_WS_EX_CLIENTEDGE) $data = "============================================="&@LF _write($data) _write($data) _write($data) ; Fill listview For $i = 0 To $iUBound GUICtrlCreateListViewItem($avArrayText[$i], $hListView) Next ; adjust window width ;~ $iWidth = 0 ;~ For $i = 0 To $iSubMax + 1 ;~ $iWidth += GUICtrlSendMsg($hListView, $_ARRAYCONSTANT_LVM_GETCOLUMNWIDTH, $i, 0) ;~ Next ;~ If $iWidth < 250 Then $iWidth = 230 ;~ $iWidth += 20 If $iWidth > @DesktopWidth Then $iWidth = @DesktopWidth - 100 WinMove($hGUI, "", (@DesktopWidth - $iWidth) / 2, Default, $iWidth) ; Show dialog GUISetState(@SW_SHOW, $hGUI) GUICtrlSetOnEvent($_ARRAYCONSTANT_GUI_EVENT_CLOSE, "_closewin") GUICtrlSetOnEvent($hCopy, "_sync") While 1 sleep(100) WEnd EndFunc func _closewin() GUIDelete($hGUI) EndFunc func _sync() Local $sClip = "" ; Get selected indices [ _GUICtrlListView_GetSelectedIndices($hListView, True) ] Local $aiCurItems[1] = [0] For $i = 0 To GUICtrlSendMsg($hListView, $_ARRAYCONSTANT_LVM_GETITEMCOUNT, 0, 0) If GUICtrlSendMsg($hListView, $_ARRAYCONSTANT_LVM_GETITEMSTATE, $i, 0x2) Then $aiCurItems[0] += 1 ReDim $aiCurItems[$aiCurItems[0] + 1] $aiCurItems[$aiCurItems[0]] = $i EndIf Next GUISetState(@SW_HIDE,$hGUI) ; Generate clipboard text If Not $aiCurItems[0] Then For $i=0 to UBound($avArrayText)-1 ; run p4 sync [branch param + array result] $cmd = ' /c p4 sync ' & $avArray[$i][0] $data = "cmd: " & $cmd & @lf _write($data) ;ConsoleWrite("cmd: " & $cmd & @lf) $process = Run(@ComSpec & $cmd,'',@SW_HIDE,$STDOUT_CHILD+$STDERR_CHILD) sleep(100) Next Else For $i = 1 To UBound($aiCurItems) - 1 ; run p4 sync [branch param + array result] $cmd = ' /c p4 sync ' & $avArray[$aiCurItems[$i]][0] $data = "cmd: " & $cmd & @lf _write($data) ;ConsoleWrite("cmd: " & $cmd & @lf) $process = Run(@ComSpec & $cmd,'',@SW_HIDE,$STDOUT_CHILD+$STDERR_CHILD) sleep(100) Next EndIf ;~ ExitLoop ;~ EndSwitch ;~ WEnd ;GUIDelete($hGUI) ;Opt("GUIOnEventMode", $iOnEventMode) ;Opt("GUIDataSeparatorChar", $sDataSeparatorChar) Return EndFunc Func _Exit() ConsoleWrite("exiting" & @lf) Exit EndFunc Func _OpenDialog() ; start the dialog from reg value saved $startpath = RegRead("HKEY_CURRENT_USER\SOFTWARE\USERDEF\RegExCopyBook", "LastSelect") ; open the dialog If $startpath <> '' Then $file = FileOpenDialog("Choose file...", $startpath, "All (*.*)") Else $file = FileOpenDialog("Choose file...", 'C:\', "All (*.*)") EndIf ; when successful If @error <> 1 Then ; create recent files item first time only ;~ If $times = 0 Then ;~ $recentfilesmenu = GUICtrlCreateMenu("Recent Files", $filemenu, 1) ;~ EndIf ;~ $times += 1 ;~ ReDim $arRecent[$times] ;~ ReDim $arValues[$times] ;~ $arRecent[$times - 1] = GUICtrlCreateMenuItem($file, $recentfilesmenu,0) ;~ $arValues[$times - 1] = $file ;~ ConsoleWrite('added array record ' & $arRecent[$times - 1] & ' @ index ' & $times -1 & @lf) ;~ ; put the text in the box ControlSetText ( "", "", $txtbx, $file ) EndIf EndFunc Func _about() ShellExecute("http://goo.gl/2UckFW") EndFunc Func _write($data) ConsoleWrite($data) $iEnd = StringLen(GUICtrlRead($out_box)) _GUICtrlEdit_SetSel($out_box, $iEnd, $iEnd) _GUICtrlEdit_Scroll($out_box, $SB_SCROLLCARET) GUICtrlSetData($out_box,$data,1) EndFunc Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 3, 2014 Moderators Share Posted April 3, 2014 RedFish,As I have none of the data available I have no real idea of what the various functions do, so it is impossible to tell you precisely what is going wrong - but I have a pretty good idea. You have infinite While...WEnd idle loops inside some of your functions - this means that you never leave those functions and so AutoIt will not run any further functions. In OnEvent mode you need but a single idle loop in the main script - never inside a function. So I suggest you add an idle loop after calling the _Main() function:_Main() ; look for user activity While 1 Sleep(10) WEnd Func _Main()and remove the idle loops at the end of the Main & _Display_GetArray functions. This will allow the other functions to run. There are a myriad other minor problems with the script, but let us see if we can get the main parts working first. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
RedFish Posted April 3, 2014 Author Share Posted April 3, 2014 M23, Thanks for your help! I have made the change you suggested and, while I do see the reason for making them, I don't seem to see any difference. Once the second window opens the events are still unresponsive. I have chopped most of the implementation pieces out, so the program is now just bare bones and the code for the simplified version follows. I would also be very interested in your opinion on style and patterns or other issues you see in the way I have written this utility, but as you said I would like to get the events working between the 2 windows with this simple version first. expandcollapse popup#Include <GuiMenu.au3> #include <Constants.au3> #include <GUIConstants.au3> #include <GUIConstantsEx.au3> #include <EditConstants.au3> #include <ScrollBarConstants.au3> #include <GuiComboBox.au3> #include <Array.au3> #include <GUIEdit.au3> opt('GUIOnEventMode',1) _Main() ; look for user activity While 1 sleep( 1000 ) WEnd Func _Main() ; globals Global $paramIndex = 0 ; the indicator of how many parameters have been provided. Global $Path = '' ; path to search file given by user Global $strRoot = '' ; root directory of the client workspace Global $strViews Global $arGet[1][2] Local $filemenu, $FileOpen, $recentfilesmenu, $separator1, $txtbx Local $hGUI, $hFile, $hEdit, $hHelp, $hMain Local $exititem, $helpmenu, $aboutitem Local $msg, $file Dim $arRecent[1] Dim $arValues[1] Dim $times = 0 #forceref $separator1 ; for the separator in the file menu ; window create Global $Window = GUICreate("Get CopyBook", 500, 500) ; 120) GUISetOnEvent($GUI_EVENT_CLOSE, "_exit") $EditStyle = BitOR($GUI_SS_DEFAULT_EDIT, $ES_READONLY) Global $out_box = GUICtrlCreateEdit("",5,125,490,350,$EditStyle) GUICtrlSetLimit($out_box,10000000) Global $head_lbl = GUICtrlCreateLabel('In which file would you like to search.',10,5,300,20) Global $txtbx = GUICtrlCreateInput('',10,20,280,20) ; combo box Global $cb_lbl = GUICtrlCreateLabel('Select the workspace you want me to use.',10,45,300,20) Global $cb_Clients = _GuiCtrlComboBox_Create($Window,'',10,60,280,20) ;_GUICtrlComboBox_SetEditText($cb_Clients,$arClients[0]) Global $txt2_lbl = GUICtrlCreateLabel("Now select the branch you want have-list info from.",10,85,300,20,$gui_hide) Global $txtbx2 = GUICtrlCreateInput('',10,100,280,20) GUICtrlSetData($txtbx2,"//depot/...") ; buttons Global $okbutton = GUICtrlCreateButton("OK", 295, 100, 100, 20) GUICtrlSetOnEvent($okbutton, "_addProperty") ; file menu $filemenu = GUICtrlCreateMenu("File") $FileOpen = GUICtrlCreateMenuItem("Open...", $filemenu) $GetViews = GUICtrlCreateMenuItem("Get Views...", $filemenu) $separator1 = GUICtrlCreateMenuItem("", $filemenu) $exititem = GUICtrlCreateMenuItem("Exit", $filemenu) ; help menu $helpmenu = GUICtrlCreateMenu("?") $About = GUICtrlCreateMenuItem("About", $helpmenu) GUISetState(@SW_SHOW, $window) ;WinSetState($txtbx2,'',@SW_HIDE) ;GUICtrlSetOnEvent($FileOpen, "_OpenDialog") ;GUICtrlSetOnEvent($GetViews, "_get_menu") ;GUICtrlSetOnEvent($exititem, "_exit") ;GUICtrlSetOnEvent($About,"_about") EndFunc ;==>_Main Func _addProperty() ConsoleWrite("add clicked" & @lf) dim $ar[5][2]=[["file 1","1/1"],["file 2","2/2"],["file 3","3/3"],["file 4","4/4"],["file 5","5/5"]] ; display the array and allow user to get latest _Display_GetArray($ar, 'Depot Files Found', "Count|Depot File|Have") ;_exit() _write("display end") ;EndSwitch EndFunc Func _Display_GetArray(Const ByRef $avArray, $sTitle = "Array: ListView Display", $sHeader = "", $iItemLimit = -1, $iTranspose = 0, $sSeparator = "", $sReplace = "|") If Not IsArray($avArray) Then Return SetError(1, 0, 0) ; Dimension checking Local $iDimension = UBound($avArray, 0), $iUBound = UBound($avArray, 1) - 1, $iSubMax = UBound($avArray, 2) - 1 If $iDimension > 2 Then Return SetError(2, 0, 0) ; Separator handling If $sSeparator = "" Then $sSeparator = Chr(124) ; Check the separator to make sure it's not used literally in the array If _ArraySearch($avArray, $sSeparator, 0, 0, 0, 1) <> -1 Then For $x = 1 To 255 If $x >= 32 And $x <= 127 Then ContinueLoop Local $sFind = _ArraySearch($avArray, Chr($x), 0, 0, 0, 1) If $sFind = -1 Then $sSeparator = Chr($x) ExitLoop EndIf Next EndIf ; Declare variables Local $vTmp, $iBuffer = 4094 ; AutoIt max item size Local $iColLimit = 250 Local $iOnEventMode = Opt("GUIOnEventMode", 0), $sDataSeparatorChar = Opt("GUIDataSeparatorChar", $sSeparator) ; Swap dimensions if transposing If $iSubMax < 0 Then $iSubMax = 0 If $iTranspose Then $vTmp = $iUBound $iUBound = $iSubMax $iSubMax = $vTmp EndIf ; Set limits for dimensions If $iSubMax > $iColLimit Then $iSubMax = $iColLimit If $iItemLimit < 1 Then $iItemLimit = $iUBound If $iUBound > $iItemLimit Then $iUBound = $iItemLimit ; Set header up If $sHeader = "" Then $sHeader = "Row " ; blanks added to adjust column size for big number of rows For $i = 0 To $iSubMax $sHeader &= $sSeparator & "Col " & $i Next EndIf ; Convert array into text for listview Local $avArrayText[$iUBound + 1] For $i = 0 To $iUBound $avArrayText[$i] = "[" & $i & "]" For $j = 0 To $iSubMax ; Get current item If $iDimension = 1 Then If $iTranspose Then $vTmp = $avArray[$j] Else $vTmp = $avArray[$i] EndIf Else If $iTranspose Then $vTmp = $avArray[$j][$i] Else $vTmp = $avArray[$i][$j] EndIf EndIf ; Add to text array $vTmp = StringReplace($vTmp, $sSeparator, $sReplace, 0, 1) ; Set max buffer size If StringLen($vTmp) > $iBuffer Then $vTmp = StringLeft($vTmp, $iBuffer) $avArrayText[$i] &= $sSeparator & $vTmp Next Next ; GUI Constants Local Const $_ARRAYCONSTANT_GUI_DOCKBORDERS = 0x66 Local Const $_ARRAYCONSTANT_GUI_DOCKBOTTOM = 0x40 Local Const $_ARRAYCONSTANT_GUI_DOCKHEIGHT = 0x0200 Local Const $_ARRAYCONSTANT_GUI_DOCKLEFT = 0x2 Local Const $_ARRAYCONSTANT_GUI_DOCKRIGHT = 0x4 Local Const $_ARRAYCONSTANT_GUI_EVENT_CLOSE = -3 Local Const $_ARRAYCONSTANT_LVM_GETCOLUMNWIDTH = (0x1000 + 29) Local Const $_ARRAYCONSTANT_LVM_GETITEMCOUNT = (0x1000 + 4) Local Const $_ARRAYCONSTANT_LVM_GETITEMSTATE = (0x1000 + 44) Local Const $_ARRAYCONSTANT_LVM_SETEXTENDEDLISTVIEWSTYLE = (0x1000 + 54) Local Const $_ARRAYCONSTANT_LVS_EX_FULLROWSELECT = 0x20 Local Const $_ARRAYCONSTANT_LVS_EX_GRIDLINES = 0x1 Local Const $_ARRAYCONSTANT_LVS_SHOWSELALWAYS = 0x8 Local Const $_ARRAYCONSTANT_WS_EX_CLIENTEDGE = 0x0200 Local Const $_ARRAYCONSTANT_WS_MAXIMIZEBOX = 0x00010000 Local Const $_ARRAYCONSTANT_WS_MINIMIZEBOX = 0x00020000 Local Const $_ARRAYCONSTANT_WS_SIZEBOX = 0x00040000 ; Set interface up Local $iWidth = 500, $iHeight = 480 Local $hGUI = GUICreate($sTitle, $iWidth, $iHeight, Default, Default, BitOR($_ARRAYCONSTANT_WS_SIZEBOX, $_ARRAYCONSTANT_WS_MINIMIZEBOX, $_ARRAYCONSTANT_WS_MAXIMIZEBOX)) Local $aiGUISize = WinGetClientSize($hGUI) Local $hListView = GUICtrlCreateListView($sHeader, 0, 0, $aiGUISize[0], $aiGUISize[1] - 26, $_ARRAYCONSTANT_LVS_SHOWSELALWAYS) Local $hCopy = GUICtrlCreateButton("Get Latest", 3, $aiGUISize[1] - 23, $aiGUISize[0] - 6, 20) GUICtrlSetResizing($hListView, $_ARRAYCONSTANT_GUI_DOCKBORDERS) GUICtrlSetResizing($hCopy, $_ARRAYCONSTANT_GUI_DOCKLEFT + $_ARRAYCONSTANT_GUI_DOCKRIGHT + $_ARRAYCONSTANT_GUI_DOCKBOTTOM + $_ARRAYCONSTANT_GUI_DOCKHEIGHT) GUICtrlSendMsg($hListView, $_ARRAYCONSTANT_LVM_SETEXTENDEDLISTVIEWSTYLE, $_ARRAYCONSTANT_LVS_EX_GRIDLINES, $_ARRAYCONSTANT_LVS_EX_GRIDLINES) GUICtrlSendMsg($hListView, $_ARRAYCONSTANT_LVM_SETEXTENDEDLISTVIEWSTYLE, $_ARRAYCONSTANT_LVS_EX_FULLROWSELECT, $_ARRAYCONSTANT_LVS_EX_FULLROWSELECT) GUICtrlSendMsg($hListView, $_ARRAYCONSTANT_LVM_SETEXTENDEDLISTVIEWSTYLE, $_ARRAYCONSTANT_WS_EX_CLIENTEDGE, $_ARRAYCONSTANT_WS_EX_CLIENTEDGE) $data = "============================================="&@LF _write($data) _write($data) _write($data) ; Fill listview For $i = 0 To $iUBound GUICtrlCreateListViewItem($avArrayText[$i], $hListView) Next ; adjust window width ;~ $iWidth = 0 ;~ For $i = 0 To $iSubMax + 1 ;~ $iWidth += GUICtrlSendMsg($hListView, $_ARRAYCONSTANT_LVM_GETCOLUMNWIDTH, $i, 0) ;~ Next ;~ If $iWidth < 250 Then $iWidth = 230 ;~ $iWidth += 20 If $iWidth > @DesktopWidth Then $iWidth = @DesktopWidth - 100 WinMove($hGUI, "", (@DesktopWidth - $iWidth) / 2, Default, $iWidth) ; Show dialog GUISetState(@SW_SHOW, $hGUI) GUICtrlSetOnEvent($_ARRAYCONSTANT_GUI_EVENT_CLOSE, "_closewin") GUICtrlSetOnEvent($hCopy, "_sync") ;~ While 1 ;~ sleep(100) ;~ WEnd EndFunc func _closewin() GUIDelete($hGUI) EndFunc func _sync() Local $sClip = "" ; Get selected indices [ _GUICtrlListView_GetSelectedIndices($hListView, True) ] Local $aiCurItems[1] = [0] For $i = 0 To GUICtrlSendMsg($hListView, $_ARRAYCONSTANT_LVM_GETITEMCOUNT, 0, 0) If GUICtrlSendMsg($hListView, $_ARRAYCONSTANT_LVM_GETITEMSTATE, $i, 0x2) Then $aiCurItems[0] += 1 ReDim $aiCurItems[$aiCurItems[0] + 1] $aiCurItems[$aiCurItems[0]] = $i EndIf Next GUISetState(@SW_HIDE,$hGUI) ; Generate clipboard text If Not $aiCurItems[0] Then For $i=0 to UBound($avArrayText)-1 ; run p4 sync [branch param + array result] $cmd = ' /c p4 sync ' & $avArray[$i][0] $data = "cmd: " & $cmd & @lf _write($data) ;ConsoleWrite("cmd: " & $cmd & @lf) ;~ $process = Run(@ComSpec & $cmd,'',@SW_HIDE,$STDOUT_CHILD+$STDERR_CHILD) sleep(100) Next Else For $i = 1 To UBound($aiCurItems) - 1 ; run p4 sync [branch param + array result] $cmd = ' /c p4 sync ' & $avArray[$aiCurItems[$i]][0] $data = "cmd: " & $cmd & @lf _write($data) ;ConsoleWrite("cmd: " & $cmd & @lf) ;~ $process = Run(@ComSpec & $cmd,'',@SW_HIDE,$STDOUT_CHILD+$STDERR_CHILD) sleep(100) Next EndIf ;~ ExitLoop ;~ EndSwitch ;~ WEnd ;GUIDelete($hGUI) ;Opt("GUIOnEventMode", $iOnEventMode) ;Opt("GUIDataSeparatorChar", $sDataSeparatorChar) Return EndFunc Func _write($data) ConsoleWrite($data) $iEnd = StringLen(GUICtrlRead($out_box)) _GUICtrlEdit_SetSel($out_box, $iEnd, $iEnd) _GUICtrlEdit_Scroll($out_box, $SB_SCROLLCARET) GUICtrlSetData($out_box,$data,1) EndFunc Thanks again! Red Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 3, 2014 Moderators Share Posted April 3, 2014 (edited) RedFish,Did you try running that script? I think not because it is riddled with errors. With a few changes, this seems to work. The main changes are marked <<<<<<<<<<<<<<<:expandcollapse popup#include <GuiMenu.au3> #include <Constants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> #include <ScrollBarConstants.au3> #include <ListViewConstants.au3> #include <GuiComboBox.au3> #include <Array.au3> #include <GUIEdit.au3> Opt('GUIOnEventMode', 1) ; Global variables Global $Window, $out_box _Main() ; look for user activity While 1 Sleep(10) WEnd Func _Main() ; window create $Window = GUICreate("Get CopyBook", 500, 500) ; 120) GUISetOnEvent($GUI_EVENT_CLOSE, "_exit") $EditStyle = BitOR($GUI_SS_DEFAULT_EDIT, $ES_READONLY) $out_box = GUICtrlCreateEdit("", 5, 125, 490, 350, $EditStyle) GUICtrlSetLimit($out_box, 10000000) GUICtrlCreateLabel('In which file would you like to search.', 10, 5, 300, 20) $txtbx = GUICtrlCreateInput('', 10, 20, 280, 20) ; combo box GUICtrlCreateLabel('Select the workspace you want me to use.', 10, 45, 300, 20) $cb_Clients = _GUICtrlComboBox_Create($Window, '', 10, 60, 280, 20) GUICtrlCreateLabel("Now select the branch you want have-list info from.", 10, 85, 300, 20, $gui_hide) $txtbx2 = GUICtrlCreateInput('', 10, 100, 280, 20) GUICtrlSetData($txtbx2, "//depot/...") ; buttons $okbutton = GUICtrlCreateButton("OK", 295, 100, 100, 20) GUICtrlSetOnEvent($okbutton, "_addProperty") ; file menu Local $filemenu = GUICtrlCreateMenu("File") $FileOpen = GUICtrlCreateMenuItem("Open...", $filemenu) $GetViews = GUICtrlCreateMenuItem("Get Views...", $filemenu) GUICtrlCreateMenuItem("", $filemenu) $exititem = GUICtrlCreateMenuItem("Exit", $filemenu) ; help menu $helpmenu = GUICtrlCreateMenu("?") $About = GUICtrlCreateMenuItem("About", $helpmenu) GUISetState(@SW_SHOW, $Window) EndFunc ;==>_Main Func _addProperty() ConsoleWrite("add clicked" & @LF) Global $ar[5][2] = [["file 1", "1/1"],["file 2", "2/2"],["file 3", "3/3"],["file 4", "4/4"],["file 5", "5/5"]] ; display the array and allow user to get latest _Display_GetArray($ar) _write("display end") EndFunc ;==>_addProperty Func _Display_GetArray(ByRef $avArray) If Not IsArray($avArray) Then Return SetError(1, 0, 0) ; Dimension checking Local $iDimension = UBound($avArray, 0), $iUBound = UBound($avArray, 1) - 1, $iSubMax = UBound($avArray, 2) - 1 ; Set header up $sHeader = "Row " ; blanks added to adjust column size for big number of rows For $i = 0 To $iSubMax $sHeader &= "|" & "Col " & $i Next ; Convert array into text for listview Global $avArrayText[$iUBound + 1] For $i = 0 To $iUBound $avArrayText[$i] = "[" & $i & "]" For $j = 0 To $iSubMax ; Get current item ; Add to text array $avArrayText[$i] &= "|" & $avArray[$i][$j] Next Next ; Set interface up Local $iWidth = 500, $iHeight = 480 Global $hGUI = GUICreate("", $iWidth, $iHeight, Default, Default, BitOR($WS_SIZEBOX, $WS_MINIMIZEBOX, $WS_MAXIMIZEBOX)) Local $aiGUISize = WinGetClientSize($hGUI) Global $hListView = GUICtrlCreateListView($sHeader, 0, 0, $aiGUISize[0], $aiGUISize[1] - 26, $LVS_SHOWSELALWAYS) Global $hCopy = GUICtrlCreateButton("Get Latest", 3, $aiGUISize[1] - 23, $aiGUISize[0] - 6, 20) GUICtrlSetResizing($hListView, $GUI_DOCKBORDERS) GUICtrlSetResizing($hCopy, $GUI_DOCKLEFT + $GUI_DOCKRIGHT + $GUI_DOCKBOTTOM + $GUI_DOCKHEIGHT) GUICtrlSendMsg($hListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES) GUICtrlSendMsg($hListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT) GUICtrlSendMsg($hListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $WS_EX_CLIENTEDGE, $WS_EX_CLIENTEDGE) ;$data = "=============================================" & @LF ;_write($data) ;_write($data) ;_write($data) ; Fill listview For $i = 0 To $iUBound GUICtrlCreateListViewItem($avArrayText[$i], $hListView) Next ; Show dialog GUISetState(@SW_SHOW, $hGUI) GUISetOnEvent($GUI_EVENT_CLOSE, "_closewin") ; <<<<<<<<<<<<<<<<<<<<<< GUICtrlSetOnEvent($hCopy, "_sync") EndFunc ;==>_Display_GetArray Func _closewin() GUIDelete($hGUI) EndFunc ;==>_closewin Func _sync() Local $sClip = "" Local Const $LVM_GETITEMCOUNT = (0x1000 + 4) Local Const $LVM_GETITEMSTATE = (0x1000 + 44) ; Get selected indices [ _GUICtrlListView_GetSelectedIndices($hListView, True) ] Local $aiCurItems[1] = [0] For $i = 0 To GUICtrlSendMsg($hListView, $LVM_GETITEMCOUNT, 0, 0) If GUICtrlSendMsg($hListView, $LVM_GETITEMSTATE, $i, 0x2) Then $aiCurItems[0] += 1 ReDim $aiCurItems[$aiCurItems[0] + 1] $aiCurItems[$aiCurItems[0]] = $i EndIf Next _closewin() ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ; Generate clipboard text If Not $aiCurItems[0] Then For $i = 0 To UBound($avArrayText) - 1 ; run p4 sync [branch param + array result] $cmd = ' /c p4 sync ' & $ar[$i][0] $data = "cmd: " & $cmd & @LF _write($data) ;ConsoleWrite("cmd: " & $cmd & @lf) ;~ $process = Run(@ComSpec & $cmd,'',@SW_HIDE,$STDOUT_CHILD+$STDERR_CHILD) Sleep(100) Next Else For $i = 1 To UBound($aiCurItems) - 1 ; run p4 sync [branch param + array result] $cmd = ' /c p4 sync ' & $ar[$aiCurItems[$i]][0] $data = "cmd: " & $cmd & @LF _write($data) ;ConsoleWrite("cmd: " & $cmd & @lf) ;~ $process = Run(@ComSpec & $cmd,'',@SW_HIDE,$STDOUT_CHILD+$STDERR_CHILD) Sleep(100) Next EndIf ;~ ExitLoop ;~ EndSwitch ;~ WEnd ;GUIDelete($hGUI) ;Opt("GUIOnEventMode", $iOnEventMode) ;Opt("GUIDataSeparatorChar", $sDataSeparatorChar) Return EndFunc ;==>_sync Func _write($data) ConsoleWrite($data) $iEnd = StringLen(GUICtrlRead($out_box)) _GUICtrlEdit_SetSel($out_box, $iEnd, $iEnd) _GUICtrlEdit_Scroll($out_box, $SB_SCROLLCARET) GUICtrlSetData($out_box, $data, 1) EndFunc ;==>_write Func _exit() Exit EndFunc ;==>_exitI have simplified the _Display_GetArray function as it can use includes from the main script and does not need its own constant list. If that script now works as you wish we can move onto other things. M23 Edited April 3, 2014 by Melba23 Added <<<<<<<<<<<<<<<< Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
RedFish Posted April 3, 2014 Author Share Posted April 3, 2014 (edited) M23, I did run that chopped up version of my script before posting to make sure that it "runs". I'm not sure why it might not have worked after the fact. Running the code you provided does seem to have the events working. I didn't see any "<<<<<<" markers for the key changes. I can easily see that you have scrubbed it of the nonessentials, but my eyes must not be as keen to see that change which allowed the events to start working again. Edited April 3, 2014 by RedFish Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 3, 2014 Moderators Share Posted April 3, 2014 RedFish,Sorry, I added them to the code in SciTE and not to the already posted code - they are there now. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
RedFish Posted April 3, 2014 Author Share Posted April 3, 2014 So removing the constants, the second declaration of the onevent option and changing the event to the included GUI_EVENT_CLOSE are what caused the messaging to work properly? Hmm.. it might take me a bit to actually learn that. What are some of the additional suggestions you mentioned earlier in this post for this utility. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 4, 2014 Moderators Share Posted April 4, 2014 RedFish,No, the 2 highlighted changes are: - 1. You were using GUICtrlSetOnEvent to set the second GUI closure event - unsurprisingly it did not work as you need GUISetOnEvent for GUIs.- 2. You were just hiding the GUI when you called the _sync function - as you create a new GUI each time it is better to delete the old one.I removed the constants as you can use standard include files to access them - they are set in the original _ArrayDisplay function to prevent havif to add multiple include files to the Array UDF itself. As to the other points, in no particular order: - 1. Do not declare Global variables inside functions - do so at the top of the script.- 2. There is no need to save the ControlIds of controls you do not address elsewhere in the script - such as labels.- 3. Why use UDF functions (_GUICtrlComboBox_Create) when there are easier native functions to do the same thing (GUICtrlCreateCombo?- 4. If you use these native functions then you can use GUICtrlRead / GUICtrlSetData to get at the content rather then the more cumbersome _GUICtrlComboBox_GetEditText / _GUICtrlComboBox_SetEditText / ControlSetText.- 5. Rather than destroy and recreate the combo in the _get_menu function, why npt just oversrite the curernt data? If you use the native combo it is a simple as starting the new data with a delimiter.None of the above actually prevents the script from working, but if you are interested in leaning how to code cleanly, they are all good tips. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
RedFish Posted April 11, 2014 Author Share Posted April 11, 2014 M32, Thanks for pointing out that big diff between the GUICtrlSetOnEvent & GUISetOnEvent!!! As for the hiding, I was at a complete loss as to why I was not getting the behavior I wanted, so I started surfing. You asked a question that I don't have the answer to (surprising..? I know...). "Why use UDF functions over native...?" I will answer your question with a question. What are the UDFs actually used for when there are native functions for so many of the same operations? Thanks again for your help and wisdom, Red Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 11, 2014 Moderators Share Posted April 11, 2014 RedFish,When you use the native functions, AutoIt does a lot of the donkey work for you - which makes life very simple. If you use the UDF function, you often get a wider range of options but at the cost of doing a lot of extra coding that AutoIt does for you when you use the native functions. Look at the Tabs tutorial in the Wiki to see some good examples of the difference. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area 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