View Full Version : O/T Mouse Settings.."Snap To"
Is there a way of getting straight to the SNAP TO toggle of the mouse/pointer options? I love having it on about 50% of the time, and HATE it the other 55%. When in Mastercam, I want to be able to toggle it on and off without having to open mouse properties, click the right tab, then click the toggle button.
I'm pretty sure that data is stored in the registry, but don't know where. If it IS there, I can write 2 reg files that will toggle it, then run those files from my quick launch.
Is this AT ALL possible? Or am I all wet?
TYIA
'Rekd
HuFlungDung 09-05-2003, 10:48 AM Try searching regedit for
SnapToDefaultButton
HKEY_LOCAL_MACHINE| SOFTWARE| MICROSOFT| WINDOWS NT| INIFILEMAPPING| WIN.INI| WINDOWS
There is a bunch of stuff in there to do with mouse.
I can change it in the Mouse Options dialog and it updates the registry. I can't change the registry and have it update. Mayhaps there's another setting that goes with it?
'Rekd
ullbergm 09-08-2003, 10:23 AM Originally posted by Rekd
I can change it in the Mouse Options dialog and it updates the registry. I can't change the registry and have it update. Mayhaps there's another setting that goes with it?
It is the correct registry key, but you need to send a WM_SETTINGSCHANGE for it to take effect.
I wrote a small commandline utility that will let you change the snap to setting without rebooting.
http://ullberg.us/files/MouseControl.zip
usage:
MouseControl.exe /snaptodefault [true|false]
if you run it without any command line parameters at all it will toggle the setting.
disclaimer:
I wrote this in 5 minutes, it looks like it is working fine for me on windows 2000, but there may be bugs. Some other restrictions are that the command line parameters need to be in lower case and you also need the .NET framework 1.1 installed.
Let me know if you dont want to install the .net framework and i'll write a c++ version instead.
hope this helps
edit: Changed the link to a zipfile
ullbergm 09-08-2003, 11:13 AM Updated the zipfile with a c++ version of the program.
This version has even less features.. all it does it toggle the setting and exit. No feedback and no command line parameters. I can add that later if you want. (didnt want to spend a lot of time on it if you already had the .net framework installed)
Thanks ullbergm. That works.
Question; I do VB6 programmin, where do you send the WM_SETTINGSCHANGE message? Can I do this with VB6?
'Rekd
ullbergm 09-08-2003, 11:28 AM Originally posted by Rekd
Thanks ullbergm. That works.
Question; I do VB6 programmin, where do you send the WM_SETTINGSCHANGE message? Can I do this with VB6?
It's been a while since i did VB.. I may take a look at it later on today, but here is the basic idea:
You need to call a windows api called SystemParametersInfo
BOOL SystemParametersInfo(
UINT uiAction,
UINT uiParam,
PVOID pvParam,
UINT fWinIni
);
I dont remember how to import external dll's in vb right now but after you import it you call it with the following parameters:
Get the value:
uiAction = SPI_GETSNAPTODEFBUTTON (0x005F)
uiParam = 0
pvParam = reference to a integer
fWinIni = 0
if pvParam is 1 it's enabled, 0 disabled
Set the value:
uiAction = SPI_SETSNAPTODEFBUTTON (0x0060
uiParam = 1 or 0 (depending on if you want to enable or disable it)
pvParam = reference to a integer (may be able to set this to null, not sure, dont use it anyways..)
fWinIni = SPIF_SENDCHANGE (0x0002)
All i did was to read the previous value and set it to the opposite to toggle it.
Here is the c# code to give you some idea of what it looks like:
public static bool SnapToDefault
{
get
{
int bRetValue = 0;
SystemParametersInfo(
(uint)SPIActions.SPI_GETSNAPTODEFBUTTON,
0,
ref bRetValue,
0
);
return bRetValue == 1;
}
set
{
int bRetValue = 0;
int NewValue = (value ? 1 : 0);
SystemParametersInfo(
(uint)SPIActions.SPI_SETSNAPTODEFBUTTON,
(uint) NewValue,
ref bRetValue,
(uint)SPIWinINIFlags.SPIF_SENDCHANGE
);
}
}
ullbergm 09-08-2003, 11:31 AM one more thing, i didnt include any error checking at all. you should check the return value of SystemParametersInfo it returns a boolean telling you wether the call was successful or not. If it fails you should call GetLastError
Here is the MSDN page explaining the function:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/systemparametersinfo.asp
I got it to work in VB.
This is just running it on a form with
2 command buttons. I'm going to set
up a tray icon to toggle it.
Thanks again for your help! :D
Option Explicit
'Add 2 command Buttons...
Private Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, ByRef lpvParam As Any, ByVal fuWinIni As Long) As Long
Private Const SETSNAPTODEFBUTTON = &H60
Private Const GETSNAPTODEFBUTTON = &H5F
Private Const SENDWININICHANGE = &H2
Private Function isSnapToDefault() As Boolean
Dim ilpvParam&
Call SystemParametersInfo(GETSNAPTODEFBUTTON, 0, ilpvParam&, 0)
isSnapToDefault = ilpvParam&
End Function
Private Function SetSnapToDefault(ByVal SnapToDefault As Boolean)
Call SystemParametersInfo(SETSNAPTODEFBUTTON, SnapToDefault, 0, SENDWININICHANGE)
End Function
Private Sub Command1_Click()
MsgBox "Snap is: " & isSnapToDefault
End Sub
Private Sub Command2_Click()
SetSnapToDefault (Not isSnapToDefault)
End Sub
'Rekd
ullbergm 09-10-2003, 01:33 PM Originally posted by Rekd
I got it to work in VB.
This is just running it on a form with
2 command buttons. I'm going to set
up a tray icon to toggle it.
Thanks again for your help! :D
you're welcome
glad i could help
I made this with ullbergm's help and some help from Extreme Visual Basic Forum. If anyone wants, you're welcome to it.
What I do (for now, until I set it up to run from the tray), is put a shortcut in my quick launch and toggle it on and off when I need to.
:edit:
BTW, this will only work on OS's that support this mouse function, and may only work on XP and 2k machines.
:/edit:
'Rekd
ullbergm 09-18-2003, 01:55 PM Originally posted by Rekd
I made this with ullbergm's help and some help from Extreme Visual Basic Forum. If anyone wants, you're welcome to it.
What I do (for now, until I set it up to run from the tray), is put a shortcut in my quick launch and toggle it on and off when I need to.
Cool, isnt it satisfying to write something that is actually useful?
I do software development for a living and it's great when you can see people actually use what you wrote and that it is making their work easier.
:edit:
BTW, this will only work on OS's that support this mouse function, and may only work on XP and 2k machines.
:/edit:
'Rekd
This is what microsoft says in the sdk documentation.. Not sure if it actually works in practice or not.. but they say it will work all the way back to Windows 95..
Requirements
Client: Included in Windows XP, Windows 2000 Professional, Windows NT Workstation, Windows Me, Windows 98, and Windows 95.
Cool, isnt it satisfying to write something that is actually useful?
Hell yes.
I've done some neet things for the 'machining' industry.
My very first project, (4-5 years ago in BASIC, since converted to Visual Basic), is called M98 Px. It converts NC files to run multiple parts using sub programs. It was, for a first time programmer, very intense.
I've also made programs for doing file transfers to and from CNC machines, a speed-feed-sfpm-blah-blah-drill point depth calculator, a very small profile MM to English calculator, a util to convert G83 cycles to use I J and K for deep hole drilling, utils for numbering NC files, and a few others.
It's great being able to make something you need/want instead of having to find and/or buy it.
'Rekd
ullbergm 09-18-2003, 02:20 PM Originally posted by Rekd
Hell yes.
It's great being able to make something you need/want instead of having to find and/or buy it.
'Rekd
Exactly.
Maybe that's why the CNC stuff interests me as well..
Cool stuff
|
|