NotStr() : Switch between multiple states

Post your working scripts, libraries and tools for AHK v1.1 and older
piddly
Posts: 6
Joined: 19 May 2020, 03:48

Re: NotStr() : Switch between multiple states

Post by piddly » 19 May 2020, 08:18

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()]
}

User avatar
SKAN
Posts: 1551
Joined: 29 Sep 2013, 16:58

Cycle thru open Explorer windows

Post by SKAN » 21 May 2020, 08:38

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)
}
My Scripts and Functions: V1  V2
burque505
Posts: 1736
Joined: 22 Jan 2017, 19:37

Re: NotStr() : Switch between multiple states

Post by burque505 » 21 May 2020, 09:11

:clap: Wow. What a great script, @SKAN. That gets added to my startup scripts for sure.
Thank you!!!!!
Regards,
burque505
User avatar
SKAN
Posts: 1551
Joined: 29 Sep 2013, 16:58

Re: NotStr() : Switch between multiple states

Post by SKAN » 21 May 2020, 10:37

burque505 wrote:
21 May 2020, 09:11
:clap: Wow. What a great script, @SKAN. That gets added to my startup scripts for sure.
:) :thumbup:

PS: I'm too building one master startup script for explorer...
My Scripts and Functions: V1  V2
Post Reply

Return to “Scripts and Functions (v1)”