Başka uygulama üzerindeki butonu x,y değerlerini alabilirmi

Delphi'de kod yazma ile ilgili sorularınızı bu foruma yazabilirsiniz.
Cevapla
Kullanıcı avatarı
metemete
Üye
Mesajlar: 422
Kayıt: 21 Mar 2004 12:30
Konum: samsun
İletişim:

Başka uygulama üzerindeki butonu x,y değerlerini alabilirmi

Mesaj gönderen metemete »

Delphi ile baska bir uygulamanın içindeki buttonun ekran çözünürlüğüne göre x,y koordinatlarını yani mouse ile üzerine geldiğimde x,y değerlerini nasıl öğreniriz? tabi bu button değilde baska bir nesnede olabilir
Kullanıcı avatarı
Search
Üye
Mesajlar: 74
Kayıt: 01 Oca 2008 01:03
Konum: Konya

Mesaj gönderen Search »

Kod: Tümünü seç

implementation

{$R *.dfm}
var 
  JHook: THandle; 

function JournalProc(Code, wParam: Integer; var EventStrut: TEventMsg): Integer; stdcall; 
var 
  Char1: PChar; 
  s: string; 
begin
  
  if Code < 0 then Exit; 
  if Code = HC_SYSMODALON then Exit; 
  if Code = HC_ACTION then 
    begin 

    s := ''; 
    if EventStrut.message = WM_LBUTTONUP then 
      s := 'Left Mouse UP at X pos ' + 
        IntToStr(EventStrut.paramL) + ' and Y pos ' + IntToStr(EventStrut.paramH); 
    if EventStrut.message = WM_LBUTTONDOWN then 
      s := 'Left Mouse Down at X pos ' + 
        IntToStr(EventStrut.paramL) + ' and Y pos ' + IntToStr(EventStrut.paramH); 
    if EventStrut.message = WM_RBUTTONDOWN then 
      s := 'Right Mouse Down at X pos ' + 
        IntToStr(EventStrut.paramL) + ' and Y pos ' + IntToStr(EventStrut.paramH); 
    if (EventStrut.message = WM_RBUTTONUP) then 
      s := 'Right Mouse Up at X pos ' + 
        IntToStr(EventStrut.paramL) + ' and Y pos ' + IntToStr(EventStrut.paramH); 
    if (EventStrut.message = WM_MOUSEWHEEL) then 
      s := 'Mouse Wheel at X pos ' + 
        IntToStr(EventStrut.paramL) + ' and Y pos ' + IntToStr(EventStrut.paramH); 
    if (EventStrut.message = WM_MOUSEMOVE) then 
      s := 'Mouse Position at X:' + 
        IntToStr(EventStrut.paramL) + ' and Y: ' + IntToStr(EventStrut.paramH); 
    if s <> '' then
       Form1.ListBox1.ItemIndex :=  Form1.ListBox1.Items.Add(s);
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
 begin
       if FHookStarted then
  begin 
      ShowMessage('Mouse is already being Journaled, can not restart'); 
    Exit; 
  end; 
      JHook := SetWindowsHookEx(WH_JOURNALRECORD, @JournalProc,    hInstance, 0); 
  if JHook > 0 then 
  begin 
    FHookStarted := True; 
  end 
  else 
    ShowMessage('No Journal Hook availible'); 
end; 


procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
   if FHookStarted then 
    UnhookWindowsHookEx(JHook); 

end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  FHookStarted := False; 
  UnhookWindowsHookEx(JHook);
  JHook := 0; 
end;

procedure TForm1.ApplicationEvents1Message(var Msg: tagMSG;
  var Handled: Boolean);
begin

  Handled := False;
  if (Msg.message = WM_CANCELJOURNAL) and FHookStarted then
    JHook := SetWindowsHookEx(WH_JOURNALRECORD, @JournalProc, 0, 0);

end;
Kolay gelsin...
procedure TForm1.FormCreate(Sender: TObject);
begin
showmessage('Dehanın %1 i ilham %99u terdir.');
end;
end.
Kullanıcı avatarı
metemete
Üye
Mesajlar: 422
Kayıt: 21 Mar 2004 12:30
Konum: samsun
İletişim:

Mesaj gönderen metemete »

bu kodlar bende vardı teşekkür ederim ama yanlış bilgi verdim sanırım. mouse ile üzerine gitmeden o buttonun değerini öğrenemeyizmi?
Cevapla