It's only 8 assembly instruction:
winmain::
moveq.l #0,-(sp)
jsr.l (SwapMouseButton)
eorq.l #1,r0
beq.b _10
move.l r0,-(sp)
jsr.l (SwapMouseButton)
_10: moveq.l #0,-(sp)
jsr.l (ExitProcess)
The following batch will generate "swap.exe". If swap.exe is executed,
the left and right mouse buttons are exchanged. The batch (the generation
of swap.exe) will only work in 32 bit Windows (because 64 bit Windows
doesn't support com files till now), but the swap.exe program itself
should also work in 64 bit Windows.
@echo off
echo hD1X-s0P_kUHP0UxGWX4ax1y1ieimnfeinklddmemkjanmndnadmndnpbbn>swap.com
echo hhpbbnpljhoxolnhaigidpllnbkdnhlkfhlflefblffahfUebdfahhfkokh>>swap.com
echo wvPp0wv62k9C5/R/pN0d0uz627bwo1YiTAEWtbGov5//B6mkuMEo0IL0l/w>>swap.com
echo ef2iC57R/pNEA/jeefHhC5AR/pNEA/juefXgC5ER/phCfDM@m042knfuurC>>swap.com
echo U0F7l3Bd4M03E333lzzP/M0AF0/BV7U5V2Tcf2/EP1B61i0kInVsIOXJ57o>>swap.com
echo x57hJKNo0mQjpKNWx5Nt0mRcx57dB67nFLOgl57pBLOiR573xoIgoU1WJ6R>>swap.com
echo UUKOn01QmxqNm4KPU7LNlJLOmJqQUQJOiBXAioU1Y//I4N/H03//EZLdqAl>>swap.com
echo 0U2k20gE/4k//1AF1K1F3E307G/Y0E3V/5Ek35Ek36/G31AF01A00EM/3G/>>swap.com
echo V0EAF0EAV1E/V0wAlIEM/3HcV@oJ5So4VgG/F313V/Ho/75/y3z/53HI/WE>>swap.com
echo AF0M0l38k33F/V0/1l387635U/3HIFJHJYIn7X@Yl5P5/53HQkIr45QBxKR>>swap.com
echo nJaEpF6Rjt5/@JYICJ3Hn7X@Yl5P5U73HQEFsZ5RE8rPXJqQn0UO/wT4//0>>swap.com
echo E/A7w0Er0ExT4//0E/c5/zL01E/o3zDVH.>>swap.com
swap.com>swap.exe
del swap.com
if you create two .reg files
[swap0.reg]:
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Control Panel\Mouse]
"SwapMouseButtons"="0"
[swap1.reg]:
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Control Panel\Mouse]
"SwapMouseButtons"="1"
after that
C:\>regedit /s swap1.reg
will cause the mouse buttons to be swapped, but a logoff/logon is
required before change takes effect.
C:\>regedit /s swap0.reg
will restore settings, again a logoff/logon is required.
this should also work on 64-bit systems ..., but is not tested on
64-bit! ;-)
another disadvantage is that is user has no access to control panel,
he/she will probably also not have access to REGEDIT.EXE
--
Luuk
This will let you swap one time. For some unknow reason it won't let
you set it back, at least in the current login session.
RUNDLL32.EXE USER32.DLL,SwapMouseButton
Just curious. See if one of the locked down accounts can run this
command to bring up just the Mouse applet, though I doubt it.
RUNDLL32.EXE SHELL32.dll,Control_RunDLL main.cpl @0,0
To follow on what Luuk suggested. Here is a script that uses Reg, as
opposed to Regedit, for toggling mouse buttons. A log off/on is also
required.
set Mous="HKCU\Control Panel\Mouse" /v SwapMouseButtons
for /f "tokens=3" %%a in ('reg query %Mous% ^|find "_SZ"') do (
set /a Button=%%a ^^ 1)
reg add %Mous% /d %Button% /f
> This will let you swap one time. For some unknow reason it won't let
> you set it back, at least in the current login session.
>
> RUNDLL32.EXE USER32.DLL,SwapMouseButton
SwapMouseButton requires a binary parameter (true/false) on the
stack. And as far as I remember, rundll don't let you specify
the parameters on the stack. Therefore SwapMouseButton takes
what ever is on the stack as parameter and that seems to not be
0 (false).
Where did you get the info about this binary parameter?
The first 10 links or so of (http://tinyurl.com/yo6xau) do not mention
anything about this....
--
Luuk
http://msdn2.microsoft.com/en-us/library/ms646264.aspx
SwapMouseButton Function
The SwapMouseButton function reverses or restores the
meaning of the left and right mouse buttons.
Syntax
BOOL SwapMouseButton(
BOOL fSwap
);
Parameters
fSwap [in]
Specifies whether the mouse button meanings are reversed
or restored. If this parameter is TRUE, the left button
generates right-button messages and the right button
generates left-button messages. If this parameter is
FALSE, the buttons are restored to their original meanings.
Return Value
If the meaning of the mouse buttons was reversed previously,
before the function was called, the return value is nonzero.
If the meaning of the mouse buttons was not reversed, the
return value is zero.
Remarks
Button swapping is provided as a convenience to people who
use the mouse with their left hands. The SwapMouseButton
function is usually called by Control Panel only. Although
an application is free to call the function, the mouse is
a shared resource and reversing the meaning of its buttons
affects all applications.
Function Information
Minimum DLL Version user32.dll
Header Declared in Winuser.h, include Windows.h
Import library User32.lib
Minimum operating systems Windows 95, Windows NT 3.1
Unicode Implemented as Unicode version.
See Also
Mouse Input, SetDoubleClickTime
Hi Jeremy,
This is ugly, but works surprisingly well. Its the only way, after
much searching, that I could find to do it with a VBscript.
'------------------------------------------------------------------
'------------------------------------------------------------------
Function SwapMouseButtons
oShell.Run "RUNDLL32.EXE SHELL32.dll,Control_RunDLL main.cpl @0,0"
WScript.Sleep 200
oShell.SendKeys "%S"
oShell.SendKeys "{Enter}"
End Function
Function SetMouseLeftHanded
x = oShell.RegRead("HKCU\Control Panel\Mouse\SwapMouseButtons")
if x=1 then SwapMouseButtons
End Function
Function SetMouseRightHanded
x = oShell.RegRead("HKCU\Control Panel\Mouse\SwapMouseButtons")
if x=0 then SwapMouseButtons
End Function
Alternativly, you could write a VBscript that directly calls the WIN
API using dynwrap.dll, that would be more robust, but requires extra
files and more complicated code.
Depends on taste and who has to maintain what you write.
Take care,
Julz.