Search code examples
vb6

How Do I Turn On/Off X-Mouse in Tweak UI?


I'm attempting to create a VB6 executable (not sure of the proper syntax) that will toggle the X-Mouse option in Tweak UI under Windows 98SE. Ideally, I would like to have two scripts - one that turns it off (regardless of its state) and one that turns it on (again, regardless of its state).

I have been able to open the TweakUI control panel with the code below.

Private Sub Form_Load()
Call Shell("rundll32.exe shell32.dll,Control_RunDLL tweakui.cpl", vbNormalFocus)
End Sub

enter image description here

If possible, I would like it to do it without opening the TweakUI control panel.

As far as I can tell, changing the registry setting doesn't work as I would have to reboot the computer for that to take effect.

I have Registry Monitor 7.04 running. It captures the following:

Path: C:\WINDOWS\RUNDLL32.EXE
Command Line: "C:\WINDOWS\RUNDLL32.EXE" "C:\WINDOWS\SYSTEM\TWEAKUI.CPL", Tweak UI
Other: hKey: 0xC2A066F0

Honestly, I'm not sure how to move forward.

Not sure the best way to show progress on this, I'll just edit.

This code is very close.

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
Const SPI_SETACTIVEWINDOWTRACKING = 4097

'Click on this button to Activate XMouse
Private Sub Command1_Click()
SystemParametersInfo SPI_SETACTIVEWINDOWTRACKING, 0, True, 0
End Sub

'Click on this button to Deactivate XMouse
Private Sub Command2_Click()
SystemParametersInfo SPI_SETACTIVEWINDOWTRACKING, 0, False, 0
End Sub

Button 1 works correctly and Activates XMouse. But button two does not deactivate it.


Solution

  • Thank you to all of the input. I was able to solve this problem.

    Private Declare Function SystemParametersInfo Lib "user32" Alias _
    "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, _
    ByVal lpvParam As Boolean, ByVal fuWinIni As Long) As Long
    Const SPI_SETACTIVEWINDOWTRACKING = 4097
    
    
    Private Sub Command1_Click()
    retVal = SystemParametersInfo(SPI_SETACTIVEWINDOWTRACKING, 0, True, 0)
    End Sub
    
    Private Sub Command2_Click()
    retVal = SystemParametersInfo(SPI_SETACTIVEWINDOWTRACKING, 0, False, 0)
    End Sub
    

    In addition to the help here, I stumbled upon a few gems that gave me what I needed. Control the mouse speed under Windows 98 / 2000 and Controling Active Window Tracking

    A couple things of note. I had to include this or else nothing happened:

    Const SPI_SETACTIVEWINDOWTRACKING = 4097
    

    Also, the 3rd parameter was

    ByRef lpvParam As Boolean
    

    Instead of

    ByVal lpvParam As Boolean
    

    I was passing a pointer to a pointer instead of a pointer to a value