L/R Mouse Buttons...

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
User avatar
Phil Pendlebury
Automation Wizard
Posts: 543
Joined: Tue Jan 16, 2007 9:00 am
Contact:

L/R Mouse Buttons...

Post by Phil Pendlebury » Sun Feb 26, 2012 7:03 pm

Hi there,

I seem to remember discussing this before at some point. I had a couple of issues with people using my app that are using Left Handed mouse assignments.

I thought I had sorted this but obviously not.

In my app I am using for example:

Code: Select all

LDown
  Wait>%mouse_delay%
LUp
The reason for the delay (which is read from an ini file) is because sometimes the buttons don't react quickly enough, I'm pretty sure that is irrelevant to this problem.

Perhaps if I quote the support issue it may help:

USER
Got it solved! Switching the mouse back to right handed solved the problem.
I am one of the rare people that use a mouse in the left hand with the buttons switched I guess
ME
I had built in support for left handed mice a while ago but something must have gone amiss. As you say, it easy enough to switch buttons but I will certainly fix this in an update.

If you have a minute, could you please explain what process you use to change the mouse orientation. Is it using Control Panel or the mouse's own drivers or maybe a switch on the mouse itself?
USER
I use the "mouse" menu in the control panel and in the first tab called buttons (in windows 7) I use switch primary buttons (maybe the naming is different in the english version of windows, I use the Dutch version). To use it left handed I enable this box and to solve my problem with your app I disable this box.
I was wondering if that sheds any light on the situation? I am sure we discussed this before and that it was an issue that was "fixed" which is why I thought I should report it here, or maybe it is not "fixable"? If so is there any obvious work around I can place in the code to compensate for users using this method to alter L/R buttons?

Thanks in advance.

Phil.
Phil Pendlebury - Linktree

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Sun Feb 26, 2012 9:33 pm

Odd. Macro Scheduler checks whether the mouse is right or left handed and therefore ensures that a LClick is always the primary mouse button and RClick the opposite. So it should already handle it for you. You shouldn't need to do anything in your scripts. I'll re-test.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
Phil Pendlebury
Automation Wizard
Posts: 543
Joined: Tue Jan 16, 2007 9:00 am
Contact:

Post by Phil Pendlebury » Mon Feb 27, 2012 12:10 pm

Hi Marcus,

Thanks for your reply. Yes that was the discussion I remembered.

If you can shed any light on this it would be appreciated. Maybe it got broken in an update or maybe the app I control takes clicks in a strange way?
Phil Pendlebury - Linktree

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Mon Feb 27, 2012 5:11 pm

Ok, this could be due to some inconsistencies in the way different mouse drivers work.

What Macro Scheduler has always done is check the SwapMouseButtons registry entry:

HKEY_CURRENT_USER\Control Panel\Mouse - SwapMouseButtons

The mouse properties dialog in control panel should provide an option to "switch primary and secondary buttons" and this should affect this registry value.

However, in my case - and I'm using a Microsoft wireless mouse! - this option doesn't exist. Instead I can select the action that the left button should do, and again for the right button. So I have to select two items.

And having done that it does not seem to be modifying the SwapMouseButtons registry entry.

So that means Macro Scheduler doesn't know to swap behaviour.

However, on a different machine with a regular mouse I see the default Windows "switch primary and secondary buttons" option and when I use this the registry entry is updated and Macro Scheduler therefore complies and an RClick does a default right click behaviour (now done with my left physcial button) and vice versa.

So this is as designed and expected.

I think the issue therefore is with custom mouse drivers which don't do what Windows does. Macro Scheduler copes where the standard Windows behaviour/options exist. Unfortunately we cannot handle it when this isn't the case.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
Phil Pendlebury
Automation Wizard
Posts: 543
Joined: Tue Jan 16, 2007 9:00 am
Contact:

Post by Phil Pendlebury » Mon Feb 27, 2012 5:48 pm

Ok Marcus, Thanks for that.

So I think my safest option then is just to add an entry to my ini file for Left or Right handed mouse. defaulting to Right.

