[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"
   }
}
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。

给TA捐赠
共{{data.count}}人
人已捐赠
其他

新年贺曲——AHK Music库应用

2023-1-4 18:32:20

其他

[AHK]面向对象的实例--point和line

2023-1-6 10:08:56

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
有新私信 私信列表
搜索