I have a problem, regarding a game called OS-Scape: https://os-scape.com/
In the bottom-right corner part of screen and during game play there's an area within which one can find up to 4x6 items: 6 per row, 4 by columns.
I also made a script that does the folowing: if I press LButton and until I released it, it spams LButton.
If I press CTRL+LButton it does the same as the previous one except for the items which immediatly surrond the item (first at the left, the right, the top, the bottom, if any)
which was first cliked.
My question is: Is there any awy to avoid the need to use two hotkeys and use only one instead?
By the way, I already think about a solution that runs the subroutine associated with the LButton key combination or the CRTL+Lbutton one depending on whether or not the very item
itself was clicked or the grey area immediatly surronding it in order to avoid the need of two hotkeys. Unfortunately, it appears that the grey-black background of the area is not homogeneous...
use PixelGetColor the moment the hotkeys fires cannot provide any help...
Any ideas?
My Script:
Code: Select all
CoordMode, Mouse, Window
SetTitleMatchMode, 2
#NoEnv
Process, Priority,, H
#MaxHotkeysPerInterval 10000
#MaxThreadsPerHotkey, 10000
SetMouseDelay, -1
SetKeyDelay, 0
SetWinDelay, 0
SetControlDelay -1
ListLines, Off
centers := {rows: [ 225,260,295,330,370,400 ], colums: [ 580,622,667,710 ]}
#IfWinActive OS-Scape
$^LButton::
$LButton::
~LShift & LButton::
MouseGetPos, x, y
if (Between(550, 740, x) and Between(205, 460, y)) {
if !(A_ThisHotkey = "$^LButton") {
While (GetKeyState("LButton", "P")) {
if (GetKeyState("Ctrl")) {
continue
}
click
Sleep 15
}
} else {
calculateCenter(rcstart, ccstart)
While (GetKeyState("LButton", "P")) {
calculateCenter(rc, cc)
if (Between(34, 38, Abs(rcstart-rc)) or (Between(35, 45, Abs(ccstart-cc)))) {
continue
}
click
Sleep 15
}
}
} else send, {LButton}
return
#If
F10::Suspend, On
F7::Suspend, Off
Between(lowerBound, upperBound, var) {
If var between %lowerBound% and %upperBound%
return true
return false
}
calculateCenter(ByRef rcs:="", ByRef ccs:="") {
global
MouseGetPos, x, y
for index, center in centers.rows, o := []
o[ Abs(y-center) ] := center
rcs := o[o.minIndex()]
for index, center in centers.colums, o := []
o[ Abs(x-center) ] := center
ccs := o[o.minIndex()]
return true
}
all the items using MouseGetPos, if it is it execute statements depending one the value of A_ThisHotkey. In particuluar
if the hotkey is CTRL+LButton it calculate the center of the item beneath the mouse upon click using the calculateCenter function
and spams while subsequent calls of this function returns values that does not imply that the absolute distance (calculated by using Abs
function) is not the one that represent the area imediatly surronding teh item which was first clicked.
Thanks