Page 1 of 1

Mouse is on Position and give a Key

Posted: Sat Dec 21, 2019 7:24 am
by Veteran66
Hi all

my other try,
Mouse is on Position give a Number Pad 5

Mouse is in Position 920 < x < 960 and 520 < y < 560 work fine
but it give no Key.NumberPad5 out
how i can do this?

Code: Select all

class POINT(Structure):
    _fields_ = [("x", c_long), ("y", c_long)]

def queryMousePosition():
    pt = POINT()
    windll.user32.GetCursorPos(byref(pt))
    return { "x": pt.x, "y": pt.y}

pos = queryMousePosition()
x = pos["x"]
y = pos["y"]
diagnostics.watch("x:" + str(x) + ", y:" + str(y))



if  920 < x < 960 and 520 < y < 560:

   windll.user32.keyboard.setKey(Key.NumberPad5)

Re: Mouse is on Position and give a Key

Posted: Sat Dec 21, 2019 7:36 am
by Veteran66
ok i find it :)

Code: Select all

class POINT(Structure):
    _fields_ = [("x", c_long), ("y", c_long)]

def queryMousePosition():
    pt = POINT()
    windll.user32.GetCursorPos(byref(pt))
    return { "x": pt.x, "y": pt.y}

pos = queryMousePosition()
x = pos["x"]
y = pos["y"]
diagnostics.watch("x:" + str(x) + ", y:" + str(y))



if  900 < x < 980 and 500 < y < 580:
   if inside == False:
      inside = True
      keyboard.setPressed(Key.NumberPad5)
else:
   inside = False

Re: Mouse is on Position and give a Key

Posted: Thu Jan 02, 2020 12:55 am
by Canescj
Can I get that full script, I've been trying to figure something like this out for a long time