mirror of
https://github.com/robotn/gohook.git
synced 2025-05-29 04:27:51 +08:00
Update: push the custom tm code
This commit is contained in:
parent
a8f8a8fb20
commit
c49f850b47
1
event.go
1
event.go
@ -71,7 +71,6 @@ func AddEvents(key string, arr ...string) bool {
|
||||
if l > 0 {
|
||||
for i := 0; i < l; i++ {
|
||||
ukey := Keycode[arr[i]]
|
||||
|
||||
if e.Kind == KeyHold && e.Keycode == ukey {
|
||||
k++
|
||||
}
|
||||
|
9
hook.go
9
hook.go
@ -234,10 +234,15 @@ func KeychartoRawcode(kc string) uint16 {
|
||||
|
||||
// Start adds global event hook to OS
|
||||
// returns event channel
|
||||
func Start() chan Event {
|
||||
func Start(tm ...int) chan Event {
|
||||
ev = make(chan Event, 1024)
|
||||
go C.start_ev()
|
||||
|
||||
tm1 := 50
|
||||
if len(tm) > 0 {
|
||||
tm1 = tm[0]
|
||||
}
|
||||
|
||||
asyncon = true
|
||||
go func() {
|
||||
for {
|
||||
@ -246,7 +251,7 @@ func Start() chan Event {
|
||||
}
|
||||
|
||||
C.pollEv()
|
||||
time.Sleep(time.Millisecond * 50)
|
||||
time.Sleep(time.Millisecond * time.Duration(tm1))
|
||||
//todo: find smallest time that does not destroy the cpu utilization
|
||||
}
|
||||
}()
|
||||
|
Loading…
x
Reference in New Issue
Block a user