Hi Martin, First, congrats on attempting your own app! It's a major step forward to try one (if you haven't yet, I don't remember), so congrats!
I am not sure about the delay in speaking which you are seeing, but I suspect your hotkey is running a piece of your script, and this is tying up window-eyes the way it's being done, and causing the delay. I'll try and suggest a different approach, and we'll see if that was it. I should get back to doing more podcasts, and this type of problem solving is really where I wanted to go with some of them, but I always felt that there was more background which needed to be covered. I will get back to it though. I think your use of the "sleep" command is pausing your script, but not allowing other things to happen, and so you're seeing the delay. If nothing else, I'd break the commands off which come after the "sleep" and put them into their own routine, and then I'd try replacing the "sleep" command with a startTimer command, to run this little routine 200 milliseconds later. breaking off the execution of the first routine should return control back to window-eyes while waiting for the timer to expire and run the other little routine, and I think, should fix the delay you're seeing when you arrow down. This is only to demonstrate what the problem really is. If you want things to happen automatically, events are what you need to use. If you want to know what events are firing when you are in the treeview and you cursor down, you'll need to get to know the WE Event app. What I would do would be to get everything setup, so you are focused in the treeview, ready to cursor down. I'd press the hotkey for WE Event to bring it up, and I'd choose all the event categories, and then press the "select all" button to choose all events in these categories to be monitored. I'd then alt-tab back to your program, cursor down once in the treeview, and then alt-tab back to WE Event. This keeps your report WE Event has generated down to a minimum. Now use the "file" "save as" to save this report to a text file, and then close WE Event so it doesn't keep recording. This report shows you an event firing on every line. Because some of them are keyboard events, you'll see when you press the down arrow, what gets fired. The event I think will be the most help to you is probably the MSAA event onObjectSelection, which I think will fire when the treeview selection changes. if so, you could use it to then cause your "counting" and speaking to happen. If you don't see this event firing, you may have to post here the little report so we could suggest other options. If nothing else, you could use the various key down and key up events, but I'm hoping you can find something easier to work with. You'll need to get the name of the control which just had the selection event happen from the parameter passed to the onObjectSelection event (there are several choices here for getting this info), but the point is, you need to test to see if it's your treeview, and if it's not, just do nothing. At first, you could use a hotkey to start your event monitoring, and to stop it when you're done, just to see if it works like you want. then you could work on the proper way to set it all up. hth, Chip > -----Original Message----- > From: martin webster [mailto:[email protected]] > Sent: Tuesday, January 24, 2012 6:13 AM > To: [email protected] > Subject: help with treeview control > > Hi All, > I am scripting an application call Baygenie pro, which is > basically an ebay auction sniping tool available from > http://www.snapfiles.com/php/sfdwnld.php?id=111004&a=7134512&l > oc=2 This application has a treeview, which is not a custom > control, it's window type is 22 and it's class name > SysTreeView32. However this treeview does not work as > expected. All treeview item text is spoken until you want > information on the actual auctions. No information on the > auctions is available from the treeview itself, this is > displayed in a grid, and is only available when a treeview > item is selected, the information disappears or is changed as > soon as you cursor to another item in the treeview. I wrote a > small ap which when a hot key is pressed and any node in this > particuloar treview is selected window-eyes will tell me how > many items if any are selected in the grid. Example: if you > were bidding on two items and the treeview was focused and > you cursored down to bidding and pressed the hotkey, > window-eyes will search the grid, count the ebay item > numbers, and say two. Two problems with this aproach, one, > When the hotkey is pressed, and I quickly arrow down to the > next note in the treeview, window-eyes does not speak the > node text straight away. there is a delay of about 1 second > then everything is back to normal again. I can then cursor > through the nodes and the node text is spoken again. Second I > want this information to be spoken automatically as I cursor > up and down the treeview. Just how many items for now will > do. once I can see how it's done I'll be able to add more > functionality. Sorry if this seems to be a lengthy e-mail, I > am trying to be as detailed as possible. > Now follows my ap which tells me how many items are available > in the grid at the press of a hotkey. > > Begin VBScript > Dim MyHotkey > Set MyHotkey = > Keyboard.RegisterHotkey("Control-Shift-Windows-h", > "LaunchApp") Sub LaunchApp() CountItems End Sub Function > CountItems() Dim Grid, Matches, objRegExp Grid = > ActiveWindow.Children(19).Clips.Clipstext > Set objRegExp = New RegExp > objRegExp.Global = True > objRegExp.Pattern = "\d{12}" > Set Matches = objRegExp.Execute(Grid) > If Matches.Count > 0 Then > Speak Matches.Count > Else > X = 0 > Speak X > End If > End Function > > > I added the following routine to my main ap to try and get > the above function to work automatically, it didn't work. > > Begin VBScript > Dim TView > ActiveWinObj.Item(14).Focus 'tree view > Set TView = FocusedWindow.Parent.Control(59648).TopLevel > Sleep 200 > If TView(1).Children.Item(1).Selected Then CountItems End If > > Hope someone can shed some light on this. > Warm Regards. > Martin Webster > >
