Leaderboard
Popular Content
Showing content with the highest reputation on 03/27/2021 in all areas
-
Is GUICtrlDelete() recommended for zapping listview items?
pixelsearch and one other reacted to Nine for a topic
As explained by @pixelsearch using _SendMessage($g_hListView, $LVM_DELETEALLITEMS) on natively created LVI will create holes (leaks) of control ids. Normally, when you delete a control (with GUICtrlDelete), its ID is recuperated by the GUI system. When you use the send message, it is not. After a while you may end up lacking ID, and your application will fail. Here an example that show the purpose : #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <WindowsConstants.au3> #include <SendMessage.au3> #include <ListViewConstants.au3> Example() Func Example() Local $hGUI = GUICreate("listview items", 220, 250, 100, 200, -1) Local $idListview = GUICtrlCreateListView("col1 |col2|col3 ", 10, 10, 200, 150) Local $idButton1 = GUICtrlCreateButton("Send", 75, 170, 70, 20) Local $idButton2 = GUICtrlCreateButton("Delete", 75, 195, 70, 20) Local $idItem1 = GUICtrlCreateListViewItem("item2|col22|col23", $idListview) Local $idItem2 = GUICtrlCreateListViewItem("item1|col12|col13", $idListview) Local $idItem3 = GUICtrlCreateListViewItem("item3|col32|col33", $idListview) GUISetState(@SW_SHOW) ConsoleWrite($idItem1 & "/" & $idItem2 & "/" & $idItem3 & @CRLF) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idButton1 _SendMessage(GUICtrlGetHandle($idListview), $LVM_DELETEALLITEMS) Sleep(5000) $idItem1 = GUICtrlCreateListViewItem("item2|col22|col23", $idListview) $idItem2 = GUICtrlCreateListViewItem("item1|col12|col13", $idListview) $idItem3 = GUICtrlCreateListViewItem("item3|col32|col33", $idListview) ConsoleWrite($idItem1 & "/" & $idItem2 & "/" & $idItem3 & @CRLF) Case $idButton2 For $i = $idItem1 to $idItem3 GUICtrlDelete($i) Next Sleep(5000) $idItem1 = GUICtrlCreateListViewItem("item2|col22|col23", $idListview) $idItem2 = GUICtrlCreateListViewItem("item1|col12|col13", $idListview) $idItem3 = GUICtrlCreateListViewItem("item3|col32|col33", $idListview) ConsoleWrite($idItem1 & "/" & $idItem2 & "/" & $idItem3 & @CRLF) EndSwitch WEnd EndFunc ;==>Example2 points -
The GUI looks like shown in the picture: It contains a main menu, a treeview in left pane that lists UI Automation elements, a listview in right pane that displays detail information for the selected element, and a splitterbar to adjust the width of the two panes. Detect element The "Detect element" main menu is used to detect elements under the mouse with function keys F1 - F4. See How to topics number 2. Left pane The left pane is a treeview that initially lists open programs and windows. Generally, the left pane shows UI Automation elements represented as treeview items. Right pane The right pane is a listview that displays detail information for the selected treeview element. The information is grouped into different types of information. Only the relevant information for each type is displayed. Invalid elements When a window is closed the elements in UIASpy becomes invalid. But the elements are not deleted in UIASpy and can still be handled and selected in the treeview. Detail information for an element that was calculated before the window was closed can still be seen in the listview. In this way it's possible for UIASpy to show information for eg. a context menu that is closed as soon as it loses focus. Listview features Listview features Help system With completion of the Help system, a lot of information has been moved from this post and other posts into the Help system. Sample code creation Sample code creation is implemented through the UI element Detail info listview page and through the Sample code main menu. Sample code creates code snippets based on data in one or more selected rows in the Detail info listview page or based on the clicked Sample code menu item. UI Automation code is largely based on COM interface objects and thus on the function ObjCreateInterface(), which is one of the advanced functions in AutoIt. The main purpose of Sample code functionality is to eliminate the complexity of ObjCreateInterface(). Sample code creation either through the Detail info listview page or through the Sample code main menu can create all the interface objects required in UI Automation code. Another purpose is of course to make it easier and faster to implement code for simple automation tasks. Through Sample code creation, you can more or less create all code in a simple automation task: Create UI Automation initial code Create condition and find application window Create condition and find control in window Get information about windows and controls Create pattern objects to perform actions Get information related to pattern objects Perform actions with pattern object methods Add a Sleep() statement if necessary Note that the UI element used in sample code is named after the selected element in the treeview. Also note that both the Sample code menu items and the sections in the Detail info listview page are placed in approximately the order they are used in a simple automation task. Sample code creation through Detail info listview page Sample code creation through Sample code main menu Supported applications Most browsers including Google Chrome To be able to spy on web content in Google Chrome it's necessary to enable accessibility by entering chrome://accessibility/ in the address bar of a new tab item, and then check the five check boxes that are located in a column in upper left corner down along the left edge. Then the accessibility tab can be closed again. It's a global setting that applies to all open and new tabs until Chrome is closed. Without accessibility enabled you are only able to investigate the outer elements of Chrome but not web content. Internet Explorer Microsoft Edge Mozilla Firefox Most Microsoft applications and applications developed with Microsoft software including Classic Windows applications based on the standard control library Modern Universal Windows Platform apps like the Windows 10 Calculator Programs implemented through .NET Framework eg. Windows Forms applications Most applications provided by major development companies Automation issues Automation issues How to topics If UI Automation or the UIASpy tool is new to you, then you should read the How to topics. Examples Examples that demonstrates the features of UIASpy: Automating Notepad. Very detailed example. Automating Notepad - Windows XP Examples about Sample code creation: Automating Notepad with Sample code - step by step Automating Notepad with Sample code - all at once Chrome - Clicking an extension. Compact summary example. Click Save As... issue in Notepad examples: Using Expand() instead of Invoke() Updates Windows 8, Windows 8.1 and Windows 10 updates Threads UI Automation UDFs contains all include files. In Using UI Automation Code in AutoIt you can find and download examples and read information about using UIA code. UI Automation Events is about implementing event handlers and includes GUIs to detect events. IUIAutomation MS framework automate chrome, FF, IE, .... created by junkew August 2013 is the first AutoIt thread on UIA code. Zip-file The zip contains source files for UIASpy GUI. Note that UI Automation UDFs must be installed in the Includes folder. You need AutoIt 3.3.12 or later. Tested on Windows XP, Windows 7 and Windows 10. Comments are welcome. Let me know if there are any issues. UIASpy.7z1 point
-
Sorry, my confusion came from the "read only" in your first sentence, and then i misunderstood this: "when you open [...] will be as they originally were" (i connected this ideas...) I clearly need to improve my English and also the level of attention when reading Thanks for all your work in the forum!1 point
-
"Ghost" console messages
argumentum reacted to pseakins for a topic
Of course we don't know because you haven't given us any information. All very vague. If you show us an example of the code we may be able to help. You have to ensure that the code is not running when you compile your changes. If you didn't look closely at the output window you may not have noticed that the compile didn't complete.1 point -
Is GUICtrlDelete() recommended for zapping listview items?
pixelsearch reacted to CYCho for a topic
@pixelsearch, In your post mentioned above you said: A worse idea would be to call _SendMessage($g_hListView, $LVM_DELETEALLITEMS) when all your items are natively created with GUICtrlCreateListViewItem(). In this case, deleting the listview control and creating a new one may be a viable option. I used _SendMessage($g_hListView, $LVM_DELETEALLITEMS) in my latest update(3.0.1.6) of zPlayer and I like it. You are full of ideas and, as your avatar shows, you are very good at scholarly details. I respect you and I am glad to have you nearby.1 point -
New version V1.4.3 See the first post for the changes.1 point
-
ListView export speed
Skysnake reacted to pixelsearch for a topic
Hi everybody Even if they're not recent, both following links are interesting if you want to know how to improve speed in your listview control : https://www.autoitscript.com/forum/topic/67829-_guictrllistview_additem-much-slower-than-guictrlcreatelistviewitem/ https://www.autoitscript.com/forum/topic/132703-correct-way-to-clear-a-listview-solved/ Also LarsJ , in this thread, wrote what follows : "A general approach to listviews is to create listview and listview items with native functions due to speed and then use UDF functions for everything else." I'd like to add 2 comments based on the little experience I got with my "CSV file editor" script : 1) If the data you need to populate your listview is contained in an array, then do not use the native function GUICtrlCreateListViewItem() in a loop, but choose instead the function _GUICtrlListView_AddArray() This function, found in GuiListView.au3 and written by Paul Campbell & Gary Frost is optimized and its speed will be 3 times faster than a loop with many GUICtrlCreateListViewItem() needed to populate the listview. Why is it faster ? Because there's a loop on items & subitems, the loop is included in the function and the buffer involved is opened only once. That's the reason why the next release of "CSV file editor" will be based on _GUICtrlListView_AddArray() instead of GUICtrlCreateListViewItem(), which will allow to populate the listview 3 times faster during the import phase (tests done successfully on arrays of 1000, 10000, 36000 rows) 2) Now let's talk about deleting all items in a listview : => if you added your items with GUICtrlCreateListViewItem() then deleting thousands of items will take a lot of time because each control has to be deleted one by one in a loop, using GuiCtrlDelete() as explained by Gary Frost himself, here => if you added your items with _GUICtrlListView_AddArray() then deleting all items could be done in a snap, like this : $g_idListView = GUICtrlCreateListView(...) ; native-created listview $g_hListView = GuiCtrlGetHandle($g_idListView) _GUICtrlListView_AddArray($g_idListview, ...) ; populating listview (fastest way) _SendMessage($g_hListView, $LVM_DELETEALLITEMS) ; fast deletion + no id's leaks So, if you are sure that your listview items are not native, then you don't need to call _GUICtrlListView_DeleteAllItems() . Just Send the Message $LVM_DELETEALLITEMS and avoid the loop found in _GUICtrlListView_DeleteAllItems() which would inspect each item to know if it's native or not (you know they are not !) A worse idea would be to call _SendMessage($g_hListView, $LVM_DELETEALLITEMS) when all your items are natively created with GUICtrlCreateListViewItem() . Why is that ? Because though deletion appears fast on your monitor, AutoIt will not delete any of the thousands of items controls id's and you'll end with plenty of handle leaks. Have a look at BrewManNH's post, which explains the situation. And even if "we can have up to 64k control ids", imagine a user doing this in the same session : * 1st file imported in listview, 30.000 items, using GUICtrlCreateListViewItem() * Delete them all with _SendMessage($g_hListView, $LVM_DELETEALLITEMS), bad way * Now Autoit would (for example) assign a control id of 30.027 for any new control created * 2nd file imported in listview, 30.000 items, using GUICtrlCreateListViewItem() * Delete them all... and you already reached 60.000 id's all "alive" for AutoIt None of this happens the other way, which is : * 1st file imported in listview, 30.000 items, using _GUICtrlListView_AddArray() * Delete them all with _SendMessage($g_hListView, $LVM_DELETEALLITEMS), good way * Now Autoit would (for example) assign a control id of 27 for any new control created, great * 2nd file imported in listview, 30.000 items, using _GUICtrlListView_AddArray() * Delete them all... and your new controls id would still start at 27, no leak. My conclusion (for now) : _GUICtrlListView_AddArray() rules for both reasons described above1 point -
As mentioned: You are running the lite version. Just download the separate full SciTE4AutoIt3 installer to get all the goodies. Jos1 point