BryanWall Posted January 29 Share Posted January 29 I have a listbox in my gui that serves as a log. Global $listBoxStyle = BitOr($LBS_NOTIFY, $WS_VSCROLL, $WS_BORDER) Global $lstLog = GUICtrlCreateList("", 30, 155, 346, 176, $listBoxStyle) The main code updates it just fine with GUICtrlSetData($lstLog,_NowTime(5) & " " & $msg) I have subscripts that run using Run('...... var1 var2 ...) I would like those other scripts to update my log window as well. How? I have tried the same GUICtrlSetData line however it doesn't work. Both using the $lstlog passed to the script and using "$lstLog = ControlGetHandle("Automation","","[CLASS:ListBox; INSTANCE:1]"). I have also tried _GUICtrlListBox_AddString and one other version of the same I think. Link to comment Share on other sites More sharing options...
spudw2k Posted January 29 Share Posted January 29 Try ListBox1 as the last parameter in the ControlGetHandle function, then check the variable to verify a handle was obtained. Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
BryanWall Posted January 29 Author Share Posted January 29 Both $lstLog = ControlGetHandle("Applanix Automation","","[CLASS:ListBox; INSTANCE:1]") ConsoleWrite("Win exists: " & $lstLog & @CRLF) $lstLog = ControlGetHandle("Applanix Automation","","ListBox1") ConsoleWrite("Win exists: " & $lstLog & @CRLF) Returns Win exists: 0x00700642 Win exists: 0x00700642 Link to comment Share on other sites More sharing options...
Solution Zedna Posted January 29 Solution Share Posted January 29 (edited) Try: ControlCommand("Applanix Automation","","ListBox1","AddString","some text ...") EDIT: _GUICtrlListBox_AddString() should work too, but ControlCommand() is more simple EDIT2: just note that GUICtrlSetData() can't be used in this case Edited January 29 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
spudw2k Posted January 29 Share Posted January 29 Ok, well that is a good sign. The handle does seems a little short to me (thinking x86 versus x64). Are the subscripts and the GUI script all using the same architecture x86/x64? I'm pretty sure you will need to use the _GUICtrlListBox functions, as using GUICtrlSetData uses the control ID instead of the handle...but you mentioned you already tried that. What return value do you get from the _GUICtrlListBox_AddString function? Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
BryanWall Posted January 30 Author Share Posted January 30 @Zedna That works. Thank you. Link to comment Share on other sites More sharing options...
LKP Posted January 30 Share Posted January 30 Sending data to AutoIt window by title or using onboard UDFs is the best solution. However, reading process text stream is also an option. Hope my solution helps someone☺ See attachment. exmpl.au3 Link to comment Share on other sites More sharing options...
BryanWall Posted January 31 Author Share Posted January 31 I will look at your example as well @LKP. Apologies in advance if this is already included in the example but similar to my original question, how to I scroll down on the listbox from a subscript? The below doesn't work, presumably for the same problem. GUICtrlSendMsg("ListBox1", $WM_VSCROLL, $SB_LINEDOWN, 0) The list in the help file for the ControlCommand doesn't seem to have an obvious parallel to the SendMsg. Link to comment Share on other sites More sharing options...
BryanWall Posted January 31 Author Share Posted January 31 (edited) @LKP Interesting example and I will give it a try since I was needing to separate out GUI from main script anyways since the main script is designed to keep running which means the button controls like closing the gui don't respond until main is 100% done. Also, in case it helps anyone else, I put together a tiny function to stop all scripts running using AutoIt3.exe. Could be supplemented to accept array for exes run by automation to kill them too. Seems necessary because Exit only stops that script as best I can tell, not subscripts or sub-subscripts. #include <Array.au3> Func _KillAU3s() Global $ProcList $ProcList = ProcessList() ;~ _ArrayDisplay($ProcList) ;Loop through process list and close anything using AutoIt3.exe For $x = 1 to $ProcList[0][0] If $ProcList[$x][0] = "AutoIt3.exe" Then ProcessClose($ProcList[$x][1]) Next EndFunc I plan on having the GUI part be compiled into an exe so this will work for me. If the main is being run from au3 file as well, will need to figure out how to get PID for the script running this function to exclude it. Edited January 31 by BryanWall Link to comment Share on other sites More sharing options...
LKP Posted January 31 Share Posted January 31 (edited) @BryanWall, I was actualy thinking of making an example that works both for @compiled and not, but everything I could google works only for compiled scripts. The sipmle solution (ignoring UDFs) is to create temporary files somewhere in @AppDataCommonDir or elsewhere and cleanup when subscripts exit, but it is kinda boring. Couldnt find $AutoHScroll style in help files, but you can just select an element every time you add one. Func _Hndl_Stream() Local $sData For $i = 1 to UBound($aChildPIDs) - 1 If ProcessExists($aChildPIDs[$i]) Then $sData = StdoutRead($aChildPIDs[$i]) If $sData <> '' Then GUICtrlSetData($idLog, $sData) ControlCommand($hGui, '', $idLog, 'SelectString', $sData) EndIf EndIf Next EndFunc P.s. Dont know what you are doing but HelpFile & Local MVPs recomend compiling everyting ¯\_(ツ)_/¯ Edited January 31 by LKP Link to comment Share on other sites More sharing options...
BryanWall Posted February 12 Author Share Posted February 12 @LKP Interesting. I'll look into it. That said, I have a side question. Do you know how to add a horizontal scroll the listbox? I have tried $WS_HSCROLL, and I have tried using _GUICtrlListView_SetColumnWidth to set the listbox column width to be larger than the listbox itself as one post suggested. None of it is working. expandcollapse popup#Include <SQLite.au3> #include <GuiListBox.au3> #include <GuiListView.au3> #include <Date.au3> #include <File.au3> #include <Array.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <ScrollBarConstants.au3> #Include <Math.au3> #Include <Inet.au3> #Region CreateGUI ;create gui Global $hGUI = GUICreate("Applanix Automation", 400, 350, 210, 0) GUISetOnEvent($GUI_EVENT_CLOSE, EndCode) Global $btnBrowse = GUICtrlCreateButton("Start", 10, 2, 76, 20) Global $lblBrowse = GUICtrlCreateLabel("Project Directory", 100, 5, 286, 16) Global $Label_5 = GUICtrlCreateLabel("APPLANIX", 10, 30, 76, 20) Global $Label_1 = GUICtrlCreateLabel("TIME SYNC", 10, 55, 76, 20) Global $Label_2 = GUICtrlCreateLabel("INJ TC", 10, 80, 76, 20) Global $Label_3 = GUICtrlCreateLabel("INJ PP", 10, 105, 76, 20) Global $Label_4 = GUICtrlCreateLabel("DR", 10, 130, 76, 20) Global $lblApplxStatus = GUICtrlCreateLabel("n/x", 100, 30, 56, 20) Global $lblTSStatus = GUICtrlCreateLabel("n/x", 100, 55, 56, 20) Global $lblITCStatus = GUICtrlCreateLabel("n/x", 100, 80, 56, 20) Global $lblIPPStatus = GUICtrlCreateLabel("n/x", 100, 105, 56, 20) Global $lblDRStatus = GUICtrlCreateLabel("n/x", 100, 130, 56, 20) Global $lstLog = GUICtrlCreateList(" ", 30, 155, 346, 176, $listBoxStyle) GUISetState(@SW_SHOWNORMAL) for $i = 0 to 50 GUICtrlSetData($lstLog,_NowTime(5) & " " & 50 - $i & " testttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt") Next _GUICtrlListView_SetColumnWidth($lstLog,0,500) #EndRegion ;CreateGUI While 1 wend Link to comment Share on other sites More sharing options...
Zedna Posted February 13 Share Posted February 13 (edited) 1) $listBoxStyle is not defined in your example 2) $WS_HSCROLL should work 3) _GUICtrlListView_SetColumnWidth() can't be used with Listbox Edited February 13 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
BryanWall Posted February 15 Author Share Posted February 15 1) Sorry, it was further up in code, didn't catch that I didn't copy it. Global $listBoxStyle = BitOr($LBS_NOTIFY, $WS_VSCROLL, $WS_HSCROLL) ;~ Global $listBoxStyle = BitOr($LBS_NOTIFY, $WS_VSCROLL, $WS_HSCROLL, $WS_BORDER) Also, I ended up posting a seperate topic since it is a separate issue and GUIctrlSetLimit is what worked for me. Link to comment Share on other sites More sharing options...
Zedna Posted February 15 Share Posted February 15 Try Global $listBoxStyle = BitOR($GUI_SS_DEFAULT_LIST, $WS_HSCROLL) Resources UDF ResourcesEx UDF AutoIt Forum Search 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