View Single Post
  #2  
Old 03-29-2023, 10:38 AM
Spliff Spliff is offline
Registered User
 
Join Date: 04-07-2021
Posts: 204
The user has to know their Tools-Options-Misc-CommandLineFormat:

a) Either you set it to something like
|ATTRIB|ATTRIB|ATTRIB| etc. (even leading and trailing "|" to ease up the scriptlet code),

then you must know and observe the order, and for the 3rd element e.g., you do (you JUST replace the single "3" here with the correct number):

; code 1, for 3rd element here:
pos1 := instr(clipboard, "|",,, 3) ; 3rd occurrence
pos2 := instr(clipboard, "|",, pos1+1) ; next occ after that
n := substr(clipboard, pos1+1, pos2-pos1-1)

b) Or you use (1-char) codes for your elements, then their order is irrelevant (to be preferred):
{eATTRIB}{aATTRIB}{mATTRIB} etc.

then you do either (third element again here):

; code 2, for element-code m here:
pos1 := instr(clipboard, "{m") ; unique occurrence
pos2 := instr(clipboard, "}",, pos1+1) ; next "}"
n := substr(clipboard, pos1+2, pos2-pos1-2)

or in just 1 line of code:

; code 3, for element-code m here:
pos := regexmatch(clipboard, "(?<=\{m).+?(?=\})", n)

(In both sub-alternatives, you JUST replace the single "m" with the correct code-char or code-number.)


THUS:

F12:: ExpandBy2Levels() ; or whatever shortkey

ExpandBy2Levels() ; to be triggered when respective sub-tree parent-item is selected
{ ; Begin of function
clipboard =
; clipwait, 5 ; up to 5s EDIT: DELETED: MISTAKE
sendevent, ^+i ; or whatever for Item-CopyItemCommandLine
clipwait, 5 ; up to 5s
; your adjusted special-code 1, 2 or 3 from above here:


; and then (as known from above):
sendevent, ^1 ; "go tree" (allows triggering even from content-pane)
sleep, 300
sendevent, +{left} ; shift-leftarrow or whatever for 2)-Coll (Tree-CollapseAll)
sleep, 500 ; milliseconds (might not be sufficient for large, expanded sub-trees)
sendevent, {right} ; or whatever for 3)-Exp (regular "expand item")
sleep, 300
sendevent, {down} ; "go first sibling" (all collapsed now)
sleep, 100
sendevent, !{end} ; alt-end or whatever for "go last sibling"
sleep, 100

; and finally, the loop with correct iteration number:
loop, %n%
{
sleep, 100
sendevent, {right} ; expands if children, else does nothing
sleep, 100
sendevent, {up} ; go previous item (we step from last item to first one)
sleep, 100
}
} ; End of function

Copyright by Spliff-in-UR-forum, no re-publication outside of this forum, licensed for personal use even in commercial environments.

(Code EDITED)

Last edited by Spliff; 03-29-2023 at 11:01 AM.
Reply With Quote