private procedure WMHotKey(var a: TWMHotKey); message WM_HOTKEY; Procedure ShowTitle(Sender: TObject); { Private declarations } public { Public declarations } end;
var Formsmall: TFormsmall; nid: TNotifyIconData;
implementation
{$R *.DFM}
Procedure SendtoWindow(s: string); var wt:pchar; h: hwnd; begin h := findWindow( nil, nil); GetWindowText(h,wt,255); setforegroundwindow(h); end;
Procedure TFormsmall.ShowTitle(Sender: TObject); var npad:HWND; szText: array[0..254] of char; begin ListBox1.Items.clear; Npad := GetWindow(Handle, GW_OWNER{GW_HWNDFIRST}); while Npad <> 0 do begin if (GetWindowText(Npad, @szText, 255) > 0) and IsWindowVisible(Npad) then ListBox1.Items.add(StrPas(@szText)); Npad:= GetWindow(Npad, GW_HWNDNEXT); end; end;
function MyCallback(Wnd: THandle; Param: integer):boolean; stdcall; VAR npad:HWND; begin Npad := FindWindow( nil,Pchar(Formsmall.Edit1.Text)); if npad <> 0 then begin BringWindowToTop(Npad); Wnd:=Npad; Result := Wnd <> 0; if Result and IsWindowVisible(Wnd) then ShowWindow(Wnd,Param); end; END;
function MyCallback0(Wnd: THandle; Param: integer):boolean; stdcall; VAR npad:HWND; begin Npad := FindWindow( nil,Pchar(Formsmall.Edit2.Text)); if npad <> 0 then begin BringWindowToTop(Npad); Wnd:=Npad; Result := Wnd <> 0; if Result and IsWindowVisible(Wnd) then ShowWindow(Wnd,Param); end; END;
procedure ShowAllWindows0(Cmd: integer); begin EnumWindows(@MyCallback0, 1); end; procedure TFormsmall.WMHotKey(var a: TWMHotKey); begin if a.HotKey = 0 then begin ShowAllWindows(SW_SHOWNORMAL) ; end; if a.HotKey = 1 then begin ShowAllWindows0(SW_SHOWNORMAL) ; end; end;
procedure TFormsmall.FormCreate(Sender: TObject); begin ShowTitle(Self); RegisterHotKey(Handle,0,MOD_CONTROL+MOD_ALT,ord('A')); RegisterHotKey(Handle,1,MOD_CONTROL+MOD_ALT,ord('Q')); end;
procedure TFormsmall.CtrlAltA1Click(Sender: TObject); var i : integer; begin for I:=0 to ListBox1.Items.Count - 1 do if ListBox1.Selected[I] then Edit1.text:= ListBox1.Items[I]; end;
procedure TFormsmall.CtrlAltQ1Click(Sender: TObject); var i : integer; begin for I:=0 to ListBox1.Items.Count - 1 do if ListBox1.Selected[I] then Edit2.text:= ListBox1.Items[I]; end;
procedure TFormsmall.Button1Click(Sender: TObject); begin ShowTitle(Self); end;
procedure TFormsmall.Button2Click(Sender: TObject); begin close; end;