Jump to content
bosshunts

If PressKey

Recommended Posts

Is it possible to make this program do an action if I press a certain key?

For example. If I press 'a', can I make it push 1?

I tried to do this:

begin
if PressKey('a') then
PressKey(chr(49));
wait (1000);
end.

But I had the error "Type Mismatch"

Can anyone help?

Link to comment
Share on other sites

PressKey does what it says.. it presses a key. You need to check the STATE of the key.. So GetCurrentKeyState would work fine.

 

begin
 if GetCurrentKeyState('a') then
   PressKey(chr(49));

 Wait (1000);
end.

 

Also, the Wiki contains an example which is as clear as sunny day:

begin
 repeat
   Wait(500)
 until GetCurrentKeyState(VK_DOWN);
 WriteLn('Pressed down');
end.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
  • Create New...