[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.6

dll mousehook or journaling thru my own application?

Asked by urif in Delphi Programming

Tags: hook

ok, at the moment i am creating a mouse journal (hook) because i need my application to know where is the mouse, if the mouse move, if the user pressed left, right or whatever mouse button, etc.
see the question after all the code

this is the code for the journaling:

function JournalProc(Code, wParam: Integer; var EventStrut: TEventMsg): Integer; stdcall;
var
  s: string;
begin
  {this is the JournalRecordProc}
  Result := CallNextHookEx(JHook, Code, wParam, Longint(@EventStrut));
  if Code < 0 then Exit;

  {you should cancel operation if you get HC_SYSMODALON}
  if Code = HC_SYSMODALON then Exit;
  if Code = HC_ACTION then
  begin
    s := '';

    if EventStrut.message = WM_LBUTTONUP then
    begin
     if not form2.CheckBox1.Checked then //no stiky double-click
     begin
       doubleclick:=false;
       form1.SpeedButton1.Down:=true;
     end;
    end;

    if EventStrut.message = WM_LBUTTONDOWN then
    begin
      form1.TILed1.Flash;
      form1.TILed1.Caption:='L';
    end;

    if EventStrut.message = WM_RBUTTONDOWN then
    begin
      form1.TILed1.Flash;
      form1.TILed1.Caption:='R';
    end;

    if (EventStrut.message = WM_RBUTTONUP) then
    begin
        if not form2.CheckBox1.Checked then //no stiky righ-click
        begin
           leftclick:=true;
           form1.SpeedButton1.Down:=true;
        end;
    end;

    if (EventStrut.message = WM_MOUSEWHEEL) then
    begin
      //s := 'Mouse Wheel at X pos ' +
      //  IntToStr(EventStrut.paramL) + ' and Y pos ' + IntToStr(EventStrut.paramH);
    end;

    if (EventStrut.message = WM_MOUSEMOVE) then
    begin
      form1.MouseMoveReceived;
      posx:=EventStrut.paramL;
      posy:=EventStrut.paramH;
    end;

    if s <> '' then
    begin
       Form1.Label3.Caption:=s; //debug
    end;
  end;
end;


and i am starting the journaling with:

JHook := SetWindowsHookEx(WH_JOURNALRECORD, @JournalProc, hInstance, 0);

and stopping it with:

UnhookWindowsHookEx(JHook);

also, since the windows cancels the journal when the user presses ctrl-esc or ctrl-alt-del i am restarting it with:

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, hInstance, 0);

end;

now, here's the problem. while the hook is on i experience the following:
the start menu and any of the sub-menues there will flicker, as if someone if repetedly moving the mouse of the items and reopening them. also alt-tab will show the task change little form but it will disappear almost intantly.
all this might be related to the journal, or maybe to the rest of my code, that simple clicks the mouse by code when the user moves and stops the mouse somewhere on the screen. in any case, what's better a mouse journal or a full dll hook on the mouse in this case?
the case beeing the ability to know where the mouse is at any given time, to know whether the mouse is moving or not, whether it;s a left click, right click, double click or the mouse is till down (the user is dragging the form, etc).

if a full dll is better, i know the journaling could be problematic - hence this entire question, does anyone has simple example for a mouse hook thru a dll?

thanks and sorry for the poor english.
[+][-]09/20/05 07:21 AM, ID: 14920391Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zone: Delphi Programming
Tags: hook
Sign Up Now!
Solution Provided By: RadikalQ3
Participating Experts: 2
Solution Grade: A
 
[+][-]09/20/05 07:44 AM, ID: 14920625Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/20/05 08:11 AM, ID: 14920847Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09/20/05 08:13 AM, ID: 14920864Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09/20/05 11:41 AM, ID: 14922828Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/20/05 02:42 PM, ID: 14924290Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09/20/05 02:49 PM, ID: 14924330Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09/20/05 02:53 PM, ID: 14924348Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09/21/05 12:29 AM, ID: 14926256Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/22/05 09:47 AM, ID: 14938267Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-92