Code: Select all
Global Color
IniRead, Color, Settings.ini, Settings, Color
IniRead, x1, Settings.ini, Settings, SetWindowArea-x1
IniRead, x2, Settings.ini, Settings, SetWindowArea-x2
IniRead, y1, Settings.ini, Settings, SetWindowArea-y1
IniRead, y2, Settings.ini, Settings, SetWindowArea-y2
Gui, Color, %Color%
CoordMode, ToolTip, Screen
CoordMode, Pixel, Screen
CoordMode, Mouse, Screen
CoordMode, Caret, Screen
CoordMode, Mouse, Screen
CoordMode, Menu, Screen
Gui,Add,Button,x5 y8 w150 h23 gButtonRealTime,Set Color Detection
Gui,Add,Button,x5 y75 w150 h23 gSetWindowArea,Select Window Area
Gui,Add,Button,x5 y125 w150 h23 gStartDetection,Start
Gui,Add,Button,x5 y150 w150 h23 gStopBreak,Stop
Gui,Add,Edit, x5 y35 w150 h21 vColor,%Color%
Gui,Show,w160 h175,Alert
return
StartDetection:
CoordMode, ToolTip, Screen
CoordMode, Pixel, Screen
CoordMode, Mouse, Screen
CoordMode, Caret, Screen
CoordMode, Mouse, Screen
CoordMode, Menu, Screen
Gui, Submit, NoHide
IniWrite, %Color%, Settings.ini, Settings, Color
SetTitleMatchMode, 2
SplashImage = small.png
SoundDelayer = 0
SoundDelayer2 = 0
stopbreak=0
IniRead, x1, Settings.ini, Settings, SetWindowArea-x1
IniRead, x2, Settings.ini, Settings, SetWindowArea-x2
IniRead, y1, Settings.ini, Settings, SetWindowArea-y1
IniRead, y2, Settings.ini, Settings, SetWindowArea-y2
r := 3
Loop {
{
Sleep 3500
0xColor:= "0x" . Color
PixelSearch, Outx, Outy, %x1%, %y1%, %x2%, %y2%,%0xColor%,20, fast
if (ErrorLevel=0) {
if (SoundDelayer < 5) {
SoundPlay, sound.wav
SoundDelayer += 1
}
SplashImageGUI(SplashImage, "Center", "Center", 500, true)
}
else if (SoundDelayer>0) {
SoundDelayer = 0
}
}
if(stopbreak=1) {
break
}
}
stopbreak=0
return
SetWindowArea:
LetUserSelectRect(x1, y1, x2, y2)
IniWrite, %x1%, Settings.ini, Settings, SetWindowArea-x1
IniWrite, %x2%, Settings.ini, Settings, SetWindowArea-x2
IniWrite, %y1%, Settings.ini, Settings, SetWindowArea-y1
IniWrite, %y2%, Settings.ini, Settings, SetWindowArea-y2
CoordMode, ToolTip, Screen
CoordMode, Pixel, Screen
CoordMode, Mouse, Screen
CoordMode, Caret, Screen
CoordMode, Menu, Screen
return
SplashImageGUI(Picture, X, Y, Duration, Transparent = false)
{
Gui, XPT99:Margin , 0, 0
Gui, XPT99:Add, Picture,, %Picture%
Gui, XPT99:Color, ECE9D8
Gui, XPT99:+LastFound -Caption +AlwaysOnTop +ToolWindow -Border
SysGet, Mon2, MonitorWorkArea, 2
If (Mon2Left) {
Mon2X:=((Mon2Left+Mon2Right)/2)-316
Mon2Y:=((Mon2Top+Mon2Bottom)/2)-157
Gui, XPT100:Margin , 0, 0
Gui, XPT100:Add, Picture,, %Picture%
Gui, XPT100:Color, ECE9D8
Gui, XPT100:+LastFound -Caption +AlwaysOnTop +ToolWindow -Border
}
If Transparent
{
Winset, TransColor, ECE9D8
}
Gui, XPT99:Show, x%X% y%Y% NoActivate
If (Mon2Left) {
Gui, XPT100:Show, x%Mon2X% y%Mon2Y% NoActivate
}
SetTimer, DestroySplashGUI, -%Duration%
return
DestroySplashGUI:
Gui, XPT99:Destroy
Gui, XPT100:Destroy
return
}
ButtonRealTime:
RealTimeIsRunning = 1 ;stop HexEditBox label glabel from running when ControlSetText is executed
stopbreak = 0
Loop
{
MouseGetPos , xpos, ypos, WinTitle1, ControlID,
PixelGetColor , color, %xpos%, %ypos%, rgb
StringSplit,Digit,Color
ControlColor := (Digit1 Digit2 Digit7 Digit8 Digit5 Digit6 Digit3 Digit4)
if ( Color1 <> Color and WinTitle1 <> WinTitle2 )
{
StringTrimLeft,Color,Color,2
controlsettext, edit4, %Color%
Gui, Color, %Color%
Guicontrol,Text,Color,%Color%
SetTimer, Mousetooltip2, 10
loop 4
Color1 = %Color%
}
if stopbreak = 1
{
RealTimeIsRunning = 0
SetTimer, Mousetooltip2, Off
ToolTip
break
}
}
IniWrite, %Color%, Settings.ini, Settings, Color
stopbreak = 0
Return
Control_Colors(wParam, lParam, Msg, Hwnd) {
Static Controls := {}
If (lParam = "Set") {
If !(CtlHwnd := wParam + 0)
GuiControlGet, CtlHwnd, Hwnd, %wParam%
If !(CtlHwnd + 0)
Return False
Controls[CtlHwnd, "CBG"] := Msg + 0
Controls[CtlHwnd, "CTX"] := Hwnd + 0
Return True
}
; Critical
If (Msg = 0x0133 Or Msg = 0x0134 Or Msg = 0x0138) {
If Controls.HasKey(lParam) {
If (Controls[lParam].CTX >= 0)
DllCall("Gdi32.dll\SetTextColor", "Ptr", wParam, "UInt", Controls[lParam].CTX)
DllCall("Gdi32.dll\SetBkColor", "Ptr", wParam, "UInt", Controls[lParam].CBG)
Return DllCall("Gdi32.dll\CreateSolidBrush", "UInt", Controls[lParam].CBG)
}
}
}
^e::
stopbreak=1
return
StopBreak:
stopbreak=1
return
LetUserSelectRect(ByRef X1, ByRef Y1, ByRef X2, ByRef Y2)
{
SetTimer, Mousetooltip, 10
static r := 3
; Create the "selection rectangle" GUIs (one for each edge).
Loop 4 {
GuiNumber=%A_Index%
GuiNumber+=1
Gui, %GuiNumber%: -Caption +ToolWindow +AlwaysOnTop
Gui, %GuiNumber%: Color, Red
}
; Disable LButton.
Hotkey, *LButton, lusr_return, On
; Wait for user to press LButton.
KeyWait, LButton, D
; Get initial coordinates.
MouseGetPos, xorigin, yorigin
; Set timer for updating the selection rectangle.
SetTimer, lusr_update, 10
; Wait for user to release LButton.
KeyWait, LButton
; Re-enable LButton.
Hotkey, *LButton, Off
; Disable timer.
SetTimer, lusr_update, Off
; Destroy "selection rectangle" GUIs.
Gui, 2: Destroy
Gui, 3: Destroy
Gui, 4: Destroy
Gui, 5: Destroy
SetTimer, Mousetooltip, Off
tooltip,,
return
Mousetooltip:
MouseGetPos, x, y
tooltip, Click and drag to select area, (x + 20), (y + 20), 1
return
Mousetooltip2:
MouseGetPos, x, y
tooltip, Press CTRL E to select a color, (x + 20), (y + 20), 1
return
lusr_update:
CoordMode, Mouse, Screen
MouseGetPos, x, y
if (x = xlast && y = ylast)
; Mouse hasn't moved so there's nothing to do.
return
if (x < xorigin)
x1 := x, x2 := xorigin
else x2 := x, x1 := xorigin
if (y < yorigin)
y1 := y, y2 := yorigin
else y2 := y, y1 := yorigin
; Update the "selection rectangle".
Gui, 2:Show, % "NA X" x1 " Y" y1 " W" x2-x1 " H" r
Gui, 3:Show, % "NA X" x1 " Y" y2-r " W" x2-x1 " H" r
Gui, 4:Show, % "NA X" x1 " Y" y1 " W" r " H" y2-y1
Gui, 5:Show, % "NA X" x2-r " Y" y1 " W" r " H" y2-y1
lusr_return:
return
}