Then if a user is experiencing problems I can ask him to change the setting.

I will have to go through the code and put IF>THEN around the clicks as I can't imagine being able to use variable to assign the click.

All easily done.

I presume this won't work:

Read ini file for "UserMouse" variable.
Normal - Right handed - Other = Left Handed

Code: Select all

IF>UserMouse=Normal
  Let>BUTTON=L
ELSE
 LET>BUTTON=R
ENDIF
...
// Send the click
%BUTTON%Down
%BUTTON%Up
More likely I will have to find all instances of:

Code: Select all

LDown
  Wait>%mouse_delay%
LUp
And replace with:

Code: Select all

IF>UserMouse=Normal
LDown
  Wait>%mouse_delay%
LUp
ELSE
RDown
  Wait>%mouse_delay%
RUp
ENDIF
Unless you have any thoughts on a 100% reliable way to tell MS which way round the mouse is being used?

Thanks again for taking the time to check all that.

Cheers,

Phil.
Phil Pendlebury - Linktree

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Mon Feb 27, 2012 5:56 pm

What you could try is just setting that existing registry value:

HKEY_CURRENT_USER\Control Panel\Mouse - SwapMouseButtons

Ask the user to set that to 1 - or make a script that does so.

Since Macro Scheduler reads that to determine left/right handedness that should do it, assuming no adverse affects.

The standard Windows "switch primary and secondary buttons" does exactly this. But it seems some mouse drivers replace this control panel applet and do it some other way without modifying this value.

I modified it manually and everything continued to work correctly and then Macro Scheduler worked too. So maybe that's all you need to do. Maybe ask one or two affected users to try it.

But regarding your question, no you can't put a variable in the command name, so, yes, your longer version will be required.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
Phil Pendlebury
Automation Wizard
Posts: 543
Joined: Tue Jan 16, 2007 9:00 am
Contact:

Post by Phil Pendlebury » Mon Feb 27, 2012 7:30 pm

Thanks Marcus all great info as usual.
Phil Pendlebury - Linktree

User avatar
Phil Pendlebury
Automation Wizard
Posts: 543
Joined: Tue Jan 16, 2007 9:00 am
Contact:

Post by Phil Pendlebury » Tue Feb 28, 2012 5:19 pm

Will compile this (quick 5 minute script) and ask user to let me know the results:

Code: Select all

Let>APP_TITLE=Mouse Button Registry Check

Dialog>Dialog1
object Dialog1: TForm
  Left = 934
  Top = 581
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  Caption = 'Mouse Button Registry Check'
  ClientHeight = 126
  ClientWidth = 283
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  ShowHint = True
  OnTaskBar = False
  PixelsPerInch = 96
  TextHeight = 13
  object Label1: TLabel
    Left = 48
    Top = 16
    Width = 173
    Height = 13
    Caption = 'Registry Mouse Keys Check / Adjust'
  end
  object MSButton1: tMSButton
    Left = 14
    Top = 40
    Width = 75
    Height = 73
    Caption = 'CHECK'
    TabOrder = 8
    DoBrowse = False
    BrowseStyle = fbOpen
  end
  object MSButton2: tMSButton
    Left = 193
    Top = 41
    Width = 75
    Height = 72
    Caption = 'SWAP'
    TabOrder = 9
    DoBrowse = False
    BrowseStyle = fbOpen
  end
  object MSButton3: tMSButton
    Left = 104
    Top = 40
    Width = 73
    Height = 73
    Caption = 'QUIT'
    TabOrder = 10
    DoBrowse = False
    BrowseStyle = fbOpen
  end
end
EndDialog>Dialog1

AddDialogHandler>Dialog1,MSButton1,OnClick,doCHECK
AddDialogHandler>Dialog1,MSButton2,OnClick,doSWAP
AddDialogHandler>Dialog1,MSButton3,OnClick,doQUIT

Show>Dialog1,xxx

