| View previous topic :: View next topic |
| Author |
Message |
marty Professional Member


Joined: 10 May 2001 Posts: 789
|
Posted: Mon Jan 17, 2005 6:08 pm Post subject: Problem using the command GetAsyncKeyState from WinAPI |
|
|
Hi,
The code below is suppose to log every number pressed on the keyboard and puts in the list.
But the problem is that it is really slow to capture the numbers, even if I type slowly or in a faster way...
Any help would be appreciated.
Thank you.
| Code: | DIALOG CREATE,Test,-1,0,478,300
DIALOG ADD,list,EDIT1,39,33,416,218,EDIT1,,multi
DIALOG SHOW
LOADLIB USER32
:EVENTLOOP
WAIT EVENT,"0.01"
%E = @event()
IF %E
GOTO %E
END
GOTO EVENTLOOP
:TIMER
%%ALT = 0
%%ALT2 = 0
%%ALT3 = 0
%%ALT4 = 0
%%ALT5 = 0
%%ALT6 = 0
%%ALT7 = 0
%%ALT8 = 0
%%ALT9 = 0
%%ALT0 = @lib(user32,GetAsyncKeyState,int:,$30)
%%ALT1 = @lib(user32,GetAsyncKeyState,int:,$31)
%%ALT2 = @lib(user32,GetAsyncKeyState,int:,$32)
%%ALT3 = @lib(user32,GetAsyncKeyState,int:,$33)
%%ALT4 = @lib(user32,GetAsyncKeyState,int:,$34)
%%ALT5 = @lib(user32,GetAsyncKeyState,int:,$35)
%%ALT6 = @lib(user32,GetAsyncKeyState,int:,$36)
%%ALT7 = @lib(user32,GetAsyncKeyState,int:,$37)
%%ALT8 = @lib(user32,GetAsyncKeyState,int:,$38)
%%ALT9 = @lib(user32,GetAsyncKeyState,int:,$39)
rem info %%alt
if @equal(%%alt0,1)
rem info Yup!
list insert,edit1,0
end
if @equal(%%alt1,1)
rem info Yup!
list insert,edit1,1
end
if @equal(%%alt2,1)
rem info Yup!
list insert,edit1,2
end
if @equal(%%alt3,1)
rem info Yup!
list insert,edit1,3
end
if @equal(%%alt4,1)
rem info Yup!
list insert,edit1,4
end
if @equal(%%alt5,1)
rem info Yup!
list insert,edit1,5
end
if @equal(%%alt6,1)
rem info Yup!
list insert,edit1,6
end
if @equal(%%alt7,1)
rem info Yup!
list insert,edit1,7
end
if @equal(%%alt8,1)
rem info Yup!
list insert,edit1,8
end
if @equal(%%alt9,1)
rem info Yup!
list insert,edit1,9
end
GOTO EVENTLOOP
:CLOSE
FREELIB USER32
EXIT |
|
|
| Back to top |
|
 |
Boo Valued Contributor


Joined: 31 Oct 2003 Posts: 599 Location: Gulf Breeze, Florida USA
|
Posted: Mon Jan 17, 2005 7:02 pm Post subject: |
|
|
Hi Marty,
How about something like this?
Cheers,
- Boo
| Code: |
DIALOG CREATE,Test,-1,0,478,300
DIALOG ADD,list,EDIT1,39,33,416,218,EDIT1,,multi
DIALOG SHOW
LOADLIB USER32
:EVENTLOOP
WAIT EVENT,".1"
%E = @event()
IF %E
GOTO %E
END
GOTO EVENTLOOP
:TIMER
%%ALT = 0
%%ALT2 = 0
%%ALT3 = 0
%%ALT4 = 0
%%ALT5 = 0
%%ALT6 = 0
%%ALT7 = 0
%%ALT8 = 0
%%ALT9 = 0
%%ALT0 = @lib(user32,GetAsyncKeyState,int:,$30)
%%ALT1 = @lib(user32,GetAsyncKeyState,int:,$31)
%%ALT2 = @lib(user32,GetAsyncKeyState,int:,$32)
%%ALT3 = @lib(user32,GetAsyncKeyState,int:,$33)
%%ALT4 = @lib(user32,GetAsyncKeyState,int:,$34)
%%ALT5 = @lib(user32,GetAsyncKeyState,int:,$35)
%%ALT6 = @lib(user32,GetAsyncKeyState,int:,$36)
%%ALT7 = @lib(user32,GetAsyncKeyState,int:,$37)
%%ALT8 = @lib(user32,GetAsyncKeyState,int:,$3
%%ALT9 = @lib(user32,GetAsyncKeyState,int:,$39)
rem info %%alt
if @not(@equal(%%alt0,0))
rem info Yup!
list insert,edit1,Key: 0
end
if @not(@equal(%%alt1,0))
rem info Yup!
list insert,edit1,Key: 1
end
if @not(@equal(%%alt2,0))
rem info Yup!
list insert,edit1,Key: 2
end
if @not(@equal(%%alt3,0))
rem info Yup!
list insert,edit1,Key: 3
end
if @not(@equal(%%alt4,0))
rem info Yup!
list insert,edit1,Key: 4
end
if @not(@equal(%%alt5,0))
rem info Yup!
list insert,edit1,Key: 5
end
if @not(@equal(%%alt6,0))
rem info Yup!
list insert,edit1,Key: 6
end
if @not(@equal(%%alt7,0))
rem info Yup!
list insert,edit1,Key: 7
end
if @not(@equal(%%alt8,0))
rem info Yup!
list insert,edit1,Key: 8
end
if @not(@equal(%%alt9,0))
rem info Yup!
list insert,edit1,Key: 9
end
GOTO EVENTLOOP
:CLOSE
FREELIB USER32
EXIT
|
|
|
| Back to top |
|
 |
marty Professional Member


Joined: 10 May 2001 Posts: 789
|
Posted: Mon Jan 17, 2005 7:09 pm Post subject: |
|
|
Thanks Boo!!!
Works like a charm...
 |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|