Recent

Author Topic: OnMouseDown event  (Read 21373 times)

rvk

  • Hero Member
  • *****
  • Posts: 6939
Re: OnMouseDown event
« Reply #45 on: February 01, 2024, 03:23:02 pm »
But it looks like the KodeZwerg is a direct access to the Windows infrastructure. Wouldn't that be independent of the Lazarus complier?
Yes. It uses SetWindowsHookExW so that's outside the Lazarus framework.

So it must be something else that's blocking the buttons to the application process (which is what I was saying from the beginning).

If then buttons 4 & 5 work in Lazarus and they stop working at some point, then there must be something interfering with it.

(What's why I also suggested the X-Mouse app to see if that can detect the buttons at the point it's not getting to your app anymore, just to test it.)

If it's just only you app that's eventually denied access to those buttons it seems some security issue, but I can't imagine what.
If it's all other programs too (like X-Mouse) that's denied access then there is something wrong with the buttons/driver itself at that moment.

It's just a matter of investigating what (but we can't do that from a distance and it's hard if we can't reproduce the issue).

RW1962

  • New Member
  • *
  • Posts: 41
Re: OnMouseDown event
« Reply #46 on: February 01, 2024, 04:40:06 pm »
I had tried X-Mouse earlier ... but I just installed it again, and set 4 & 5 to BACK & FORWARD. It no effect with Lazarus, none with a run version of my App, and none with a compiled App. While other editors also continued to function.

rvk

  • Hero Member
  • *****
  • Posts: 6939
Re: OnMouseDown event
« Reply #47 on: February 01, 2024, 07:15:28 pm »
You need to see if the line with extra 5 and 6 light up when you press them. That indicates that x-mouse can see them. If they don't light up then x-mouse also doesn't see the buttons. You don't need to assign them.. just see if the app sees them and then close the app again.

Next you need to look in the taskmanager and remove any process that can hinder the buttons. Like normally videodriver helper software. They usually catch (shortcut)keys and maybe buttons too.

But still... that would be systemwide, not per program.

I'm out of ideas (especially because it's working and then it's not, and then it's working again after copying).



RW1962

  • New Member
  • *
  • Posts: 41
Re: OnMouseDown event
« Reply #48 on: February 02, 2024, 03:00:04 pm »
This is a freak show...

I was checking buttons again, and using only the KodeZwerg Code, the 1 thru 3 buttons would fire. But without closing down the Lazarus editor, the same buttons would not fire.

Rick

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2269
  • Fifty shades of code.
    • Delphi & FreePascal
Re: OnMouseDown event
« Reply #49 on: February 02, 2024, 04:53:24 pm »
I was not reading all this thread content, have you tried this:
Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
  2.   Shift: TShiftState; X, Y: Integer);
  3. begin
  4.   CheckBox1.Checked := ssLeft in Shift;
  5.   CheckBox2.Checked := ssMiddle in Shift;
  6.   CheckBox3.Checked := ssRight in Shift;
  7.   CheckBox4.Checked := ssExtra1 in Shift;
  8.   CheckBox5.Checked := ssExtra2 in Shift;
  9. end;
What I can say is, that ssExtra1 and ssExtra2 do faulty MouseUp stuff within LCL or do not trigger MouseUp at all if not pressed together.
Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormMouseUp(Sender: TObject; Button: TMouseButton;
  2.   Shift: TShiftState; X, Y: Integer);
  3. begin
  4.   CheckBox1.Checked := False;
  5.   CheckBox2.Checked := False;
  6.   CheckBox3.Checked := False;
  7.   CheckBox4.Checked := False;
  8.   CheckBox5.Checked := False;
  9. end;
« Last Edit: February 02, 2024, 04:55:18 pm by KodeZwerg »
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2269
  • Fifty shades of code.
    • Delphi & FreePascal
Re: OnMouseDown event
« Reply #50 on: February 02, 2024, 05:04:16 pm »
Here is my test application attached
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

RW1962

  • New Member
  • *
  • Posts: 41
Re: OnMouseDown event
« Reply #51 on: February 02, 2024, 05:47:07 pm »
Thanks KodeZwerg,

I found what was causing a single instance for mouse clicks.

The "setup hook" in FormCreate...
mHook := SetWindowsHookExW(LWH_MOUSE_LL, @LowLevelMouseProc, hInstance, 0);

...needs to be preceded by mHook:= 0;  // to initiate the variable

When I did that, the keys would fire at every demand ... but it didn't help the Extra keys.

Quote
do not trigger MouseUp at all if not pressed together

What do you mean by "pressed together"? Do you mean a shift-button4? I haven't been doing any keyboard combinations with a mouse click.

I'll try your FormMouseDown and FormMouseUp, but I have been doing WM_XBUTTONDOWN: ShowMessage('X-Button-Down HIT') inside the LowLevelMouseProc function to confirm that the button fires.

Rick

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2269
  • Fifty shades of code.
    • Delphi & FreePascal
Re: OnMouseDown event
« Reply #52 on: February 02, 2024, 06:04:22 pm »
I am unsure how you treat the exclusive windows low level hook, attach a sample project that i can compile and test/look etc.
Does my attached project work for your needs?

Quote
do not trigger MouseUp at all if not pressed together

