[AHK]画矩形框

outline := new Outline("yellow")
outline.show(10,10,100,100)




class Outline {
   __New(color="red") {
      Gui, +HWNDdefault
      Loop, 4 {
         Gui, New, -Caption +ToolWindow HWNDhwnd
         Gui, Color, %color%
         this[A_Index] := hwnd
      }
      this.visible := false
      this.color := color
      this.top := this[1]
      this.right := this[2]
      this.bottom := this[3]
      this.left := this[4]
      Gui, %default%: Default
   }
   Show(x1, y1, x2, y2, sides="TRBL") { ; show outline at coords
      Gui, +HWNDdefault
      if InStr( sides, "T" )
         Gui, % this[1] ":Show", % "NA X" x1-2 " Y" y1-2 " W" x2-x1+4 " H" 2
      Else, Gui, % this[1] ":Hide"
      if InStr( sides, "R" )
         Gui, % this[2] ":Show", % "NA X" x2 " Y" y1 " W" 2 " H" y2-y1
      Else, Gui, % this[2] ":Hide"
      if InStr( sides, "B" )
         Gui, % this[3] ":Show", % "NA X" x1-2 " Y" y2 " W" x2-x1+4 " H" 2
      Else, Gui, % this[3] ":Hide"
      if InStr( sides, "L" )
         Gui, % this[4] ":Show", % "NA X" x1-2 " Y" y1 " W" 2 " H" y2-y1
      Else, Gui, % this[3] ":Hide"
      self.visible := true
      Gui, %default%: Default
   }
   Hide() { ; hide outline
      Gui, +HWNDdefault
      Loop, 4
         Gui, % this[A_Index] ": Hide"
      this.visible := false
      Gui, %default%: Default
   }
   SetAbove(hwnd) { ; set Z-Order one above "hwnd"
      ABOVE := DllCall("GetWindow", "uint", hwnd, "uint", 3) ; get window directly above "hwnd"
      Loop, 4  ; set 4 "outline" GUI's directly below "hwnd_above"
         DllCall(   "SetWindowPos", "uint", this[A_Index], "uint", ABOVE
                  ,   "int", 0, "int", 0, "int", 0, "int", 0
                  ,   "uint", 0x1|0x2|0x10   ) ; NOSIZE | NOMOVE | NOACTIVATE
   }
   Transparent(param) { ; set Transparent ( different from hiding )
      Loop, 4
         WinSet, Transparent, % param=1? 0:255, % "ahk_id" this[A_Index]
      this.visible := !param
   }
   SetColor(color) {
      Gui, +HWNDdefault
      Loop, 4
         Gui, % this[A_Index] ": Color" , %color%
      this.color := color
      Gui, %default%: Default
   }
   Destroy() {
      Loop, 4
         Gui, % this[A_Index] ": Destroy"
   }
}

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值