Python - ctypes

From PeformIQ Upgrade
Revision as of 14:29, 9 November 2007 by 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...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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