CNCzone.com-The Largest Machinist Community on the net!



Home Page Mark Forums Read Today's Posts My Replies Classifieds Reviews Photo Gallery Web Links Share Files Advertise With Us Ad List
Go Back   CNCzone.com-The Largest Machinist Community on the net! > Events, Product Announcements and More > CNCzone Club House


CNCzone Club House Discuss everything in between CNC. THIS IS NOT A TRASH BIN.


This forum is sponsored by:

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 09-05-2003, 09:09 AM
Rekd's Avatar
Community Moderator
 
Join Date: Apr 2003
Location: teh Debug Window
Posts: 1,877
Rekd is on a distinguished road
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)
Tweet this Post!Share on Facebook
Reply With Quote

  #2  
Old 09-05-2003, 10:48 AM
HuFlungDung's Avatar
Moderator
 
Join Date: Mar 2003
Location: Canada
Posts: 4,823
HuFlungDung is on a distinguished road
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)
Tweet this Post!Share on Facebook
Reply With Quote

  #3  
Old 09-05-2003, 11:22 AM
Rekd's Avatar
Community Moderator
 
Join Date: Apr 2003
Location: teh Debug Window
Posts: 1,877
Rekd is on a distinguished road
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)
Tweet this Post!Share on Facebook
Reply With Quote

  #4   Ban this user!
Old 09-08-2003, 10:23 AM
 
Join Date: Jul 2003
Location: Owensboro, Kentucky
Posts: 109
ullbergm is on a distinguished road
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
Tweet this Post!Share on Facebook
Reply With Quote

  #5   Ban this user!
Old 09-08-2003, 11:13 AM
 
Join Date: Jul 2003
Location: Owensboro, Kentucky
Posts: 109
ullbergm is on a distinguished road
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)
Tweet this Post!Share on Facebook
Reply With Quote

Sponsored Links
  #6  
Old 09-08-2003, 11:17 AM
Rekd's Avatar
Community Moderator
 
Join Date: Apr 2003
Location: teh Debug Window
Posts: 1,877
Rekd is on a distinguished road
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)
Tweet this Post!Share on Facebook
Reply With Quote

  #7   Ban this user!
Old 09-08-2003, 11:28 AM
 
Join Date: Jul 2003
Location: Owensboro, Kentucky
Posts: 109
ullbergm is on a distinguished road
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
);
}
}
Tweet this Post!Share on Facebook
Reply With Quote

  #8   Ban this user!
Old 09-08-2003, 11:31 AM
 
Join Date: Jul 2003
Location: Owensboro, Kentucky
Posts: 109
ullbergm is on a distinguished road
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
Tweet this Post!Share on Facebook
Reply With Quote

  #9  
Old 09-10-2003, 12:27 PM
Rekd's Avatar
Community Moderator
 
Join Date: Apr 2003
Location: teh Debug Window
Posts: 1,877
Rekd is on a distinguished road
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 LongByVal uParam As LongByRef lpvParam As AnyByVal 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(GETSNAPTODEFBUTTON0ilpvParam&, 0)
  
isSnapToDefault ilpvParam&
End Function

Private Function 
SetSnapToDefault(ByVal SnapToDefault As Boolean)
   
Call SystemParametersInfo(SETSNAPTODEFBUTTONSnapToDefault0SENDWININICHANGE)
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)
Tweet this Post!Share on Facebook
Reply With Quote

  #10   Ban this user!
Old 09-10-2003, 01:33 PM
 
Join Date: Jul 2003
Location: Owensboro, Kentucky
Posts: 109
ullbergm is on a distinguished road
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
Tweet this Post!Share on Facebook
Reply With Quote

Sponsored Links
  #11  
Old 09-18-2003, 01:39 PM
Rekd's Avatar
Community Moderator
 
Join Date: Apr 2003
Location: teh Debug Window
Posts: 1,877
Rekd is on a distinguished road
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
File Type: zip snap to default.zip‎ (4.4 KB, 52 views)
__________________
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)
Tweet this Post!Share on Facebook
Reply With Quote

  #12   Ban this user!
Old 09-18-2003, 01:55 PM
 
Join Date: Jul 2003
Location: Owensboro, Kentucky
Posts: 109
ullbergm is on a distinguished road
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.
Tweet this Post!Share on Facebook
Reply With Quote

Reply




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Mutilated mouse DRO (using Microsoft PS2 Mice) wcarrothers General Electronics Discussion 6 03-30-2009 12:37 PM
Fun with steppers (From serial mouse to stepper) Konstantin General Electronics Discussion 0 07-21-2004 01:41 PM




All times are GMT -5. The time now is 05:32 AM.





Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
Content Relevant URLs by vBSEO
Template-Modifications by TMS

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353