The full details of this issue are available in
this thread.
However, it boils down to the fact that it's impossible to register events on some/most nodes (in particular, I've been trying to use My Computer's child nodes) at startup. For example, the following code fails if run from OnStartup, but it works if triggered post-startup (e.g., from a menu item).
- Code: Select all
Sub OnStartup ' Or some other name, if called from menu item.
Dim mainTree : Set mainTree = SDB.MainTree
Dim myComputer : Set myComputer = mainTree.Node_MyComputer
myComputer.Expanded = True
Dim node : Set node = mainTree.FirstChildNode(myComputer)
While node.Path <> ""
node.UseScript = Script.ScriptPath
Script.RegisterEvent node, "OnNodeFocused", "Node_Is_Focused"
Set node = mainTree.NextNode(node)
Wend
End Sub
Function Node_Is_Focused(node)
MsgBox node.Path & "Focused"
End Function
What appears to be happening is that, at startup, my script does register the events -- but the nodes under My Computer are subsequently destroyed and re-created for some reason. Strangely, this does not appear to be the case on the very first run after installation -- for that instance only, I get duplicate nodes!