;Start: /tool
;Stop: /tool stop
alias tool {
if (!$1) {
cwnd subclass tool $dll(cwnd.dll,findWindowEx,$window(-2).hwnd > > mIRC_ToolBar) 0 tool
cwnd block tool 1 LBUTTONUP
}
elseif ($1 == stop) cwnd sfree tool
elseif ($2 == LBUTTONUP) {
var %parms = $5-6
var %i = 0, %a = 1, %x = $3, %y = $4, %handle = $cwnd(getInfo,tool handle)
while (%i < 34) {
tokenize 32 $tool_coords(%i)
if (!$1- || $3 == 1) {
inc %i
continue
}
if ($inrect(%x,%y,$1,$2,$3,$4)) {
;%a = Nth Button of the toolbar
if (%a != 5) {
cwnd callWindowProc tool LBUTTONUP %parms
}
else cwnd callWindowProc tool RBUTTONUP 0 $calc(%x + %y * 65536)
break
}
inc %i
inc %a
}
}
}
alias -l tool_coords {
cwnd newStruct rect 16
if (!$cwnd(sendMessage,$cwnd(findWindowEx,$window(-2).hwnd > > mIRC_ToolBar) 1053 $1 $cwnd(getStructInfo,rect pointer))) return 0
var %s $cwnd(getStructInfo,rect dword 0) $cwnd(getStructInfo,rect dword 4) $&
$calc($cwnd(getStructInfo,rect dword 8) - $cwnd(getStructInfo,rect dword 0)) $&
$calc($cwnd(getStructInfo,rect dword 12) - $cwnd(getStructInfo,rect dword 4))
cwnd delStruct rect
return %s
}
alias -l cwnd {
if ($isid) {
var %res = $dll($scriptdircwnd.dll,$1,$2-)
if ($prop != $null) return $gettok(%res,$prop,32)
return %res
}
dll " $+ $scriptdircwnd.dll" $1-
}