Skip to content

Instantly share code, notes, and snippets.

@laerreal
Created October 26, 2021 16:19
Show Gist options
  • Save laerreal/87395aacb5bd83a61d434347f0476e72 to your computer and use it in GitHub Desktop.
Save laerreal/87395aacb5bd83a61d434347f0476e72 to your computer and use it in GitHub Desktop.
They Are Billions Send Alt Key
from six.moves.tkinter import (
Tk,
Checkbutton,
BooleanVar,
)
from time import (
sleep,
)
from win32api import (
PostMessage,
)
from win32con import (
WM_KEYDOWN,
VK_MENU,
)
from win32gui import (
FindWindow,
)
root = Tk()
root.geometry("200x30")
send = BooleanVar()
cb = Checkbutton(root,
text = "Send",
variable = send,
)
cb.pack()
targetHWND = None
def do_send():
global targetHWND
root.after(1000, do_send)
if not send.get():
return
if not targetHWND:
targetHWND = FindWindow(None, "They Are Billions")
if not targetHWND:
print("No window")
return
print("hwnd" + str(targetHWND))
# print("Sending")
try:
PostMessage(targetHWND, WM_KEYDOWN, VK_MENU, 0)
except BaseException as e:
print(e)
targetHWND = None
root.after_idle(do_send)
root.mainloop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment