Soyez le premier à donner votre avis sur cette source.
Vue 7 714 fois - Téléchargée 729 fois
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, TLHelp32, Spin; type TForm1 = class(TForm) GroupBox1: TGroupBox; GroupBox2: TGroupBox; GroupBox3: TGroupBox; Label1: TLabel; Edit1: TEdit; Button1: TButton; Button2: TButton; Label2: TLabel; Edit2: TEdit; Button3: TButton; Button4: TButton; StaticText1: TStaticText; StaticText2: TStaticText; Edit3: TEdit; ListBox1: TListBox; Button6: TButton; CheckBox1: TCheckBox; Timer1: TTimer; Memo1: TMemo; Button5: TButton; Button7: TButton; Label3: TLabel; SpinEdit1: TSpinEdit; Label4: TLabel; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure Button3Click(Sender: TObject); procedure Button4Click(Sender: TObject); procedure ListBox1Click(Sender: TObject); procedure FormCreate(Sender: TObject); procedure Button7Click(Sender: TObject); procedure Button6Click(Sender: TObject); procedure Timer1Timer(Sender: TObject); procedure Button5Click(Sender: TObject); procedure SpinEdit1Change(Sender: TObject); private { Déclarations privées } public { Déclarations publiques } end; var Form1: TForm1; implementation {$R *.dfm} //Pour le Style WindowsXP {$R windowsXp.res} Function GetCalculatrice:String; var Calc,Edit:HWND; Mem:integer; begin Result:=''; //Retrouve le Handle de la fenêtre de Calculatrice (Par sa Class) Calc:=FindWindow('SciCalc',Nil); //ou Retrouve le Handle de la fenêtre de Calculatrice (Par son Titre) // Calc:=FindWindow(nil,'Calculatrice'); if Calc<>0 then begin //Cherche le Handle du Edit Edit:=FindWindowEx(Calc,0,'Edit',nil); //obtenir la numbre de caractere Mem:=SendMessage(Edit,WM_GETTEXTLENGTH,0,0)+1; SetLength(Result,Mem); //Envoi du message //"WM_GETTEXT" le paramettre pour recevoir de message. SendMessage(Edit,WM_GETTEXT,Mem,Integer(@Result[1])); end; end; procedure SetCalculatrice(St:string); var Calc,Edit:HWND; begin //Retrouve le Handle de la fenêtre de Calculatrice (Par sa Class) Calc:=FindWindow('SciCalc',Nil); //ou Retrouve le Handle de la fenêtre de Calculatrice (Par son Titre) // Calc:=FindWindow(nil,'Calculatrice'); if Calc<>0 then begin //Cherche le Handle du Edit Edit:=FindWindowEx(Calc,0,'Edit',nil); //Envoi du message //"WM_SETTEXT" le paramettre pour Envoi de message. SendMessage(Edit,WM_SETTEXT,Integer(st),Integer(@st[1])); end; end; procedure SetInternetExplorerURL(St:String); var Explorer,ClientWork,Toolbar,ComboBox,ComboBoxChild,Edit:HWND; begin //Retrouve le Handle de la fenêtre de IE Explorer:=FindWindow('IEFrame',nil); if Explorer<>0 then begin //Cherche le Handle de la fenêtre de travail ClientWork:=FindWindowEx(Explorer,0,'WorkerA',nil); if ClientWork=0 then ClientWork:=FindWindowEx(Explorer,0,'WorkerW',nil); //Retrouve le Handle de la ToolBar Toolbar:=FindWindowEx(ClientWork,0,'ReBarWindow32',nil); //Cherche le Handle du ComboBox ComboBox:=FindWindowEx(Toolbar,0,'ComboBoxEx32', nil); ComboBoxChild:=FindWindowEx(ComboBox,0,'ComboBox',nil); //Cherche le Handle du Edit Edit:=FindWindowEx(ComboBoxChild,0,'Edit',nil); //Envoi du message SendMessage(Edit,WM_SETTEXT,Integer(st),Integer(@st[1])); end; end; Function GetInternetExplorerURL:String; var Explorer,ClientWork,Toolbar,ComboBox,ComboBoxChild,Edit:HWND; Mem:integer; begin //Retrouve le Handle de la fenêtre de IE Explorer:=FindWindow('IEFrame',nil); if Explorer<>0 then begin //Cherche le Handle de la fenêtre de travail ClientWork:=FindWindowEx(Explorer,0,'WorkerA',nil); if ClientWork=0 then ClientWork:=FindWindowEx(Explorer,0,'WorkerW',nil); //Retrouve le Handle de la ToolBar Toolbar:=FindWindowEx(ClientWork,0,'ReBarWindow32',nil); //Cherche le Handle du ComboBox ComboBox:=FindWindowEx(Toolbar,0,'ComboBoxEx32', nil); ComboBoxChild:=FindWindowEx(ComboBox,0,'ComboBox',nil); //Cherche le Handle du Edit Edit:=FindWindowEx(ComboBoxChild,0,'Edit',nil); //Envoi du message Mem:=SendMessage(Edit,WM_GETTEXTLENGTH,0,0)+1; SetLength(Result,Mem); SendMessage(Edit,WM_GETTEXT,Mem,Integer(@Result[1])); end; end; procedure TForm1.Button1Click(Sender: TObject); begin Label1.Caption:=GetCalculatrice; end; procedure TForm1.Button2Click(Sender: TObject); begin SetCalculatrice(edit1.Text); end; procedure TForm1.Button3Click(Sender: TObject); begin label2.Caption:=GetInternetExplorerURL; end; procedure TForm1.Button4Click(Sender: TObject); begin SetInternetExplorerURL(edit2.Text); end; function GetModule(Hdl : HWND;ProcessID : Cardinal) : ShortString; var ProcessEntry : TProcessEntry32; Snap : Integer; begin Snap := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); try ProcessEntry.dwSize := SizeOf(ProcessEntry); if(Process32First(Snap,ProcessEntry))then begin repeat if ProcessEntry.th32ProcessID = ProcessID then begin Result := StrPas(ProcessEntry.szExeFile); Break; end; until not(Process32Next(Snap,ProcessEntry)); end; finally Windows.CloseHandle(Snap); end; end; procedure TForm1.ListBox1Click(Sender: TObject); var Hdl : Hwnd; WText,ClassName : Array[0..255] of Char; ProcessId : Cardinal; begin memo1.Clear; hdl:=strtoint(ListBox1.Items.Strings[ListBox1.ItemIndex]); memo1.lines.Add('Handle de la fenêtre : ' + inttostr(hdl)); GetWindowText(hdl,WText,SizeOf(WText)); memo1.lines.Add('Texte de la fenêtre : ' + String(WText)); GetClassName(hdl,ClassName,SizeOf(ClassName)); memo1.lines.Add('Nom de classe : ' + String(ClassName)); GetWindowThreadProcessId(Hdl,@ProcessId); memo1.lines.Add('ID du processus : ' + IntToStr(ProcessID)); memo1.lines.Add('Nom du module : ' + GetModule(Hdl,ProcessID)); end; procedure TForm1.FormCreate(Sender: TObject); begin SetWindowPos(form1.Handle, HWND_TOPMOST, 0, 0, 0, 0,SWP_NOMOVE or SWP_NOSIZE or SWP_NOACTIVATE); end; procedure TForm1.Button7Click(Sender: TObject); begin SendMessage(strtoint(ListBox1.Items.Strings[ListBox1.ItemIndex]),WM_SETTEXT,Integer(edit3.Text),Integer(@edit3.Text[1])); end; procedure TForm1.Button6Click(Sender: TObject); begin Timer1.Enabled:=not Timer1.Enabled; if Timer1.Enabled=true then begin Button6.Caption:='ARRETER'; SpinEdit1.Enabled:=False; end else begin Button6.Caption:='Démarrer'; SpinEdit1.Enabled:=True; end; end; procedure TForm1.Timer1Timer(Sender: TObject); var Hdl:HWND; Pt:TPoint; j:integer; bool:boolean; begin If (GetCursorPos(Pt)) then begin Hdl:=WindowFRomPoint(Pt); if Listbox1.Items.Count>0 then begin j:=1; bool:=false; while (j<=Listbox1.items.count)and(bool=false) do if Listbox1.Items.Strings[j-1]=inttostr(Hdl) then bool:=true else inc(j); end; if bool=false then begin Listbox1.Items.Insert(0,inttostr(Hdl)); if CheckBox1.Checked=true then Button6Click(self); end;end; end; Function GetHandleText:String; var h:HWND; Mem :integer; begin h:=strtoint(form1.ListBox1.Items.Strings[form1.ListBox1.ItemIndex]); Mem:=SendMessage(h,WM_GETTEXTLENGTH,0,0)+1; SetLength(Result,Mem); SendMessage(h,WM_GETTEXT,Mem,Integer(@Result[1])); end; procedure TForm1.Button5Click(Sender: TObject); begin label3.caption:=GetHandleText; end; procedure TForm1.SpinEdit1Change(Sender: TObject); begin timer1.Interval:=SpinEdit1.Value*100; end; end.
10 sept. 2008 à 16:01
Source interressante, mais saurai-tu par hazard, comment lire les infos d'un edit ou d'une combobox à partir d'un site utilisant flash, j'm'explique : je souhaiterai extraire les infos (artiste, titre) du site deezer, mais c'est une application flash, hors je ne sais pas comment allé récuperer les infos de ce type d'application, si par hazard tu aurai une idée... merci :)
Vous n'êtes pas encore membre ?
inscrivez-vous, c'est gratuit et ça prend moins d'une minute !
Les membres obtiennent plus de réponses que les utilisateurs anonymes.
Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.
Le fait d'être membre vous permet d'avoir des options supplémentaires.