What do you mean by "pressed together"? Do you mean a shift-button4? I haven't been doing any keyboard combinations with a mouse click.
You need to press extra1 and extra2 together and release them together so the mouseup is fired.

I am a windows user and have no clue what x-mouse is, but it sound like fun so enjoy :D
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

RW1962

  • New Member
  • *
  • Posts: 41
Re: OnMouseDown event
« Reply #53 on: February 02, 2024, 08:46:07 pm »
Quote
You need to press extra1 and extra2 together and release them together so the mouseup is fired.
I don't think I want hit both extra buttons at the same time. Whatever it does would not allow me to control the PgUp and PgDn functionality.

Does WM_XBUTTONDOWN with Extra1 & Extra2 have any problems on your end? They are supposed handle PgUp & PgDn.

I need screen paging because my computers won't read PgUp & PgDn at all.

Your application has made me think that I can take over the button control.

But my initial question, what is keeping Windows from conflicting with my button assignments?

Rick


KodeZwerg

  • Hero Member
  • *****
  • Posts: 2269
  • Fifty shades of code.
    • Delphi & FreePascal
Re: OnMouseDown event
« Reply #54 on: February 02, 2024, 09:34:38 pm »
Quote
You need to press extra1 and extra2 together and release them together so the mouseup is fired.
I don't think I want hit both extra buttons at the same time. Whatever it does would not allow me to control the PgUp and PgDn functionality.

Does WM_XBUTTONDOWN with Extra1 & Extra2 have any problems on your end? They are supposed handle PgUp & PgDn.

I need screen paging because my computers won't read PgUp & PgDn at all.

Your application has made me think that I can take over the button control.

But my initial question, what is keeping Windows from conflicting with my button assignments?

Rick
Since you refuse to attach a demo project how you treat the low level hook I cant discuss.
Since you not answered my question if the LCL way where I attached a demo works for you I am still clueless.

On my side via Low Level Hook I have everything under full control and get everything strict and clear for each my buttons that I can test with (basic mouse with 2 extras)
Each action trigger instantly an message -> MouseUp/Down for ButtonX or wheel.
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

RW1962

  • New Member
  • *
  • Posts: 41
Re: OnMouseDown event
« Reply #55 on: February 02, 2024, 09:57:22 pm »
Quote
Since you refuse to attach a demo project how you treat the low level hook I cant discuss.
You are moving too fast. This is the end of the day for me. So I answered your questions. It will take some time for me to format the example that you want. I will work on it tomorrow, Please have patience.

Rick

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2269
  • Fifty shades of code.
    • Delphi & FreePascal
Re: OnMouseDown event
« Reply #56 on: February 03, 2024, 01:53:42 am »
Attached is a simple check that you can execute on Windows to watch if your buttons are responding to a Low Level Hook or not.
The problem with such hooks are, they do work global system wide so my demo app works beyond its window.
You need to limit its reacting power by X/Y ranges of the control they should be watching.

Whenever you can, test and reply me, in theory it has no limit on the XButtons.

App runs only on 64bit Windows systems.
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

RW1962

  • New Member
  • *
  • Posts: 41
Re: OnMouseDown event
« Reply #57 on: February 03, 2024, 04:51:03 pm »
My computer is a 64bit, but LazProject is 32bit.

I have used your MouseSpy & CheckMouse apps.

Both of the them behave the same... all buttons fire except the Extra1 & Extra2.

Additionally, if I have a Text Document open and it has focus, the Extra1 & Extra2 is scrolling pages, while your MouseSpy does not show them as firing.

I am still working on building my own example projects.

Rick

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2269
  • Fifty shades of code.
    • Delphi & FreePascal
Re: OnMouseDown event
« Reply #58 on: February 03, 2024, 05:19:55 pm »
My computer is a 64bit, but LazProject is 32bit.

I have used your MouseSpy & CheckMouse apps.

Both of the them behave the same... all buttons fire except the Extra1 & Extra2.

Additionally, if I have a Text Document open and it has focus, the Extra1 & Extra2 is scrolling pages, while your MouseSpy does not show them as firing.

I am still working on building my own example projects.

Rick
You do not need to post an example since my MouseSpy is silent on your XButtons.
I am out of ideas, even if for some reason you remapped buttons the spy should at least say something.
At this point I can not help further, all I could tell is, try my spy with a different mouse connected if it is still silent on extra buttons.

Also the spy would show if some unsupported message from mouse arrive, like pressing several buttons at once so it can not differentiate anymore what was pressed.
I've attached a newer build but code is same.
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

rvk

  • Hero Member
  • *****
  • Posts: 6939
Re: OnMouseDown event
« Reply #59 on: February 03, 2024, 05:26:48 pm »
Both of the them behave the same... all buttons fire except the Extra1 & Extra2.

Additionally, if I have a Text Document open and it has focus, the Extra1 & Extra2 is scrolling pages, while your MouseSpy does not show them as firing.
I already suggested that you close as many programs as you can. Strip it all down. Even in TaskManager.

Maybe some program steals those buttons (especially because the problem is intermittent).

Alternatively you could try running your program (or that MouseSpy app) in a Windows Sandbox just to see if the buttons work there.

 

TinyPortal © 2005-2018