Solved

SendInput - how to ?

Posted on 2003-10-31
5
1,623 Views
Last Modified: 2007-12-19
I want to use the SendInput function to simulate a keystroke ( in this case the key is "1"  normal, not the pad ). Well... some ppl will say "use the keyb_event" but i want to know how to use SendInput on Delphi ! :) and.. this is que question. How to simulate a keypress using the SendInput  function ? Please, i really need to know all steps including the KEYBDINPUT and INPUT members of SendInput.
0
Comment
Question by:furmiga
  • 3
5 Comments
 
LVL 33

Accepted Solution

by:
Slick812 earned 200 total points
ID: 9662089
hello furmiga, you might try this code, You will need to set the TInput "type" to INPUT_KEYBOARD for keyboard, and you will not ususually not need to have any Scan code.


procedure TForm1.sbut_SendInputClick(Sender: TObject);
var
Input1: TInput;
begin
Input1.Itype := INPUT_KEYBOARD;
Input1.ki.wVk := $31; // $31 is the VK_1
Input1.ki.wScan := 0;
Input1.ki.dwFlags := 0;
Input1.ki.time := 0;
Input1.ki.dwExtraInfo := 0;
if SendInput(1, Input1, SizeOf(Input1)) = 0 then
  begin
  ShowMessage('Input event was Blocked');
  Exit
  end;
Input1.ki.dwFlags := KEYEVENTF_KEYUP;
SendInput(1, Input1, SizeOf(Input1));
end;
0
 
LVL 11

Expert Comment

by:robert_marquardt
ID: 9662117
SendInput is about the same as keybd_event.
It only allows to send a sequence uninterupted.
0
 
LVL 7

Author Comment

by:furmiga
ID: 9662130
Okie Slick812 u really solved my problem. Now i can use this ....... function :)

Now... talking about dwflags y i cant use KEYEVENTF_SCANCODE ? I mean, i need this flag cuz there is no other way to send a command to a DXInput app. DirectInput only accept Scan code eventes.... i sow a few C# or C++ apps that uses KEYEVENTF_SCANCODE... Is there anything i can do for the KEYEVENTF_SCANCODE works on Delphi's apps ?

oh btw i am justing keeping this Article oppened cuz i really need this awser :) u already got the points with A grade :) i ll close this topic i a few hours but.... if you or anyone here answer my question i ll be glad :)


Thx man.
0
 
LVL 33

Expert Comment

by:Slick812
ID: 9663689
to get a scan code. . . you could get the  scan code from a WM_KEYDOWN or WM_KEYUP message in the 3 byte of the lParam for a certain key. . I will have to look at some of my references, to see what I can find
0
 
LVL 33

Expert Comment

by:Slick812
ID: 9663769
The scan code is Device Dependent, so different Keyboards will have different scan codes, however, by now there seem to be some "Standard" for the scan codes and certain keys on all keyboards, , , by that may not be the case for all (particulrly NON-English keyboards). . . anyway the scan code for my keyboard "1" charater is 2,  for "2" is 3, , for character "3" is 4, for "4" is 5, , ect. . .
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question