Nivse Posted November 17, 2009 Share Posted November 17, 2009 Hello all, I'm using autoit to write script over some program which uses "SysListView32" control. As part of the program, sometime new entries are getting in to the "SysListView32" control accordign to some specific actions the program does. My goal is to get an event each and every time a new entry got in to the "SysListView32" control and do some specific action. My question is how can i create an event (something like delegate in C#) or use an existing one for the "SysListView32" control. thanks, Nivse Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 17, 2009 Moderators Share Posted November 17, 2009 Nivse,First, welcome to the Autoit forums. Take a look at the ControlListView function. I have not used it myself, but it looks as it the "GetItemCount" command might be what you are looking for - just keep polling the LV until the count changes.Give it a try and come back if you have problems.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...
Nivse Posted November 17, 2009 Author Share Posted November 17, 2009 Nivse,First, welcome to the Autoit forums. Take a look at the ControlListView function. I have not used it myself, but it looks as it the "GetItemCount" command might be what you are looking for - just keep polling the LV until the count changes.Give it a try and come back if you have problems.M23I thought about this kind of solution but wouldn't it require another thread to run and pull the items from LV?i won't my program to run or wait for user action and when new element is inserted to the LV an action will be taken.... Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 17, 2009 Moderators Share Posted November 17, 2009 (edited) Nivse, In pseudo-code I would do something like this: HotKeySet so you can exit Old_Count = initial count of LV items ; Start infinite loop While 1 New_Count = Current LV item count If New_count <> Old-Count Then Do_something() EndIf Old_Count = New_Count Sleep a bit to prevent CPU overload WEnd Func Do_something() Code EndFunc Func _Exit Exit EndFunc Now you just start your script and leave it running. M23 Edit: Speeling - or to be honest Tpying Edited November 17, 2009 by Melba23 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...
Nivse Posted November 17, 2009 Author Share Posted November 17, 2009 Nivse, In pseudo-code I would do something like this: HotKeySet so you can exit Old_Count = initial count of LV items ; Start infinite loop While 1 New_Count = Current LV item count If New_count <> Old-Count Then Do_something() EndIf Old_Count = New_Count Sleep a bit to prevent CPU overload WEnd Func Do_something() Code EndFunc Func _Exit Exit EndFunc Now you just start your script and leave it running. M23 Edit: Speeling - or to be honest Tpying Well it's a bit more complicated then that... let me explain: My program control on softphone application. with my program i can automaticaly send commands in text, "dial" for example and with autoit i press the relevant buttons on the softphone application. this application also has a status window - the list view control. if i gave a "dial" instruction then i get dial a new entry in the list view - "dialing" now i want to keep a state machine to know in which state im currently in (dialing, ringing, answered, idle etc...) all these states are a result in the LV from the commands i send. when i send the command -"dialing" for example i have no problem since i know the state - "dialing" but... in the other side someone is answering maybe and this command doesn't sent by me but from the other side thus i have a schange in the state that didn't came from my command (dialing --> answered). this is way i need to read from LV to get the states directly from it and not from the command certain side is sending. so my program always runs and wait for commands i just need an event for cases where a new entry got in the LV so i would update my state and continue waiting for user command. i don't see how can implement you solution above in my program please correct me if im wrong. hope you have a better solution for me thanks a lot, Nivse Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 17, 2009 Moderators Share Posted November 17, 2009 Nivse,Firstly, when you reply please use the "Add Reply" button at the top and bottom of the page rather then the "Reply" button in the post itself. That way you do not get the contents of the previous post quoted in your reply and the whole thread becomes easier to read. Now, my understanding of the ControlListView function is that it will work on controls in windows other than those created by your own script. The "GetItemCount" command will get you the number of items in the list - it should then be simple simple to use the "GetText" command to tell you what the new item is - if it is one produced by your own script, then ignore it; if it is produced by the other side, then action it.For responses to your own inputs I would suggest something along these lines: Your script places "dialing" into the LV - you recognise that a new item has been put into the LV, and you know it is one of your own. You therefore just keep re-reading that item using the "GetText" command and see what the response is. If the text becomes "dialing --> answered" then you take certain actions, if it becomes "dialling --> no-one home" than you do something else.So I suggest that you go and try to script something along the lines of the suggestions above and then come back if you run into problems. 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...
Nivse Posted November 17, 2009 Author Share Posted November 17, 2009 thanks a lot , It really helped, i will try it tomorrow and come back if i will have more issues. thanks, Niv 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