Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Manipulate 3 Windows Explorer windows with same base path.
#1
Trying to find a good way to manipulate 3 Windows Explorer windows,
they all have the same base path for example: "C:\Temp"

w1=("C:\Temp\dir1" "CabinetWClass")
w2=("C:\Temp\dir2" "CabinetWClass")
w3=("C:\Temp" "CabinetWClass")

Now, if I want to mov or clo or min, etc. it will sometimes 
manipulate the wrong window.

Is there a better way to definitively define these windows??
Thx in Adv.
#2
In this case can be used win, because window name is different: dir1, dir2, Temp.

Also it's possible to get folder path.

Function FolderWindowGetAddress
Code:
Copy      Help
;/
function! w str&address

;Gets the address field text from a folder window.
;It's the editable text displayed when clicked. It can be folder path, or special folder name like "Documents", or whatever.

;EXAMPLE
;int w=win("Test" "CabinetWClass")
;if(FolderWindowGetAddress(w _s)) out _s


if(!WinTest(w "CabinetWClass")) ret
int c=child("Address: *" "ToolbarWindow32" w 0x401); if(!c) ret
_s.getwintext(c); if(_s.len<10) ret
address.get(_s 9)
ret 1

Function FolderWindowFind
Code:
Copy      Help
;/
function# $address [flags] ;;flags: 1 wildcard, 2 regex

;Finds folder window with specified text in the address field.

;address - the address text. It can be folder path, or special folder name like "Documents", or whatever. See <help>FolderWindowGetPath</help>. Case-insensitive. Can be wildcard or regex, depending on flags.

;EXAMPLE
;int w=FolderWindowFind("c:\test")
;outw w


ARRAY(int) a; int i
win "" "CabinetWClass" "explorer.exe" 0x401 "" a
for i 0 a.len
,int w=a[i]
,if FolderWindowGetAddress(w _s)
,,int ok
,,sel flags&3
,,,case 1 ok = matchw(_s address 1)
,,,case 2 ok = findrx(_s address 0 1)>=0
,,,case else ok = _s~address
,,if(ok) ret w
#3
That works! Thanks Gintaras
#4
Gintaras, I am having timing issues with the code (Error (RT) in <open ":4578: /1470">M3__Wins:  window not found (the handle is 0). --> Maybe there is a more efficient way to do it?
Trying to open and position 7 explorer folders quickly, and another function "CloseWindows2" to close
quickly only the 7 folders that were opened by function "M03 Wins"

Function M3__Wins
Code:
Copy      Help
/ M3__Wins \
;; ::::::::::::::::::::::  
;; 2021-09-12  Sunday  -  17.34.16
;;;;© Scott_F  †††     -->  Version 1.0.0
;;;
spe 500

str s1 s2 s3 s4 s5 s6 s7
int w

s1="C:\M03 Wins\dir5" ;; -1601 13 501 464
s2="C:\M03 Wins\dir4" ;; -1602 477 501 426
s3="C:\M03 Wins\dir3" ;; -1091 31 501 419
s4="C:\M03 Wins\dir2" ;; -1089 454 501 419
s5="C:\M03 Wins\dir1" ;; -575 30 501 419
s6="C:\M03 Wins" ;; -573 460 501 420
s7="C:\Temp" ;; 167 6 980 476


;;; win1
;;; open Folder.
run s1 "" "" "" 0x100|0x200|0x800|0x10000; 0.23
w=wait(10 WV win(s1 "CabinetWClass")) ;;
w=FolderWindowFind(s1)
outw w
act w; 0.23            ;; activate it
mov+ -1601 13 501 464 w    ;; mov window to location and size.


;;; win2
;;; open Folder.
run s2 "" "" "" 0x100|0x200|0x800|0x10000; 2.23
w=wait(10 WV win(s2 "CabinetWClass")) ;;
w=FolderWindowFind(s2)
outw w
act w; 0.23            ;; activate it
mov+ -1602 477 501 426 w    ;; mov window to location and size.


;;; win3
;;; open Folder.
run s3 "" "" "" 0x100|0x200|0x800|0x10000; 0.23
w=wait(10 WV win(s3 "CabinetWClass")) ;;
w=FolderWindowFind(s3)
outw w
act w; 0.23            ;; activate it
mov+ -1091 31 501 419 w    ;; mov window to location and size.


;;; win4
;;; open Folder.
run s4 "" "" "" 0x100|0x200|0x800|0x10000; 0.23
w=wait(10 WV win(s4 "CabinetWClass")) ;;
w=FolderWindowFind(s4)
outw w
act w; 0.23            ;; activate it
mov+ -1089 454 501 419 w    ;; mov window to location and size.


;;; win5
;;; open Folder.
run s5 "" "" "" 0x100|0x200|0x800|0x10000; 0.23
w=wait(10 WV win(s5 "CabinetWClass")) ;;
w=FolderWindowFind(s5)
outw w
act w; 0.23            ;; activate it
mov+ -575 30 501 419 w    ;; mov window to location and size.


;;; win6
;;; open Folder.
run s6 "" "" "" 0x100|0x200|0x800|0x10000; 0.23
w=wait(10 WV win(s6 "CabinetWClass")) ;;
w=FolderWindowFind(s6)
outw w
act w; 0.23            ;; activate it
mov+ -573 460 501 420 w    ;; mov window to location and size.


;;; win7
;;; open Folder.
run s7 "" "" "" 0x100|0x200|0x800|0x10000; 0.23
w=wait(10 WV win(s7 "CabinetWClass")); 0.23 
w=FolderWindowFind(s7)
outw w
act w; 0.23            ;; activate it
mov+ 167 6 980 476 w    ;; mov window to location and size.


Function CloseWindows2
Code:
Copy      Help
;CloseWindows2


str s1 s2 s3 s4 s5 s6 s7 sw2
int w
;out

s1="C:\M03 Wins\dir5" ;; -1601 13 501 464
s2="C:\M03 Wins\dir4" ;; -1602 477 501 426
s3="C:\M03 Wins\dir3" ;; -1091 31 501 419
s4="C:\M03 Wins\dir2" ;; -1089 454 501 419
s5="C:\M03 Wins\dir1" ;; -575 30 501 419
s6="C:\M03 Wins" ;; -573 460 501 420
s7="C:\Temp" ;; 167 6 980 476



;;; close
w=win(s1 "CabinetWClass")
if w
,act w
,clo w
,0.05

w=win(s2 "CabinetWClass")
if w
,act w
,clo w
,0.05

w=win(s3 "CabinetWClass")
if w
,act w
,clo w
,0.05

w=win(s4 "CabinetWClass")
if w
,act w
,clo w
,0.05

w=win(s5 "CabinetWClass")
if w
,act w
,clo w
,0.05

w=win(s6 "CabinetWClass")
if w
,act w
,clo w
,0.05

w=win(s7 "CabinetWClass")
if w
,act w
,clo w
#5
since all windows have different names can just use win

try these
Function M3__Wins
Code:
Copy      Help
ARRAY(str) winNames.create(7)
ARRAY(int) winHandles.create(7)
winNames[0]="C:\M03 Wins\dir1";; -575 30 501 419
winNames[1]="C:\M03 Wins\dir2";; -1089 454 501 419
winNames[2]="C:\M03 Wins\dir3" ;; -1091 31 501 419
winNames[3]="C:\M03 Wins\dir4" ;; -1602 477 501 426
winNames[4]="C:\M03 Wins\dir5" ;; -1601 13 501 464
winNames[5]="C:\M03 Wins";; -573 460 501 420
winNames[6]="C:\Temp" ;; 167 6 980 476

for int'i 0 winNames.len
,run winNames[i] "" "" "" 0x100|0x800|0x10000 win(winNames[i] "CabinetWClass") winHandles[i]
,outw winHandles[i]
,sel i
,,case 0
,,mov+ -575 30 501 419 winHandles[i]
,,case 1
,,mov+ -1089 454 501 419 winHandles[i]
,,case 2
,,mov+ -1091 31 501 419 winHandles[i]
,,case 3
,,mov+ -1602 477 501 426 winHandles[i] 
,,case 4
,,mov+ -1601 13 501 464 winHandles[i]
,,case 5
,,mov+ -573 460 501 420 winHandles[i]
,,case 6
,,mov+ 167 6 980 476 winHandles[i]



Function CloseWindows2
Code:
Copy      Help
ARRAY(str) winNames.create(7)
winNames[0]="C:\M03 Wins\dir1";; -575 30 501 419
winNames[1]="C:\M03 Wins\dir2";; -1089 454 501 419
winNames[2]="C:\M03 Wins\dir3" ;; -1091 31 501 419
winNames[3]="C:\M03 Wins\dir4" ;; -1602 477 501 426
winNames[4]="C:\M03 Wins\dir5" ;; -1601 13 501 464
winNames[5]="C:\M03 Wins";; -573 460 501 420
winNames[6]="C:\Temp" ;; 167 6 980 476

ARRAY(int) a
opt hidden 1
win("" "CabinetWClass" "" 0 0 0 a)
opt hidden 0
int i
for i 0 a.len
,str txt.getwintext(a[i])
,for int'j 0 winNames.len
,,if(txt =winNames[j])
,,,clo a[i]
#6
Hi Kevin, I tried running the code and gives the following output:

82446964 CabinetWClass "C:\M03 Wins\dir1" EXPLORER
133920 CabinetWClass "C:\M03 Wins\dir2" EXPLORER
68844 CabinetWClass "C:\M03 Wins\dir3" EXPLORER
134534 CabinetWClass "C:\M03 Wins\dir4" EXPLORER
69166 CabinetWClass "C:\M03 Wins\dir5" EXPLORER
69166 CabinetWClass "C:\M03 Wins\dir5" EXPLORER
134856 CabinetWClass "C:\Temp" EXPLORER

So it seems to output two number 5 dirs, however, it does not open two number 5's.
 
Code:
Copy      Help
winNames[5]="C:\M03 Wins";; -573 460 501 420

And did not open the "C:\M03 Wins" directory, this is similar problem I had with my other code.
For some reason windows does not want to open the parent directory.
I'm stumped...
PS. sorry for the x y coords, I'm running 3 Monitors. And thanks for the help!

PPS.  Never mind Kevin, I just switched 0 with 5
winNames[5]="C:\M03 Wins\dir1";; -575 30 501 419
winNames[1]="C:\M03 Wins\dir2";; -1089 454 501 419
winNames[2]="C:\M03 Wins\dir3" ;; -1091 31 501 419
winNames[3]="C:\M03 Wins\dir4" ;; -1602 477 501 426
winNames[4]="C:\M03 Wins\dir5" ;; -1601 13 501 464
winNames[0]="C:\M03 Wins";; -573 460 501 420
winNames[6]="C:\Temp" ;; 167 6 980 476

Thanks again!!


Forum Jump:


Users browsing this thread: 7 Guest(s)