Skip to content

Instantly share code, notes, and snippets.

@mouseroot
Created August 23, 2012 02:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mouseroot/3431554 to your computer and use it in GitHub Desktop.
Save mouseroot/3431554 to your computer and use it in GitHub Desktop.
ctypes demo
from ctypes import *
class Win32api():
def __init__(self):
#msdn for what dll to use
self.SetWindowText = windll.user32.SetWindowTextA
self.FindWindow = windll.user32.FindWindowA
def String(self,s):
return c_char_p(s)
def Int(self,i):
return c_int(i)
def Long(self,l):
return c_long(l)
#small test open command prompt type title lol
test = Win32api()
#none in python is == NULL in C
ret = test.FindWindow(None,test.String("lol"))
#ret holds the window handle HWND(which is really a long/int)
test.SetWindowText(ret,test.String("Command Prompt :D"))
print("done")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment