Created
August 23, 2012 02:36
-
-
Save mouseroot/3431554 to your computer and use it in GitHub Desktop.
ctypes demo
This file contains 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
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