1. Controling the speed of the mouse - this code does not work.
- Posted by penpal0andrew May 06, 2009
- 889 views
- Last edited May 07, 2009
The reason why I want to be able to control the speed of the mouse, is because part of my application involves what I call banding ellipses, and maybe a user would have a reason for fine tuning it. One idea is to use the arrow keys. But it occurred to me, that one should be able to change the speed of the mouse programatically, and not just in the control panel. After some research, I came up with this code. I am using Windows XP Home SP3.
include Win32Lib.ew without warning constant Window1 = createEx( Window, "Test change mouse speed", 0, 0, 0, 800, 600, 0, 0 ) integer speed_toggle -- boolean integer orig_mouse_speed atom gwsMem speed_toggle = w32False gwsMem = allocate(4) VOID = w32Func(xSystemParametersInfo,{SPI_GETMOUSESPEED,0,gwsMem,0}) orig_mouse_speed = peek4u(gwsMem) procedure Screen_keydown(integer Self, integer Event, sequence Params) -- Application hot key detector if Params[1] = VK_F12 then if and_bits( Params[2], ControlMask ) then -- control F12 to toggle mouse speed if speed_toggle then poke(gwsMem, int_to_bytes(orig_mouse_speed)) else poke(gwsMem, int_to_bytes(1)) end if VOID = w32Func(xSystemParametersInfo,{SPI_SETMOUSESPEED,0,gwsMem,0}) speed_toggle = not speed_toggle VOID = w32Func(xSystemParametersInfo,{SPI_GETMOUSESPEED,0,gwsMem,0}) VOID = message_box(sprintf("Mouse Speed is now %d",peek4u(gwsMem)),"Test", #0) end if end if end procedure setHandler(Screen, w32HKeyDown, routine_id("Screen_keydown")) WinMain( Window1,Normal )
Andy
2. Re: Controling the speed of the mouse - this code does not work.
- Posted by doncole2009 May 07, 2009
- 904 views
Hello Andy,
I put ?9/0 down by your message box and it never gets there.
Don Cole
3. Re: Controling the speed of the mouse - this code does not work.
- Posted by penpal0andrew May 07, 2009
- 883 views
Hello Andy,
I put ?9/0 down by your message box and it never gets there.
Don Cole
The key to press is Ctrl and F12.
The point is that I want to change the mouse speed, and it does not change.
4. Re: Controling the speed of the mouse - this code does not work.
- Posted by ghaberek (admin) May 07, 2009
- 876 views
How about a different method? What if, while the user has the left key down, they can use the arrow keys to "nudge" the cursor one pixel at a time in any direction?
Just my $0.02.
-Greg
5. Re: Controling the speed of the mouse - this code does not work.
- Posted by doncole2009 May 07, 2009
- 906 views
procedure Screen_keydown(integer Self, integer Event, sequence Params) -- Application hot key detector if Params[1] = VK_F12 then if and_bits( Params[2], ControlMask ) then -- control F12 to toggle mouse speed printf(1,"entry question speed_toggle=%d\n",{speed_toggle}) if speed_toggle then poke(gwsMem, int_to_bytes(10)) else poke(gwsMem, int_to_bytes(1)) end if VOID = w32Func(xSystemParametersInfo,{SPI_SETMOUSESPEED,0,gwsMem,0}) speed_toggle = not speed_toggle -- VOID = w32Func(xSystemParametersInfo,{SPI_GETMOUSESPEED,0,gwsMem,0}) VOID = message_box(sprintf("Mouse Speed is now %d",peek4u(gwsMem)),"Test", #0) orig_mouse_speed = peek4u(gwsMem) end if end if end procedure setHandler(Screen, w32HKeyDown, routine_id("Screen_keydown"))
changes the message_box and the orig_mouse_speed.
Don Cole
6. Re: Controling the speed of the mouse - this code does not work.
- Posted by penpal0andrew May 07, 2009
- 905 views
procedure Screen_keydown(integer Self, integer Event, sequence Params) -- Application hot key detector if Params[1] = VK_F12 then if and_bits( Params[2], ControlMask ) then -- control F12 to toggle mouse speed printf(1,"entry question speed_toggle=%d\n",{speed_toggle}) if speed_toggle then poke(gwsMem, int_to_bytes(10)) else poke(gwsMem, int_to_bytes(1)) end if VOID = w32Func(xSystemParametersInfo,{SPI_SETMOUSESPEED,0,gwsMem,0}) speed_toggle = not speed_toggle -- VOID = w32Func(xSystemParametersInfo,{SPI_GETMOUSESPEED,0,gwsMem,0}) VOID = message_box(sprintf("Mouse Speed is now %d",peek4u(gwsMem)),"Test", #0) orig_mouse_speed = peek4u(gwsMem) end if end if end procedure setHandler(Screen, w32HKeyDown, routine_id("Screen_keydown"))
changes the message_box and the orig_mouse_speed.
Don Cole
I do not get what you are telling me. If you comment out the getmousespeed, how will I know what the mouse speed is? That is not part of the functionality. It was placed there so I could confirm that I was not seeing any change in the mouse speed.
7. Re: Controling the speed of the mouse - this code does not work.
- Posted by doncole2009 May 08, 2009
- 907 views
procedure Screen_keydown(integer Self, integer Event, sequence Params) -- Application hot key detector if Params[1] = VK_F12 then if and_bits( Params[2], ControlMask ) then -- control F12 to toggle mouse speed printf(1,"entry question speed_toggle=%d\n",{speed_toggle}) if speed_toggle then poke(gwsMem, int_to_bytes(10)) else poke(gwsMem, int_to_bytes(1)) end if VOID = w32Func(xSystemParametersInfo,{SPI_SETMOUSESPEED,0,gwsMem,0}) speed_toggle = not speed_toggle -- VOID = w32Func(xSystemParametersInfo,{SPI_GETMOUSESPEED,0,gwsMem,0}) VOID = message_box(sprintf("Mouse Speed is now %d",peek4u(gwsMem)),"Test", #0) orig_mouse_speed = peek4u(gwsMem) end if end if end procedure setHandler(Screen, w32HKeyDown, routine_id("Screen_keydown"))
changes the message_box and the orig_mouse_speed.
Don Cole
I do not get what you are telling me. If you comment out the getmousespeed, how will I know what the mouse speed is? That is not part of the functionality. It was placed there so I could confirm that I was not seeing any change in the mouse speed.
For some reason it is changing back gwsMem to the orig_mouse_speed.
If you rem it out it won't do that.
Don Cole