SRT>doCHECK
  RegistryReadKey>HKEY_CURRENT_USER,Control Panel\Mouse,SwapMouseButtons,Result
  If>Result=0
    MDL>(%Result%) Mouse buttons are NOT reversed in registry%CRLF%Hit the SWAP button to change this.
  ENDIF
  If>Result=1
    MDL>(%Result%) Mouse buttons ARE reversed in registry
  ENDIF
END>doCHECK

SRT>doSWAP
  RegistryReadKey>HKEY_CURRENT_USER,Control Panel\Mouse,SwapMouseButtons,Result
  If>Result=0
    RegistryWriteKey>HKEY_CURRENT_USER,Control Panel\Mouse,SwapMouseButtons,1
  ENDIF
  If>Result=1
    RegistryWriteKey>HKEY_CURRENT_USER,Control Panel\Mouse,SwapMouseButtons,0
  ENDIF
  MDL>Mouse buttons are now reversed in registry.%CRLF%Press the CHECK button to confirm this.
END>doSWAP

SRT>doQUIT
  Exit>0
END>doQUIT
:-)
Phil Pendlebury - Linktree

User avatar
Phil Pendlebury
Automation Wizard
Posts: 543
Joined: Tue Jan 16, 2007 9:00 am
Contact:

Post by Phil Pendlebury » Tue Feb 28, 2012 8:11 pm

The plot thickens:

From the user:
If I check with MBButtonCheck when my mouse is normal (left handed and that clicking is not working in the software) it is saying "(1) Mouse buttons ARE reversed in registry"
So it seems that his drivers are setting the correct registry key after all...

He also tried various other things (using my tool above he set the mouse back to normal etc.)

Could it be the software that is being clicked on - that refuses to obey these settings?
Phil Pendlebury - Linktree

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Wed Feb 29, 2012 9:34 am

Hmm. So Windows thinks the buttons are swapped. Macro Scheduler reads that setting and reverses the button calls. So if it isn't working, it seems to suggest the driver does something different. Annoying. I don't know what if anything we can do but will try to research this a bit more.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
Phil Pendlebury
Automation Wizard
Posts: 543
Joined: Tue Jan 16, 2007 9:00 am
Contact:

Post by Phil Pendlebury » Fri Mar 30, 2012 4:43 pm

Hi Marcus, I was just wondering if you have any further thoughts on this or indeed a way I can test it and reproduce?

Or maybe easier for me just to add a preference to reverse mouse buttons.

Thanks,

Phil.
Phil Pendlebury - Linktree

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Wed Apr 18, 2012 11:50 am

Gosh sorry just seen this. No, not sure there's anything we can do. We're checking the system flag which *should* be set if the buttons are swapped, but it would appear that some manufacturers/drivers are doing things differently and not using the flag. There's not a lot we can do if they're all doing things in different ways.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
Phil Pendlebury
Automation Wizard
Posts: 543
Joined: Tue Jan 16, 2007 9:00 am
Contact:

Post by Phil Pendlebury » Wed Apr 18, 2012 12:13 pm

Yup, it's Ok I added a new SR to cope with this:

Code: Select all

ReadIniFile>%ScriptLocation%\ini\defs.ini,other_options,reverse_mb,mouse_reverse

Code: Select all

SRT>MouseClickSR
  IF>%mouse_reverse%=False
    LDown
     Wait>%mouse_delay%
    LUp
  ENDIF
  IF>%mouse_reverse%=True
    RDown
     Wait>%mouse_delay%
    RUp
  ENDIF
END>MouseClickSR
SRT>MouseDoubleClickSR
  IF>%mouse_reverse%=False
    LDown
     Wait>%mouse_delay%
    LUp
    LDown
     Wait>%mouse_delay%
    LUp
  ENDIF
  IF>%mouse_reverse%=True
    RDown
     Wait>%mouse_delay%
    RUp
    RDown
     Wait>%mouse_delay%
    RUp
  ENDIF
END>MouseDoubleClickSR
Btw, I am using LDown / Rdown etc. with a delay (again read from ini file), due to the response of normal clicking being sluggish on some systems.

:D
Phil Pendlebury - Linktree

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts