Solved

popup letters without pressing keyboard

Posted on 2001-08-25
9
282 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
[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
9 Comments
 
LVL 1

Accepted Solution

by:
sundayboys earned 150 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Connection between libmysql.dll and MySQL Versions 7 132
Delphi 2 91
Broadcast a message using ICS 2 51
Delphi Firemonkey : user drawing in window 3 58
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

752 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