586,075 active members*
4,283 visitors online*
Register for free
Login
IndustryArena Forum > Community Club House > O/T Mouse Settings.."Snap To"
Results 1 to 14 of 14
  1. #1
    Join Date
    Apr 2003
    Posts
    1876

    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
    Matt
    San Diego, Ca

    ___ o o o_
    [l_,[_____],
    l---L - □lllllll□-
    ( )_) ( )_)--)_)

    (Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)

  2. #2
    Join Date
    Mar 2003
    Posts
    4826
    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.
    First you get good, then you get fast. Then grouchiness sets in.

    (Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)

  3. #3
    Join Date
    Apr 2003
    Posts
    1876
    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
    Matt
    San Diego, Ca

    ___ o o o_
    [l_,[_____],
    l---L - □lllllll□-
    ( )_) ( )_)--)_)

    (Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)

  4. #4
    Join Date
    Jul 2003
    Posts
    109
    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

  5. #5
    Join Date
    Jul 2003
    Posts
    109
    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)

  6. #6
    Join Date
    Apr 2003
    Posts
    1876
    Thanks ullbergm. That works.

    Question; I do VB6 programmin, where do you send the WM_SETTINGSCHANGE message? Can I do this with VB6?

    'Rekd
    Matt
    San Diego, Ca

    ___ o o o_
    [l_,[_____],
    l---L - □lllllll□-
    ( )_) ( )_)--)_)

    (Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)

  7. #7
    Join Date
    Jul 2003
    Posts
    109
    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
    );
    }
    }

  8. #8
    Join Date
    Jul 2003
    Posts
    109
    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/de...metersinfo.asp

  9. #9
    Join Date
    Apr 2003
    Posts
    1876
    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!

    PHP Code:
    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
    Matt
    San Diego, Ca

    ___ o o o_
    [l_,[_____],
    l---L - □lllllll□-
    ( )_) ( )_)--)_)

    (Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)

  10. #10
    Join Date
    Jul 2003
    Posts
    109
    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!
    you're welcome
    glad i could help

  11. #11
    Join Date
    Apr 2003
    Posts
    1876

    Update..

    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
    Attached Files Attached Files
    Matt
    San Diego, Ca

    ___ o o o_
    [l_,[_____],
    l---L - □lllllll□-
    ( )_) ( )_)--)_)

    (Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)

  12. #12
    Join Date
    Jul 2003
    Posts
    109

    Re: Update..

    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.

  13. #13
    Join Date
    Apr 2003
    Posts
    1876
    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
    Matt
    San Diego, Ca

    ___ o o o_
    [l_,[_____],
    l---L - □lllllll□-
    ( )_) ( )_)--)_)

    (Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)

  14. #14
    Join Date
    Jul 2003
    Posts
    109
    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

Similar Threads

  1. Mutilated mouse DRO (using Microsoft PS2 Mice)
    By wcarrothers in forum CNC Machine Related Electronics
    Replies: 6
    Last Post: 03-30-2009, 05:37 PM
  2. Fun with steppers (From serial mouse to stepper)
    By Konstantin in forum CNC Machine Related Electronics
    Replies: 0
    Last Post: 07-21-2004, 06:41 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •