Page 3 of 3
Re: NotStr() : Switch between multiple states
Posted: 19 May 2020, 08:18
by piddly
Another approach: Added parameter 'b' (=1 for previous element). Case-sensitivity lost.
Code: Select all
h := "a|ba|b|ab|aa|bb", n := "Ba"
Msgbox % Neighbour(h, n,,1) ; a
n = first element returns empty string. Code can be fixed to return last element.
Code: Select all
Neighbour(h, n = "", s = "|", b = 0)
{ z := StrSplit(h, s)[1], h := s h s z s, arr := StrSplit(StrReplace(h, s n s, "¢"), "¢"), arrr := StrSplit(arr[2 - b], s)
return n = "" ? z : arr[1] = h ? "" : arrr[b = 0 ? 1 : arrr.MaxIndex()]
}
Cycle thru open Explorer windows
Posted: 21 May 2020, 08:38
by SKAN
Run script and use
hotkeys Win+n (next) and
Win+b (before) to cycle through open explorer windows.
Code: Select all
#NoEnv
#Warn
#SingleInstance, Force
#n:: WinActivate, % "ahk_id" NotStr( WinExist("A"), Explorer_hList(0) ) ; Next
#b:: WinActivate, % "ahk_id" NotStr( WinExist("A"), Explorer_hList(1) ) ; Before
Return
Explorer_hList(Rev:=0) {
Local Window, hWnd, hList := ""
For Window in ComObjCreate("Shell.Application").Windows
If ( Window.Name="Windows Explorer" or Window.Name="File Explorer" )
&& ( hWnd := WinExist( "ahk_id" . Window.hWnd) )
Rev ? hList .= hWnd . "|" : hList := hWnd . "|" . hList
Return RTrim(hList,"|")
}
NotStr(S:="", Z:="", D:="|") { ; NotStr v0.6b By SKAN on D34M/D34R @ tiny.cc/notstr
Local Q, LS:=StrLen(S), LZ:=StrLen(Z), LD:=StrLen(D), P1, P2, Q
Return SubStr(LZ?Z:1,(P1:=LS+LZ=0||S=Z?1:InStr(Z,(S)(D),0,0-LZ+LS+LD)?LS+LD+1:InStr(Z,(D)(S),0,LZ
-LS)?1:(Q:=InStr(Z,(D)(S)(D)))?Q+LD+LS+LD:1),(LS+LZ=0?2:S=Z?1:(Q:=InStr(Z,D,0,P1))?Q:LZ+1)-P1)
}
Re: NotStr() : Switch between multiple states
Posted: 21 May 2020, 09:11
by burque505
Wow. What a great script,
@SKAN. That gets added to my startup scripts for sure.
Thank you!!!!!
Regards,
burque505
Re: NotStr() : Switch between multiple states
Posted: 21 May 2020, 10:37
by SKAN
burque505 wrote: ↑21 May 2020, 09:11
Wow. What a great script, @SKAN. That gets added to my startup scripts for sure.
PS: I'm too building one master startup script for explorer...