Project

General

Profile

RE: [Script] Find Window » FindWindow.ini

Mr. BS, 07/11/2016 12:39 AM

 
on *:Input:$($winput): {
findwindow $1
halt
}

alias -l winput return @findwindowinput
alias -l wresults return @findwindowresults
on *:Close:$($winput): { closeall }
on *:Appactive: { tokenize 32 $winput $wresults @fwclose | togglevisibility $* }
alias -l togglevisibility $iif($window($1), $iif($appactive, window -a $1, window -h $1))
alias -l closeall { window -c $winput | window -c $wresults | window -c @fwclose }
alias -l fwclose {
if (!$window(@fwclose)) window -k0w0Bpdo +dL @fwclose $calc($window($winput).dx + $window($winput).w -1) $window($winput).dy 29 29
var %bg $iif($1 == red,$rgb(199,80,80),$rgb(150,150,150))
drawfill -r @fwclose $rgb(100,100,100) 0 0 0
drawrect -rf @fwclose %bg 1 1 1 27 27
drawtext -rb @fwclose $rgb(255,255,255) %bg "Arial Unicode MS" 22 7 1 $chr(10006)
}
alias -l f {
var %font $readini($adiircini,n,Messages,$1)
return $qt($iif($chr(44) isin %font,$gettok(%font,1,44),$gettok(%font,1--2,32)))
}

on *:Keydown:*:*: {
; tab
if ($istok($winput $wresults,$active,32) && $keyval == 9) { window -a $$window($iif($active == $winput,$wresults,$winput)) | halt }
; esc
if ($active == $wresults && $keyval == 27) window -a $winput
; ctrl + 2
if ($mouse.key & 2 && $keyval == 50) $iif($window($winput),window -a $v1,findwindow)
}

alias findwindow {
if (!$window($winput)) window -k0w0BdCeo +bL $winput -1 -1 400 29 $f(EditboxFont) 16
fwclose
var %search $1
if (!%search) {
window -a $winput | window -c $wresults
return
}

editbox $winput $1
%search = $+(*,%search,*)

if ($window($wresults)) clear $wresults
else window -k0w0Bdol +bL $wresults $window($winput).dx $calc($window($winput).dy + $window($winput).h -1) 428 204 $f(Font)
var %s 0, %o $window(0)
while (%s < $scon(0)) {
inc %s
scon %s
var %w 0
while (%w < $window(%search, 0)) {
inc %w
if (($window(%search, %w).type == custom) && ($cid != $window(%search, %w).cid)) || ($istok($winput $wresults @fwclose,$window(%search, %w),32)) continue
aline $wresults %s $iif($network,$v1,$servertarget) $window(%search, %w)
}
}

; orphan custom windows
while (%o) {
if ($window(%search,%o) && !$fline($wresults,* $+ $window(%search,%o) $+ *) && !$istok($winput $wresults @fwclose,$window(%o),32)) aline $wresults 0 $v1 @ $+ $window(%search,%o).wid
dec %o
}
if (!$line($wresults,0)) { aline $wresults no results. | window -a $winput }
else { window -a $wresults | sline $wresults 1 }
}

menu @findwindowresults {
dclick:{
scon $gettok($line($wresults,$1),1,32) window -a $qt($$gettok($line($wresults,$1),3-,32))
closeall
}
}

menu @fwclose {
mouse:if (!%fwclosemouse) fwclose red | set -e %fwclosemouse 1
leave:fwclose | unset %fwclosemouse
uclick:unset %fwclosemouse | closeall
}

menu channel,status,query,menubar {
-
Find Window:findwindow
}
(3-3/3)