Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pyautogui
- import win32api, win32con, win32gui, win32ui, win32service, os, time
- import wmi
- import ctypes, sys
- import time
- #Check for admin privileges
- def is_admin():
- try:
- return ctypes.windll.shell32.IsUserAnAdmin()
- except:
- return False
- def f_click(pycwnd):
- x=300
- y=300
- lParam = y <<15 | x
- pycwnd.SendMessage(win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,x,y,0,0), lParam);
- pycwnd.SendMessage(win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,x,y,0,0), lParam);
- def get_whndl():
- #whndl = win32gui.FindWindowEx(0, 0, None, 'ModernWarfare.exe')
- whndl = win32gui.FindWindowEx(0, 0, None, 'mspaint.exe')
- print("ModernWarfare.exe found\n")
- print (whndl)
- return whndl
- def make_pycwnd(hwnd):
- PyCWnd = win32ui.CreateWindowFromHandle(hwnd)
- print(PyCWnd, hwnd)
- return PyCWnd
- def send_input_hax(pycwnd, msg):
- f_click(pycwnd)
- for c in msg:
- if c == "\n":
- pycwnd.SendMessage(win32con.WM_KEYDOWN, win32con.VK_RETURN, 0)
- pycwnd.SendMessage(win32con.WM_KEYUP, win32con.VK_RETURN, 0)
- print("Enter Pressed")
- else:
- pycwnd.SendMessage(win32con.WM_CHAR, ord(c), 0)
- pycwnd.UpdateWindow()
- whndl = get_whndl()
- def callback(hwnd, hwnds):
- if win32gui.IsWindowVisible(hwnd) and win32gui.IsWindowEnabled(hwnd):
- hwnds[win32gui.GetClassName(hwnd)] = hwnd
- return True
- if is_admin():
- pass
- else:
- ctypes.windll.shell32.ShellExecuteW(None, "runas", sys.executable, " ".join(sys.argv), None, 1)
- print("Wating")
- time.sleep(5)
- print("Wait done!")
- hwnds = {}
- win32gui.EnumChildWindows(whndl, callback, hwnds)
- #whndl = hwnds['IW8']
- whndl = hwnds['MSPaintApp']
- pycwnd = make_pycwnd(whndl)
- msg = "It works !\n"
- send_input_hax(pycwnd,msg)
- ############################
- #Show current active windows
- ############################
- #print(hwnds)
- ##############################
- #Show current active processes
- ##############################
- #c = wmi.WMI ()
- #for process in c.Win32_Process ():
- # print (process.ProcessId, process.Name)
- print("\nDone")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement