Esempio n. 1
0
import wx, sys, ctypes
from util import ffi
from ctypes import sizeof, byref
from ctypes.wintypes import UINT, HWND, DWORD
from gui.native.win.winutil import WinStruct

ffi.cimport(user32=['FlashWindowEx', 'FlashWindow'])

FLASHW_STOP = 0
FLASHW_CAPTION = 0x00000001
FLASHW_TRAY = 0x00000002
FLASHW_ALL = FLASHW_CAPTION | FLASHW_TRAY
FLASHW_TIMER = 0x00000004  # Flash continuously, until the FLASHW_STOP flag is set.
FLASHW_TIMERNOFG = 0x0000000C  # Flash continuously until the window comes to the foreground.


class FLASHWINFO(WinStruct):
    _fields_ = [('cbSize', UINT), ('hwnd', HWND), ('dwFlags', DWORD),
                ('uCount', UINT), ('dwTimeout', DWORD)]


# failed import?
if not FlashWindowEx:  #@UndefinedVariable
    wx.TopLevelWindow.StopFlashing = lambda win: None
else:
    FLASHWINFOsize = sum(sizeof(zz) for zz in (UINT, HWND, DWORD, UINT, DWORD))
    assert FLASHWINFOsize == len(FLASHWINFO())

    tlw = wx.TopLevelWindow

    def StopFlashing(win):
Esempio n. 2
0
from util.ffi import cimport
from ctypes.wintypes import DWORD, HMODULE, MAX_PATH
from ctypes import byref, WinError, sizeof, create_unicode_buffer, Structure, c_ulong
import os

SIZE_T = c_ulong

cimport(Psapi = ['GetModuleBaseNameW', 'EnumProcesses', 'EnumProcessModules', 'GetModuleBaseNameW', 'GetProcessMemoryInfo', 'EmptyWorkingSet'],
        kernel32 = ['OpenProcess', 'SetProcessWorkingSetSize', 'CloseHandle', 'GetCurrentProcess', 'GetCurrentThread', 'SetThreadPriority'],
        user32 = ['GetGuiResources'])

N = 500
dword_array = DWORD * N
aProcesses = dword_array()
cBytes = DWORD()

# constants for OpenProcess
PROCESS_QUERY_INFORMATION = 0x400
PROCESS_VM_READ           = 0x10
PROCESS_SET_QUOTA         = 0x0100

OPEN_PROCESS_FLAGS = PROCESS_QUERY_INFORMATION | PROCESS_VM_READ

szProcessName = create_unicode_buffer(MAX_PATH)
hMod = HMODULE()
cBytesNeeded = DWORD()

class PROCESS_MEMORY_COUNTERS(Structure):
    _fields_ = [
        ("cb", DWORD),
        ("PageFaultCount", DWORD),
Esempio n. 3
0
import wx, sys, ctypes
from util import ffi
from ctypes import sizeof, byref
from ctypes.wintypes import UINT, HWND, DWORD
from gui.native.win.winutil import WinStruct

ffi.cimport(user32=["FlashWindowEx", "FlashWindow"])

FLASHW_STOP = 0
FLASHW_CAPTION = 0x00000001
FLASHW_TRAY = 0x00000002
FLASHW_ALL = FLASHW_CAPTION | FLASHW_TRAY
FLASHW_TIMER = 0x00000004  # Flash continuously, until the FLASHW_STOP flag is set.
FLASHW_TIMERNOFG = 0x0000000C  # Flash continuously until the window comes to the foreground.


class FLASHWINFO(WinStruct):
    _fields_ = [("cbSize", UINT), ("hwnd", HWND), ("dwFlags", DWORD), ("uCount", UINT), ("dwTimeout", DWORD)]


# failed import?
if not FlashWindowEx:  # @UndefinedVariable
    wx.TopLevelWindow.StopFlashing = lambda win: None
else:
    FLASHWINFOsize = sum(sizeof(zz) for zz in (UINT, HWND, DWORD, UINT, DWORD))
    assert FLASHWINFOsize == len(FLASHWINFO())

    tlw = wx.TopLevelWindow

    def StopFlashing(win):
        f = FLASHWINFO(cbSize=FLASHWINFOsize, hwnd=win.Handle, dwFlags=FLASHW_STOP)