#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#UseHook
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
BarrelTop = 319 ; black line where the yellow and red boundary is suppose to be in
; for a succesful pick attempt
PinX = 0
PinY = 0
PickLocY = 374
PickLocX = 827
color_red = 0xDE6060
color_yellow = 0xDABF5C
color_nearblack = 0x292929
hwnd = 0
hDC = 0
pix = 0
IfNotExist, %A_WorkingDir%\MOLockPick.ini
{
FileAppend,,%A_WorkingDir%\MOLockPick.ini
}
;----------------------------------------
;----------------------------------------
;----------------------------------------
Home::
IfWinActive, MortalGame
{
window := WinExist("A") ;// grab the hwnd of the active window
MouseGetPos, curX, curY
PinX = %curX%
MouseMove, 200, 200, 0, R
Sleep 200
MouseClick, Right,,,,,D
PixelGetColor, clr2, PinX, BarrelTop - 8, RGB slow
While (!CompareRGB(color_red, clr2))
{
MouseMove, -10, -20, 0, R
PixelGetColor, clr2, PinX, BarrelTop - 8, RGB Slow
}
MouseClick, Right,,,,,U
loop, 10000
{
PixelGetColor, clr1, PinX, BarrelTop - 3, RGB slow ; 317
PixelGetColor, clr2, PinX, BarrelTop - 1, RGB slow ; 317
if (CompareRGB(color_yellow, clr1))
{
if (CompareRGB(color_red, clr2))
{
MouseClick, Left
SoundBeep
break
} else {
break
}
}
}
Sleep 200
MouseMove, curX, curY
}
return
End::
IfWinActive, MortalGame
{
MouseGetPos, curX, curY
PinX = %curX%
MouseMove, 200, 200, 0, R
Sleep 200
MouseClick, Right,,,,,D
PixelGetColor, clr2, PinX, BarrelTop - 8, RGB
While (!CompareRGB(color_red, clr2))
{
MouseMove, -10, -20, 0, R
PixelGetColor, clr2, PinX, BarrelTop - 8, RGB
}
MouseClick, Right,,,,,U
loop, 10000
{
PixelGetColor, clr1, PinX, BarrelTop - 1, RGB ; 317
PixelGetColor, clr2, PinX, BarrelTop, RGB ; 317
if (CompareRGB(color_yellow, clr1))
{
if (CompareRGB(color_red, clr2))
{
MouseClick, Left
SoundBeep
break
} else {
break
}
}
}
Sleep 200
MouseMove, curX, curY
}
return
Insert::
IfWinActive, MortalGame
{
MouseGetPos, curX, curY
PinX = %curX%
MouseMove, 200, 200, 0, R
Sleep 200
MouseClick, Right,,,,,D
PixelGetColor, clr2, PinX, BarrelTop - 8, RGB
While (!CompareRGB(color_red, clr2))
{
MouseMove, -10, -20, 0, R
PixelGetColor, clr2, PinX, BarrelTop - 8, RGB
}
MouseClick, Right,,,,,U
loop, 10000
{
PixelGetColor, clr1, PinX, BarrelTop, RGB ; 317
PixelGetColor, clr2, PinX, BarrelTop + 1, RGB ; 317
if (CompareRGB(color_yellow, clr1))
{
if (CompareRGB(color_red, clr2))
{
MouseClick, Left
SoundBeep
break
} else {
break
}
}
}
Sleep 200
MouseMove, curX, curY
}
return
Delete::
ReloadScript()
return
ScrollLock::
IfWinActive, MortalGame
{
msgbox start
PickLocY = 374
PickLocX = 827
bottomRedY = 368
xCount = 500
PixelGetColor, cl1, xCount, BottomRedY, RGB
PixelGetColor, cl2, xCount, BottomRedY + 1, RGB
While (!(CompareRGB(color_red, cl1) && CompareRGB(color_nearblack, cl2)) AND %xCount% <= 850)
{
xCount := xCount + 1
PixelGetColor, cl1, xCount, BottomRedY, RGB
PixelGetColor, cl2, xCount, BottomRedY, RGB
}
msgbox %xCount%
MouseMove, xCount, bottomRedY
}
return
PgUp::
IfWinActive, MortalGame
{
MouseGetPos, curX, curY
PinX = %curX%
MouseMove, 200, 200, 0, R
Sleep 200
MouseClick, Right,,,,,D
PixelGetColor, clr2, PinX, BarrelTop - 8, RGB
While (!CompareRGB(color_red, clr2))
{
MouseMove, -10, -20, 0, R
PixelGetColor, clr2, PinX, BarrelTop - 8, RGB
}
MouseClick, Right,,,,,U
loop, 10000
{
PixelGetColor, clr1, PinX, BarrelTop + 1, RGB ; 317
PixelGetColor, clr2, PinX, BarrelTop + 2, RGB ; 317
if (CompareRGB(color_yellow, clr1))
{
if (CompareRGB(color_red, clr2))
{
MouseClick, Left
SoundBeep
break
} else {
break
}
}
}
Sleep 200
MouseMove, curX, curY
}
return
PgDn::
IfWinActive, MortalGame
{
MouseGetPos, curX, curY
PinX = %curX%
MouseMove, 200, 200, 0, R
Sleep 200
MouseClick, Right,,,,,D
PixelGetColor, clr2, PinX, BarrelTop - 8, RGB
While (!CompareRGB(color_red, clr2))
{
MouseMove, -10, -20, 0, R
PixelGetColor, clr2, PinX, BarrelTop - 8, RGB
}
MouseClick, Right,,,,,U
loop, 10000
{
PixelGetColor, clr1, PinX, BarrelTop + 2, RGB ; 317
PixelGetColor, clr2, PinX, BarrelTop + 3, RGB ; 317
if (CompareRGB(color_yellow, clr1))
{
if (CompareRGB(color_red, clr2))
{
MouseClick, Left
SoundBeep
break
} else {
break
}
}
}
Sleep 200
MouseMove, curX, curY
}
return
PrintScreen::
MouseGetPos, MX, MY
PixelGetColor, clr, MX-2, MY, RGB
MsgBox code: %clr%
return
;----------------------------------------
;----------------------------------------
;----------------------------------------
NextPin(){
send {WheelUp 1}
}
PreviousPin(){
send {WheelDown 1}
}
GetPixelColor(){
}
CompareRGB(c1, c2, vary=20) {
r1 := HexToDecimal(SubStr(c1, 3, 2))
g1 := HexToDecimal(SubStr(c1, 5, 2))
b1 := HexToDecimal(SubStr(c1, 7, 2))
r2 := HexToDecimal(SubStr(c2, 3, 2))
g2 := HexToDecimal(SubStr(c2, 5, 2))
b2 := HexToDecimal(SubStr(c2, 7, 2))
rdiff := Abs(r1 - r2)
gdiff := Abs(g1 - g2)
bdiff := Abs(b1 - b2)
return rdiff <= vary && gdiff <= vary && bdiff <= vary
}
hexToDecimal(str){
static _0:=0,_1:=1,_2:=2,_3:=3,_4:=4,_5:=5,_6:=6,_7:=7,_8:=8,_9:=9,_a:=10,_b:=11,_c:=12,_d:=13,_e:=14,_f:=15
str:=ltrim(str,"0x `t`n`r"), len := StrLen(str), ret:=0
Loop,Parse,str
ret += _%A_LoopField%*(16**(len-A_Index))
return ret
}
ReadIniValues(){
BarrelTop = 317
color_red = 0xDE6060
color_yellow = 0xDABF5C
IfEqual, BarrelTop, ERROR
{
IniWrite, % BarrelTop, %A_WorkingDir%\MOLockPick.ini, LOCS, BarrelTop
}
else
{
IniRead, BarrelTop, %A_WorkingDir%\MOLockPick.ini, LOCS, BarrelTop
}
}
ReloadScript(){
Reload
Sleep 1000 ; If successful, the reload will close this instance during the Sleep, so the line below will never be reached.
MsgBox, 4,, The script could not be reloaded. Exiting script!
IfMsgBox, Yes, ExitApp
return
}
FHex( int, pad=0 ) { ; Function by [VxE]. Formats an integer (decimals are truncated) as hex.
; "Pad" may be the minimum number of digits that should appear on the right of the "0x".
Static hx := "0123456789ABCDEF"
If !( 0 < int |= 0 )
Return !int ? "0x0" : "-" FHex( -int, pad )
s := 1 + Floor( Ln( int ) / Ln( 16 ) )
h := SubStr( "0x0000000000000000", 1, pad := pad < s ? s + 2 : pad < 16 ? pad + 2 : 18 )
u := A_IsUnicode = 1
Loop % s
NumPut( *( &hx + ( ( int & 15 ) << u ) ), h, pad - A_Index << u, "UChar" ), int >>= 4
Return h
}
DwmInit(){
hwnd := WinExist("A") ;// grab the hwnd of the active window
hDC := DllCall("user32.dll\GetDCEx", "UInt", hwnd, "UInt", 0, "UInt", 1|2)
msgbox hDC - %hDC%
return %hDC%
}
DwmDelete(){
DllCall("user32.dll\ReleaseDC", "UInt", hwnd, "UInt", hDC)
DllCall("gdi32.dll\DeleteDC", "UInt", hDC)
return
}
DwmGetPixel2(x, y, hDC){
pix := DllCall("gdi32.dll\GetPixel", "UInt", hDC, "Int", x, "Int", y, "UInt")
if (pix == 0)
pix = 1
pix := FHex(pix, 6)
return pix
}
DwmGetPixel(x, y){
pix := DllCall("gdi32.dll\GetPixel", "UInt", %hDC%, "Int", %x%, "Int", %y%, "UInt")
if (pix == 0)
pix = 1
pix := FHex(%pix%, 6)
return pix
}
f12::
hwnd := WinExist("A") ;// grab the hwnd of the active window
hDC := DllCall("user32.dll\GetDCEx", "UInt", hwnd, "UInt", 0, "UInt", 1|2)
MouseGetPos, MX, MY
color := DwmGetPixel2(MX, MY, hDC)
MsgBox, color is %color%
if (color = "0xEBE8EA")
{
;blah blah
}
DllCall("user32.dll\ReleaseDC", "UInt", hwnd, "UInt", hDC)
DllCall("gdi32.dll\DeleteDC", "UInt", hDC)
return
f11:: ; test hotkey
hwnd := WinExist("A") ;// grab the hwnd of the active window
hDC := DllCall("user32.dll\GetDCEx", "UInt", hwnd, "UInt", 0, "UInt", 1|2)
MouseGetPos, curX, curY
PinX = %curX%
MouseMove, 200, 200, 0, R
Sleep 200
MouseClick, Right,,,,,D
clr2 := DwmGetPixel2(PinX, BarrelTop - 8, hDC)
While (!CompareRGB(color_red, clr2))
{
Sleep 1
MouseMove, -5, -6, 0, R
clr2 := DwmGetPixel2(PinX, BarrelTop - 8, hDC)
}
MouseClick, Right,,,,,U
loop, 10000
{
clr1 := DwmGetPixel2(PinX, BarrelTop, hDC)
clr2 := DwmGetPixel2(PinX, BarrelTop + 1, hDC)
if (CompareRGB(color_yellow, clr1))
{
if (CompareRGB(color_red, clr2))
{
MouseClick, Left
break
} else {
break
}
}
}
Sleep 200
MouseMove, curX, curY
DllCall("user32.dll\ReleaseDC", "UInt", hwnd, "UInt", hDC)
DllCall("gdi32.dll\DeleteDC", "UInt", hDC)
return
F10::
MouseGetPos, curX, curY
hwnd := WinExist("A") ;// grab the hwnd of the active window
hDC := DllCall("user32.dll\GetDCEx", "UInt", hwnd, "UInt", 0, "UInt", 1|2)
SoundBeep
loop, 50
{
clr2 := DwmGetPixel2(curX, curY, hDC)
}
SoundBeep
msgbox %clr2%
DllCall("user32.dll\ReleaseDC", "UInt", hwnd, "UInt", hDC)
DllCall("gdi32.dll\DeleteDC", "UInt", hDC)
return
F9::
MouseGetPos, curX, curY
SoundBeep
loop, 50
{
PixelGetColor, clr1, %curX%, %curY%, RGB ; 317
}
SoundBeep
return