Difference between revisions of "Python - ctypes"
Jump to navigation
Jump to search
PeterHarding (talk | contribs) (New page: = Examples = A scrap of sample code from a past SVT exercise implemented usiong Pyth and ctypes: <pre> #!/usr/bin/env python ## import ctypes from ctypes import * from ctypes.wintypes i...) |
PeterHarding (talk | contribs) |
||
Line 1: | Line 1: | ||
= Tutorial = | |||
Extracted from http://starship.python.net/crew/theller/ctypes/tutorial.html | |||
= Examples = | = Examples = | ||
Revision as of 14:53, 9 November 2007
Tutorial
Extracted from http://starship.python.net/crew/theller/ctypes/tutorial.html
Examples
A scrap of sample code from a past SVT exercise implemented usiong Pyth and ctypes:
#!/usr/bin/env python ## import ctypes from ctypes import * from ctypes.wintypes import * import win32con import sys import time #dll = windll.MouseHook # the dll is called hooksm.dll dll = cdll.hooksm #startfn = dll.setMyHook #stopfn = dll.clearMyHook # startfn() dll.search_msg = c_int (win32con.WM_SETTEXT) #windll.user32.DefWindowProcA(c_int(hwnd), c_int(message), c_int(wParam), c_int(lParam)) txt = "Analysis is complete for:" startfn = dll.hksmSetHook #startfn.argtypes = [c_ulong, c_int, c_uint, c_long, c_char_p, c_ulong] startfn ( # c_ulong(0x00000238), c_ulong(0x00000000), c_int (win32con.WM_SETTEXT), c_uint(win32con.NULL), c_char_p(txt), 0x00000000 ) startt = time.time() print startt #time.sleep(20) print "sync pre" syncfn = dll.Synchronize print "sync start" syncfn() print "sync stop" endt = time.time() print endt print endt - startt dll.hksmUnsetHook () #stopfn() #flog = dll.log