Python ctypes.wintypes.MSG Examples

The following are 14 code examples for showing how to use ctypes.wintypes.MSG(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.

You may check out the related API usage on the sidebar.

You may also want to check out all available functions/classes of the module ctypes.wintypes , or try the search function .

Example 1
Project: leaguedirector   Author: RiotGames   File: bindings.py    License: Apache License 2.0 5 votes vote down vote up
def run_windows(self):
        from ctypes.wintypes import DWORD, WPARAM, LPARAM, MSG

        class KBDLLHOOKSTRUCT(Structure):
            _fields_ = [
                ("vk_code", DWORD),
                ("scan_code", DWORD),
                ("flags", DWORD),
                ("time", c_int),
                ("dwExtraInfo", POINTER(DWORD))
            ]

        def callback(nCode, wParam, lParam):
            pid = c_ulong()
            windll.user32.GetWindowThreadProcessId(windll.user32.GetForegroundWindow(), byref(pid))
            if pid.value == self.pid:
                windll.user32.SendMessageA(self.window.winId(), wParam, lParam.contents.vk_code, 0)
            return windll.user32.CallNextHookEx(None, nCode, wParam, lParam)
 
        function = CFUNCTYPE(c_int, WPARAM, LPARAM, POINTER(KBDLLHOOKSTRUCT))(callback)
        hook = windll.user32.SetWindowsHookExW(13, function, windll.kernel32.GetModuleHandleW(None), 0)

        msg = POINTER(MSG)()
        while self.running:
            try:
                windll.user32.GetMessageW(msg, 0, 0, 0)
                windll.user32.TranslateMessage(msg)
                windll.user32.DispatchMessageA(msg)
            except: pass

        windll.user32.UnhookWindowsHookEx(hook) 
Example 2
Project: gdog   Author: maldevel   File: client.py    License: GNU General Public License v3.0 5 votes vote down vote up
def startKeyLog(self):                                                                
        msg = MSG()
        ctypes.windll.user32.GetMessageA(ctypes.byref(msg),0,0,0) 
Example 3
Project: gcat   Author: byt3bl33d3r   File: implant.py    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
def startKeyLog(self):                                                                
         msg = MSG()
         ctypes.windll.user32.GetMessageA(ctypes.byref(msg),0,0,0) 
Example 4
Project: sneakysnek   Author: SerpentAI   File: windows_recorder.py    License: MIT License 5 votes vote down vote up
def listen(self):
        while True:
            message = wintypes.MSG()
            message_pointer = ctypes.byref(message)

            if GetMessage(message_pointer, None, 0, 0) <= 0 or message.message == 0x0401:
                break 
Example 5
Project: NoobSec-Toolkit   Author: krintoxi   File: keylogger.py    License: GNU General Public License v2.0 5 votes vote down vote up
def run(self):
		if self.install_hook():
			print "keylogger installed"
		else:
			raise RuntimeError("couldn't install keylogger")
		msg = MSG()
		user32.GetMessageA(byref(msg),0,0,0)
		while not self.stopped:
			time.sleep(1)
		self.uninstall_hook() 
Example 6
Project: NoobSec-Toolkit   Author: krintoxi   File: mouselogger.py    License: GNU General Public License v2.0 5 votes vote down vote up
def run(self):
		if self.install_hook():
			print "mouselogger installed"
		else:
			raise RuntimeError("couldn't install mouselogger")
		msg = MSG()
		user32.GetMessageA(byref(msg),0,0,0)
		while not self.stopped:
			time.sleep(1)
		self.uninstall_hook() 
Example 7
Project: NoobSec-Toolkit   Author: krintoxi   File: keylogger.py    License: GNU General Public License v2.0 5 votes vote down vote up
def run(self):
		if self.install_hook():
			print "keylogger installed"
		else:
			raise RuntimeError("couldn't install keylogger")
		msg = MSG()
		user32.GetMessageA(byref(msg),0,0,0)
		while not self.stopped:
			time.sleep(1)
		self.uninstall_hook() 
Example 8
Project: NoobSec-Toolkit   Author: krintoxi   File: mouselogger.py    License: GNU General Public License v2.0 5 votes vote down vote up
def run(self):
		if self.install_hook():
			print "mouselogger installed"
		else:
			raise RuntimeError("couldn't install mouselogger")
		msg = MSG()
		user32.GetMessageA(byref(msg),0,0,0)
		while not self.stopped:
			time.sleep(1)
		self.uninstall_hook() 
Example 9
Project: pymt5   Author: devcartel   File: ddeclient.py    License: MIT License 5 votes vote down vote up
def WinMSGLoop():
    """Run the main windows message loop."""
    LPMSG = POINTER(MSG)
    LRESULT = c_ulong
    GetMessage = get_winfunc("user32", "GetMessageW", BOOL, (LPMSG, HWND, UINT, UINT))
    TranslateMessage = get_winfunc("user32", "TranslateMessage", BOOL, (LPMSG,))
    # restype = LRESULT
    DispatchMessage = get_winfunc("user32", "DispatchMessageW", LRESULT, (LPMSG,))

    msg = MSG()
    lpmsg = byref(msg)
    while GetMessage(lpmsg, HWND(), 0, 0) > 0:
        TranslateMessage(lpmsg)
        DispatchMessage(lpmsg) 
Example 10
Project: ATX   Author: NetEaseGame   File: tkinput.py    License: Apache License 2.0 5 votes vote down vote up
def handle_hotkey(root, callback):
        msg = wintypes.MSG()
        if windll.user32.GetMessageA(byref(msg), None, 0, 0) != 0:
            if msg.message == win32con.WM_HOTKEY:
                if msg.wParam == 1:
                    print 'Hotkey triggered!'
                    callback()
        windll.user32.TranslateMessage(byref(msg))
        windll.user32.DispatchMessageA(byref(msg))
        root.after(1, handle_hotkey, root, callback)

    # hotkey map refs: https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx
    # not yet used here. 
Example 11
Project: canisrufus   Author: maldevel   File: client.py    License: GNU General Public License v3.0 5 votes vote down vote up
def startKeyLog(self):                                                                
        msg = MSG()
        ctypes.windll.user32.GetMessageA(ctypes.byref(msg),0,0,0) 
Example 12
Project: EventGhost   Author: EventGhost   File: dde.py    License: GNU General Public License v2.0 5 votes vote down vote up
def WinMSGLoop():
    """Run the main windows message loop."""
    from ctypes import POINTER, byref, c_ulong
    from ctypes.wintypes import BOOL, HWND, MSG, UINT

    LPMSG = POINTER(MSG)
    LRESULT = c_ulong
    GetMessage = get_winfunc(
        "user32",
        "GetMessageW",
        BOOL,
        (LPMSG, HWND, UINT, UINT)
    )
    TranslateMessage = get_winfunc(
        "user32",
        "TranslateMessage",
        BOOL,
        (LPMSG,)
    )
    # restype = LRESULT
    DispatchMessage = get_winfunc(
        "user32",
        "DispatchMessageW",
        LRESULT,
        (LPMSG,)
    )

    msg = MSG()
    lpmsg = byref(msg)
    while GetMessage(lpmsg, HWND(), 0, 0) > 0:
        TranslateMessage(lpmsg)
        DispatchMessage(lpmsg) 
Example 13
Project: backdoorme   Author: Kkevsterrr   File: keylogger.py    License: MIT License 5 votes vote down vote up
def run(self):
		if self.install_hook():
			print "keylogger installed"
		else:
			raise RuntimeError("couldn't install keylogger")
		msg = MSG()
		user32.GetMessageA(byref(msg),0,0,0)
		while not self.stopped:
			time.sleep(1)
		self.uninstall_hook() 
Example 14
Project: backdoorme   Author: Kkevsterrr   File: mouselogger.py    License: MIT License 5 votes vote down vote up
def run(self):
		if self.install_hook():
			print "mouselogger installed"
		else:
			raise RuntimeError("couldn't install mouselogger")
		msg = MSG()
		user32.GetMessageA(byref(msg),0,0,0)
		while not self.stopped:
			time.sleep(1)
		self.uninstall_hook()