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


Joined: 10 May 2001 Posts: 789
|
Posted: Wed Feb 23, 2005 2:11 pm Post subject: VDSDLL 28 - Key capture question |
|
|
Hi,
I have been looking at the Keyboard example that comes with VDSDLL (version 2. and noticed it takes like 80% of the CPU.
Do you think there is a way to optimize this without loosing any key pressed?
If I had a pause it may miss some keys:
Here is the current demo script:
| Code: |
#define command,dll
#define function,dll
external @path(%0)vdsdll.dll,Public Freeware Key|90257236
DIALOG CREATE,Keyboard example,-1,0,380,270
DIALOG ADD,STYLE,STYLE2,Times New Roman,12
DIALOG ADD,STYLE,STYLE1,Wingdings,22
DIALOG ADD,BUTTON,UP,160,60,40,40,é,DEFAULT,STYLE1
DIALOG ADD,BUTTON,LEFT,210,10,40,40,ç,STYLE1
DIALOG ADD,BUTTON,DOWN,210,60,40,40,ê,STYLE1
DIALOG ADD,BUTTON,RIGHT,210,110,40,40,è,STYLE1
DIALOG ADD,BUTTON,INSERT,10,10,40,40,Ins,STYLE2
DIALOG ADD,BUTTON,HOME,10,60,40,40,Home,STYLE2
DIALOG ADD,BUTTON,PRIOR,10,110,40,40,Up,STYLE2
DIALOG ADD,BUTTON,DELETE,60,10,40,40,Del,STYLE2
DIALOG ADD,BUTTON,END,60,60,40,40,End,STYLE2
DIALOG ADD,BUTTON,NEXT,60,110,40,40,Down,STYLE2
DIALOG ADD,BUTTON,NUMPAD0,210,170,90,40,0,STYLE2
DIALOG ADD,BUTTON,NUMPAD1,160,170,40,40,1,STYLE2
DIALOG ADD,BUTTON,NUMPAD2,160,220,40,40,2,STYLE2
DIALOG ADD,BUTTON,NUMPAD3,160,270,40,40,3,STYLE2
DIALOG ADD,BUTTON,NUMPAD4,110,170,40,40,4,STYLE2
DIALOG ADD,BUTTON,NUMPAD5,110,220,40,40,5,STYLE2
DIALOG ADD,BUTTON,NUMPAD6,110,270,40,40,6,STYLE2
DIALOG ADD,BUTTON,NUMPAD7,60,170,40,40,7,STYLE2
DIALOG ADD,BUTTON,NUMPAD8,60,220,40,40,8,STYLE2
DIALOG ADD,BUTTON,NUMPAD9,60,270,40,40,9,STYLE2
DIALOG ADD,BUTTON,NUMLOCK,10,170,40,40,Num,STYLE2
DIALOG ADD,BUTTON,DIVIDE,10,220,40,40,/,STYLE2
DIALOG ADD,BUTTON,MULTIPLY,10,270,40,40,*,STYLE2
DIALOG ADD,BUTTON,SUBTRACT,10,320,40,40,-,STYLE2
DIALOG ADD,BUTTON,ADD,60,320,40,90,+,STYLE2
DIALOG ADD,BUTTON,RETURN,160,320,40,90,Enter,STYLE2
DIALOG ADD,BUTTON,DECIMAL,210,270,40,40,.,STYLE2
DIALOG ADD,TEXT,TEXT1,10,10,350,240,Press any key on the right side on the keyboard.,STYLE2
DIALOG SHOW
list create,1
list loadtext,1
"UP
"LEFT
"DOWN
"RIGHT
"NUMPAD0
"NUMPAD1
"NUMPAD2
"NUMPAD3
"NUMPAD4
"NUMPAD5
"NUMPAD6
"NUMPAD7
"NUMPAD8
"NUMPAD9
"NUMLOCK
"DIVIDE
"MULTIPLY
"SUBTRACT
"ADD
"RETURN
"DECIMAL
"DELETE
"END
"NEXT
"INSERT
"HOME
"PRIOR
:evloop
%A = @event()
if @equal(%A,CLOSE)
goto CLOSE
end
list seek,1,0
%B =
repeat
if @equal(@dll(keyboard,@item(1)),1)
%B = 1
dialog show,@next(1)
else
dialog hide,@next(1)
end
until @equal(@index(1),@count(1))
if @not(%B)
dialog show,TEXT1
else
dialog hide,TEXT1
end
goto evloop
:close |
Thanks.... |
|
| Back to top |
|
 |
Boo Valued Contributor


Joined: 31 Oct 2003 Posts: 599 Location: Gulf Breeze, Florida USA
|
Posted: Wed Feb 23, 2005 2:32 pm Post subject: |
|
|
Hi Marty,
How about using the Windows API instead of the DLL?
Cheers,
- Boo |
|
| Back to top |
|
 |
marty Professional Member


Joined: 10 May 2001 Posts: 789
|
Posted: Wed Feb 23, 2005 4:33 pm Post subject: |
|
|
I did but on some systems its not very accurate.. I tried on a Pentium 400mhz for example.
I am really looking for a solution that does not take the CPU. and works on most system., |
|
| Back to top |
|
 |
Boo Valued Contributor


Joined: 31 Oct 2003 Posts: 599 Location: Gulf Breeze, Florida USA
|
Posted: Wed Feb 23, 2005 7:20 pm Post subject: |
|
|
Hi Marty,
Just curious... How is it not very accurate? And on what systems/operating systems?
Thanks,
- Boo |
|
| Back to top |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Wed Feb 23, 2005 9:07 pm Post subject: |
|
|
Not sure how accurate the WAIT is on VDS 5, but
using a WAIT ".001" should reduce CPU usage to
nearly nothing.
Or ya can use the API "Sleep(1)".
Either one should be approx 1/1000 second, and I
doubt the user can type that fast.
Cheers, Mac  _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
 |
|
| Back to top |
|
 |
marty Professional Member


Joined: 10 May 2001 Posts: 789
|
Posted: Thu Feb 24, 2005 1:02 pm Post subject: |
|
|
Thanks mac and boo.
I added the Wait but its much too slow now...
Back to the drawing board  |
|
| Back to top |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Thu Feb 24, 2005 5:09 pm Post subject: |
|
|
What exactly are ya building? Might be another way to
get there from here...
Cheers, Mac  _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
 |
|
| Back to top |
|
 |
marty Professional Member


Joined: 10 May 2001 Posts: 789
|
Posted: Thu Feb 24, 2005 8:22 pm Post subject: |
|
|
I need a way to trap certain keys on the keyboard.
If you look at this thread, http://forum.vdsworld.com/viewtopic.php?t=3188
I tought I had it going, but to really catch what was typed I need to have a very short wait for the timer... Now if its too short the CPU usage rises and if its too slow, keys are missed.
And on some slower machines , Windows 98 PII 400, some keys are missed.
So I have no idea how to make this. I tried to make a delphi DLL, but that involves to implement a HOOK..
 |
|
| Back to top |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Thu Feb 24, 2005 10:46 pm Post subject: |
|
|
Actually a hook is prolly the only way you'll be 100% accurate
at catching keystrokes - each one passes thru the hook and
can't escape detection.
Otherwise there are too many variables - CPU speed, typematic
rates, number of apps the user has running, available resources,
etc.
An app using near 100% cpu usage certainly has a better chance
of catching them, but that's not really desirable either...
Cheers, Mac  _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
 |
|
| 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
|
|