using windll you can call methods from (kernel32.dll and user32.dll aswell as other dlls that can be found
in your system32 folder)
2 other conventions also exist that allow you to call local dlls and OLE dlls(sadly i dont have any code for these 2)
my favorite example is as follows:
- Code: Select all
from ctypes import *
#msdn for what dll to use
self.SetWindowText = windll.user32.SetWindowTextA
self.FindWindow = windll.user32.FindWindowA
#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"))
you can test this code right now by opening a command prompt window
and then type title lol
this will change the command prompt title to "lol"
now run the following script and it should change the title to "Command Prompt "
this is a small example of the power of ctypes if you can imagine a program that uses the win32 api alot
you can recreate it in python even with the proper return value types
If i can find it I have also been able to create and register a win32 gui inside python
including the WindowsProcedure.