Created
June 22, 2022 19:13
-
-
Save sin3point14/52a3404cbbbfcf51361351227a4e6099 to your computer and use it in GitHub Desktop.
Gives you the information about the process present under your cursor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# almost entirely based of https://stackoverflow.com/a/56175816 :p | |
from ctypes import windll, Structure, c_long, byref, create_string_buffer | |
import time | |
class POINT(Structure): | |
_fields_ = [("x", c_long)] | |
pt = None | |
while True: | |
#Get x coordinate of cursor | |
def queryCursorPosition1(): | |
global pt | |
pt = POINT() | |
windll.user32.GetCursorPos(byref(pt)) | |
return { "x": pt.x} | |
pos1 = queryCursorPosition1() | |
#Get x coordinate of cursor a few seconds later | |
time.sleep(1) | |
def queryCursorPosition2(): | |
global pt | |
pt = POINT() | |
windll.user32.GetCursorPos(byref(pt)) | |
return { "x": pt.x} | |
pos2 = queryCursorPosition2() | |
#Print movement 'detected' if x coord do not match past x coord | |
if pos1 != pos2: | |
print("Movement Detected") | |
print(pos1) | |
print(pos2) | |
print("---") | |
some_string = create_string_buffer(b' ' * 200) | |
handle = windll.user32.WindowFromPoint(pt) | |
print("Handle: ", handle) | |
windll.user32.GetWindowTextA(handle, byref(some_string), 200) | |
print(some_string.raw) | |
# windll.user32.WindowFromPoint(pt) | |
id = c_long(0) | |
print("Thread: ", windll.user32.GetWindowThreadProcessId(handle, byref(id))) | |
print("PID: ", id) | |
f= open("track.txt","w+") | |
f.write("X1: %s X2: %s" % (pos1, pos2)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment