Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

popup letters without pressing keyboard

Posted on 2001-08-25
9
Medium Priority
?
287 Views
Last Modified: 2010-04-06
how can i popup letters or like
pressing the enter key without pressing
keys in the keyboard.

 example: If im in the notepad(active window)
          after a few seconds a word will
          be written on it,(like it pops right away
          there!)
         
0
Comment
Question by:ryan_sabarre
9 Comments
 
LVL 1

Accepted Solution

by:
sundayboys earned 600 total points
ID: 6425855
procedure TForm1.Button1Click(Sender: TObject);
var
wnd:HWND;
i:integer;
s:string;
begin
 wnd:= FindWindow('notepad',nil);
 if wnd>0then
 begin
  wnd:=FindWindowEx(wnd,0,'Edit',nil);
  s:='Hello';
  For i:=0 to  Length(s) do
  SendMessage(wnd, WM_CHAR, Word(s[i]),0);
  PostMessage(wnd, WM_KEYDOWN, VK_RETURN,0);
  PostMessage(wnd, WM_KEYDOWN, VK_SPACE,0);
 end;
 end;
0
 

Author Comment

by:ryan_sabarre
ID: 6425869
Last Question
 if other kind of application, running
 and is the active window, how can i do
 this without going to my programming
 and pressing the onclick event button.
 like letting it happen for after a minute.
 
 
0
 

Author Comment

by:ryan_sabarre
ID: 6425874
What i mean i do not know the name of
the active window or application, and
i want to send some message on it
how can i do this? and is it possible
to display all application names found
who are running in my computer
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 6425907
Hello

 Use winsight32 that come with delphi, to show all the running processes

  to get the handle for active window you use
GetForegroundWindow

The GetForegroundWindow function returns a handle to the foreground window (the window with which the user is currently working). The system assigns a slightly higher priority to the thread that creates the foreground window than it does to other threads.
0
 

Author Comment

by:ryan_sabarre
ID: 6425915
You mean i will put it like this

procedure TForm1.Button1Click(Sender: TObject);
var
wnd:HWND;
i,r:integer;
s:string;
begin
wnd:=GetForegroundWindow;
//wnd:= FindWindow('Delphi 3',nil);
if wnd>0 then
begin
 wnd:=FindWindowEx(wnd,0,'Edit',nil);
 s:='Hello';
 For i:=0 to  Length(s) do
 SendMessage(wnd, WM_CHAR, Word(s[i]),0);
 PostMessage(wnd, WM_KEYDOWN, VK_RETURN,0);
 PostMessage(wnd, WM_KEYDOWN, VK_SPACE,0);
end
else
begin
 showmessage('not found');
end;
end;
0
 
LVL 1

Expert Comment

by:sundayboys
ID: 6425917
With the following routines it ist simply easy to kill a running process.First build a form with a TListview or Listbox with 3 columns and a button to refresh the running processes. The button must be binding with the efreshclick-procedure. The Listview shows the processes. With a Doubleclick on one of the processnames (binding with the doubleclick-propertie of Listvies) you can kill these running process. These is one of the simplest procedere to kill a running/hanging process under windows.

interface
uses
 {...,}TLHelp32 {important !}

// Global Variables, Globale Variablen

VAR aSnapshotHandle : THandle;
    aProcessEntry32 : TProcessEntry32;

procedure TFormMain.BtnRefreshClick(Sender: TObject);
var i       : integer;
    bLoop   : BOOL;
    NewItem : TListItem;
begin
  ListView.Items.Clear;
  aSnapshotHandle:=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
  aProcessEntry32.dwSize:=Sizeof(aProcessEntry32);
  bLoop:=Process32First(aSnapshotHandle,aProcessEntry32);
  while integer(bLoop) <>0 do
  begin
    NewItem:=ListView.Items.add;
    NewItem.Caption:=ExtractFileName(aProcessEntry32.szExeFile);
    NewItem.subItems.Add(IntToHex(aProcessEntry32.th32ProcessID,4));
    NewItem.subItems.Add(aProcessEntry32.szExeFile);
    ContinueLoop:=Process32Next(aSnapshotHandle,aProcessEntry32);
  end;
  CloseHandle(aSnapshotHandle);
end;

procedure TFormMain.ListViewDblClick(Sender: TObject);
var  Ret : BOOL;
     PrID : integer; //processidentifier
     Ph : THandle;  //processhandle
begin
  try
    with ListView do
    begin
      if MessageDlg('Do you want to Terminate "'+ItemFocused.Caption+'"?'+^J+
                    'posible the system is instabile or out of'+^J+
                    'control......',
          mtConfirmation,[mbYes,mbNo],0)=mrYes then
       begin
         PrID:=StrToInt('$'+ItemFocused.SubItems[0]);
         Ph:=OpenProcess(1,BOOL(0),PrID);
         Ret:=TerminateProcess(Ph,0);
         if Integer(Ret)=0 Then
           MessageDlg('Can Not Terminate "'+ItemFocused.Caption+'"',mtInformation,[mbOk],0)
         else
           ItemFocused.Delete;
       end;
     end;
   except
   end;
end;

procedure TFormMain.FormCreate(Sender: TObject);
begin
  //Application.OnHint := DisplayHint;  //If you want/need it...
  BtnRefreshClick(Sender);
end;

(Only Win95/Win98/ME)


0
 
LVL 20

Expert Comment

by:Madshi
ID: 6426089
I would suggest using keybd_event. It just simulates key pressed and doesn't care which application is currently in the foreground.

E.g. this one simulates pressing and releasing the control key:

  keybd_event(VK_CONTROL, 0, 0,               0);
  keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);

Regards, Madshi.
0
 
LVL 3

Expert Comment

by:lopem
ID: 6426768
listening...
0
 
LVL 34

Expert Comment

by:Slick812
ID: 6427513
if you use the keybd_event then this might help you to get the VK_ code for letters, VkKeyScan('m'), this will only get the small m you will have to use the
keybd_event(VK_SHIFT, 1, 0, 0);
to get upper case
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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses
Course of the Month10 days, 20 hours left to enroll

886 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