Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
CoordMode, Mouse, Screen
loop, % (4, cl:= ["Yellow", "Red", "Green", "Blue"])
drawRectangle(200+(i:=A_Index)*30, 200+i*30, 400-i*60, 300-i*60, i, 15-i*3, cl[i])
ToolTip, Now please press any modifier key`,`nleft Click and drag the Mouse..., 200, 150
Esc:: ExitApp
^LButton::
MouseGetPos, x1, y1
While GetKeyState("LButton", "P") {
MouseGetPos, x2, y2
DrawRectangle(x1, y1, x2-x1, y2-y1, 5,, "Aqua") ; defalut frame, thickness and color
Sleep, 30
} ;DrawRectangle(,,,, 5) ; optional destory frame
Return
+LButton::
MouseGetPos, x1, y1
While GetKeyState("LButton", "P") {
MouseGetPos, x2, y2
DrawRectangle(x1, y1, x2-x1, y2-y1, 6, 5, "00ff00")
Sleep, 30
} ;DrawRectangle(,,,, 6) ; optional destory frame
Return
!LButton::
MouseGetPos, x1, y1
While GetKeyState("LButton", "P") {
MouseGetPos, x2, y2
DrawRectangle(x1, y1, x2-x1, y2-y1, 7, 9, "ff8000")
Sleep, 30
} ;DrawRectangle(,,,, 7) ; optional destory frame
Return
#LButton::
MouseGetPos, x1, y1
While GetKeyState("LButton", "P") {
MouseGetPos, x2, y2
DrawRectangle(x1, y1, x2-x1, y2-y1, 8, 1, "8800ff")
Sleep, 30
} ;DrawRectangle(,,,, 8) ; optional destory frame
Return
DrawRectangle(x1:=0, y1:=0, w1:=0, h1:=0, n:=1, bw:=3, cl:="ff0000") { ; flyingDman, RRR
Global FirstCall
if (w1=0 && h1=0) {
Gui % (n ": Destroy", FirstCall:=[])
Return
}
FirstCall? "": FirstCall:=[], FirstCall[n]? "": (FirstCall[n]:=[], FirstCall[n].1:=1)
, w1<0? (w1:=Abs(w1), x1:=x1-w1): "", h1<0? (h1:=Abs(h1), y1:=y1-h1): ""
Gui % n ": +LastFound"
w2:= w1 - bw, h2:= h1 - bw
WinSet, Region, 0-0 %w1%-0 %w1%-%h1% 0-%h1% 0-0 %bw%-%bw% %w2%-%bw% %w2%-%h2% %bw%-%h2% %bw%-%bw%
If FirstCall[n].1 {
Gui % n ": -Caption +AlwaysOnTop +ToolWindow -DPIScale +HWNDhwnd +e0x8000088"
Gui % n ": Color", % cl
FirstCall[n].1:= 0
} Gui % n ": Show", NA x%x1% y%y1% w%w1% h%h1% ; performs better then WinMove over some controls
}