Controling the speed of the mouse - this code does not work.

new topic     » topic index » view thread      » older message » newer message

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

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu