1.<br>Var<br> S,US: string;<br> i: Integer;<br>begin<br><br> S := 'abcdefg';<br> US := UpperCase(s);<br> For i:=1 To Length(US) Do<br> Begin<br> KeyBd_Event(Ord(US),0,0,0);<br> KeyBd_Event(Ord(US),0,KeyEventF_KeyUp,0);<br> End;<br><br>end;<br><br>2.<br>function Proc(AWnd: HWND; AlParam: LPARAM):Boolean;stdcall;<br>var<br> WndCaption: array[0..254] of Char;<br> ulpClassName : array[0..254] of Char;<br> i : integer ;<br>begin<br> GetWindowText(AWnd, WndCaption, 254);<br> GetClassName(AWnd, ulpClassName, 254);<br> if (WndCaption[0]<>chr(0)) and IsWindowVisible(AWnd)<br> then <br> begin<br> Form1.ListBox1.Items.Add(StrPas(WndCaption)+':'+StrPas(ulpClassName));<br> //如果ulpClassName是'TEdit'(Delphi/BCB程序)或'Edit'(VC/VB程序)则用FindWindowEx找到控件句柄<br> end;<br> Result := True;<br>end;<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br> enumchildwindows(findwindow(nil,'Form1'),@proc,0);<br>end;