Solved

popup letters without pressing keyboard

Posted on 2001-08-25
9
277 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 150 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 22

Expert Comment

by:mnasman
Comment Utility
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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

Author Comment

by:ryan_sabarre
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
listening...
0
 
LVL 33

Expert Comment

by:Slick812
Comment Utility
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
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…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

771 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now