-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathtimer.py
More file actions
29 lines (27 loc) · 846 Bytes
/
Copy pathtimer.py
File metadata and controls
29 lines (27 loc) · 846 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# -*- coding:utf-8 -*-
from ctypes import (
c_void_p,
windll,
WINFUNCTYPE
)
from ctypes.wintypes import (
DWORD,
HWND,
UINT
)
from .method import method
user32=windll.user32
class Timer:
def __init__(self):
self.timer_func_dict={}
def setTimer(self,hwnd,nid,dwTime,is_timer_one=True):
self.is_timer_one=is_timer_one
return user32.SetTimer (hwnd,nid, dwTime, self._timerCallBack)
@method(WINFUNCTYPE(c_void_p,HWND,c_void_p,UINT,DWORD))
def _timerCallBack(self,hwnd,msg,nid,dwTime):
if hasattr(self,'timerCallBack'):
if self.is_timer_one:
self.timerCallBack(hwnd=hwnd,msg=msg,nid=nid,dwTime=dwTime)
user32.KillTimer(hwnd,nid)
return 0
return self.timerCallBack(hwnd=hwnd,msg=msg,nid=nid,dwTime=dwTime)