Project

General

Profile

RE: [Script] Find Window » FindWindow.ini

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

 
1
on *:Input:$($winput): {
2
  findwindow $1
3
  halt
4
}
5

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

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

    
33
alias findwindow {
34
  if (!$window($winput)) window -k0w0BdCeo +bL $winput -1 -1 400 29 $f(EditboxFont) 16
35
  fwclose
36
  var %search $1
37
  if (!%search) {
38
    window -a $winput | window -c $wresults
39
    return
40
  }
41

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

    
45
  if ($window($wresults)) clear $wresults
46
  else window -k0w0Bdol +bL $wresults $window($winput).dx $calc($window($winput).dy + $window($winput).h -1) 428 204 $f(Font)
47
  
48
  var %s 0, %o $window(0)
49
  while (%s < $scon(0)) {
50
    inc %s
51
    scon %s
52
    var %w 0
53
        
54
    while (%w < $window(%search, 0)) {
55
      inc %w
56
      if (($window(%search, %w).type == custom) && ($cid != $window(%search, %w).cid)) || ($istok($winput $wresults @fwclose,$window(%search, %w),32)) continue
57
      aline $wresults %s $iif($network,$v1,$servertarget) $window(%search, %w)
58
    }
59
  }
60

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

    
70
menu @findwindowresults {
71
  dclick:{
72
    scon $gettok($line($wresults,$1),1,32) window -a $qt($$gettok($line($wresults,$1),3-,32))
73
    closeall
74
  }
75
}
76

    
77
menu @fwclose {
78
  mouse:if (!%fwclosemouse) fwclose red | set -e %fwclosemouse 1
79
  leave:fwclose | unset %fwclosemouse
80
  uclick:unset %fwclosemouse | closeall
81
}
82

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