i can send keyboards inputs to notepad using this code
import win32gui, win32ui, win32con
def main():
window_name = "scriptkopya.txt - Not Defteri"
hwnd = win32gui.FindWindow(None, window_name)
hwnd = get_inner_windows(hwnd)['Edit']
win = win32ui.CreateWindowFromHandle(hwnd)
win.SendMessage(win32con.WM_CHAR, ord('A'), 0)
def list_window_names():
def winEnumHandler(hwnd, ctx):
if win32gui.IsWindowVisible(hwnd):
print(hex(hwnd), '"' + win32gui.GetWindowText(hwnd) + '"')
win32gui.EnumWindows(winEnumHandler, None)
def get_inner_windows(whndl):
def callback(hwnd, hwnds):
if win32gui.IsWindowVisible(hwnd) and win32gui.IsWindowEnabled(hwnd):
hwnds[win32gui.GetClassName(hwnd)] = hwnd
return True
hwnds = {}
win32gui.EnumChildWindows(whndl, callback, hwnds)
return hwnds
main()
but when i try to change window_name and hwnd = get_inner_windows(hwnd)['Edit'] (btw im trying to change to "Minecraft 1.8.9" and hwnd = get_inner_windows(hwnd)['LWJGL']) it doesnt work. Edit means Notepad Class Name if you didnt know, i putted minecraft Class Name instead of Notepad Class Name. I get classnames by using Microsof Spy++. I tried to get it by using
EnumChildWindows code but it didnt work out.
if you want detailed code here it is
import win32gui, win32ui, win32con
def main():
window_name = "Minecraft 1.8.9"
hwnd = win32gui.FindWindow(None, window_name)
win = win32ui.CreateWindowFromHandle(hwnd)
get_inner_windows(hwnd)
def list_window_names():
def winEnumHandler(hwnd, ctx):
if win32gui.IsWindowVisible(hwnd):
print(hex(hwnd), '"' + win32gui.GetWindowText(hwnd) + '"')
win32gui.EnumWindows(winEnumHandler, None)
def get_inner_windows(whndl):
def callback(hwnd, hwnds):
if win32gui.IsWindowVisible(hwnd) and win32gui.IsWindowEnabled(hwnd):
hwnds[win32gui.GetClassName(hwnd)] = hwnd
return True
hwnds = {}
win32gui.EnumChildWindows(whndl, callback, hwnds)
print(hwnds)
main()
when i run this code my output is " {} "
so instead of using this i used Microsoft Spy++ and i found this classname " LWJGL " but as you can see it didnt workout too.
import win32gui, win32ui, win32con
def main():
window_name = "Minecraft 1.8.9"
hwnd = win32gui.FindWindow(None, window_name)
hwnd = get_inner_windows(hwnd)['LWJGL']
win = win32ui.CreateWindowFromHandle(hwnd)
win.SendMessage(win32con.WM_CHAR, ord('A'), 0)
def list_window_names():
def winEnumHandler(hwnd, ctx):
if win32gui.IsWindowVisible(hwnd):
print(hex(hwnd), '"' + win32gui.GetWindowText(hwnd) + '"')
win32gui.EnumWindows(winEnumHandler, None)
def get_inner_windows(whndl):
def callback(hwnd, hwnds):
if win32gui.IsWindowVisible(hwnd) and win32gui.IsWindowEnabled(hwnd):
hwnds[win32gui.GetClassName(hwnd)] = hwnd
return True
hwnds = {}
win32gui.EnumChildWindows(whndl, callback, hwnds)
return hwnds
main()
thats my final code i tried to change "Minecraft 1.8.9" to "javaw.exe" i dont get any error but i dont get any responds too.
btw im doing this tutorial https://www.youtube.com/watch?v=J3fatZ2OVIU&t=301s
What I have tried:
I tried to change "Minecraft 1.8.9" to "javaw.exe" but it didnt work out.