Jeżeli w Firefoxie miałbyś otwarte okno, w którym widoczny będzie kod strony (któraś z opcji programistycznych) to możesz spróbować dobrać się do tego konkretnego okna. Ja coś podobnego ostatnio potrzebowałem i zrobiłem to tak:
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ShellAPI, TlHelp32, ExtCtrls
function GetProcesID(exeName:String): Cardinal;
var
Uchwyt:tHandle;
Proces:tProcessEntry32;
begin
Result := 0;
Uchwyt:=CreateToolHelp32SnapShot(TH32CS_SNAPALL,0);
Proces.dwSize:=SizeOf(Proces);
if Integer(Process32First(Uchwyt,Proces))<>0 then
repeat
if (LowerCase(Proces.szExeFile) = LowerCase(exeName)) then
begin
Result := Proces.th32ProcessID;
Break;
end;
until Integer(Process32Next(Uchwyt,Proces))=0;
closehandle(Uchwyt);
end;
function GetHWndByPID(const hPID: THandle): THandle;
type
PEnumInfo = ^TEnumInfo;
TEnumInfo = record
ProcessID: DWORD;
HWND: THandle;
end;
function EnumWindowsProc(Wnd: DWORD; var EI: TEnumInfo): Bool; stdcall;
var
PID: DWORD;
begin
GetWindowThreadProcessID(Wnd, @PID);
Result := (PID <> EI.ProcessID) or
(not IsWindowVisible(WND)) or
(not IsWindowEnabled(WND));
if not Result then EI.HWND := WND; //break on return FALSE
end;
function FindMainWindow(PID: DWORD): DWORD;
var
EI: TEnumInfo;
begin
EI.ProcessID := PID;
EI.HWND := 0;
EnumWindows(@EnumWindowsProc, Integer(@EI));
Result := EI.HWND;
end;
begin
if hPID<>0 then
Result:=FindMainWindow(hPID)
else
Result:=0;
end;
function EnumChildren(hwnd: HWND; lParam: LPARAM): BOOL; stdcall;
const
TextBoxClass = 'Favorite directories (F2)';
var
ClassName: array[0..259] of Char;
begin
Result := True;
GetClassName(hwnd, ClassName, Length(ClassName));
Windows.GetWindowText(hwnd,classname,length(ClassName));
if ClassName = TextBoxClass then
TStrings(lParam).Add('Hurra');
end;
procedure TForm1.Button1Click(Sender: TObject);
var
h: THandle;
begin
h := GetHWndByPID(GetProcesID('DicomWorks.exe'));
Memo1.Lines.Clear;
EnumChildWindows(h, @EnumChildren, UINT_PTR(Memo1.Lines)); //tutaj odpalamy funkcję przeszukującą wszystkie childy parenta czyli w twoim wypadku Firefox.exe
if Memo1.Lines[0] = 'Hurra' then //z tym memo to demo jest więc zastosuj sobie lepsze rozwiązanie
begin
//tutaj twój kod
end;
end;