Project

General

Profile

RE: [Script] Find Window ยป findwindow2.ini

Per Amundsen, 12/16/2018 03:33 PM

 
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 2 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
;echo -sg $active - $wresults - $keyval - $istok($winput $wresults,$active,32)
26
  
27
  ; tab
28
  if ($istok($winput $wresults,$active,32) && $keyval == 9) { window -a $$window($iif($active == $winput,$wresults,$winput)) | halt }
29
  ; esc
30
  if ($active == $winput && $keyval == 27) { closeall | halt }
31
  if ($active == $wresults && $keyval == 27) window -a $winput
32
  ; ctrl + 2
33
  if ($mouse.key & 2 && $keyval == 50) $iif($window($winput),window -a $v1,findwindow)
34
}
35

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

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

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

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

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

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

    
86
menu channel,status,query,menubar {
87
  -
88
  Find Window:findwindow
89
}
    (1-1/1)