Solved

SendInput - how to ?

Posted on 2003-10-31
5
1,651 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 34

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 34

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 34

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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Suggested Courses
Course of the Month7 days, 1 hour left to enroll

623 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