Link to home
Start Free TrialLog in
Avatar of G3NOCIDE
G3NOCIDE

asked on

kill sticky keys window in VB

hows it

I need to find away to either disable sticky keys only while my program is running, or kill the process before it has a chance to pop up on top. At this stage I would even settle for hiding the window.
I have been searching for a couple of days and so far all I have come up with is to disable it in the registry, which requires a reboot or possibly a log off for it to take effect, so that’s no good.
The program is written in VB 6 and will be running on xp (maybe 2k if it works sweet).

Any help will be much appreciated

Cheers
geno
Avatar of Discofish
Discofish

You'll need to set a key in the registry.

HKEY_CURRENT_USER\Control Panel\Accessibility\StickeyKeys\Flags

Set it to 506.  You might have to restart the computer, not sure on this one. You'll need the win32 API registry functions to do this. There should be a text file somewhere in the Visual Studio installation that details the API fucntions (VPAPI.txt or something like that).  I think the following will do it for you.  Check the msdn for explanations.

Private Declare Function RegOpenKeyEx Lib "advapi32" Alias "RegOpenKeyExA" ( _
    ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, _
    ByVal samDesired As Long, ByRef phkResult As Long) As Long


Private Declare Function RegQueryValueEx Lib "advapi32" Alias "RegQueryValueExA" ( _
    ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, _
    ByRef lpType As Long, ByVal lpData As String, ByRef lpcbData As Long) As Long


Private Declare Function RegCloseKey Lib "advapi32" (ByVal hKey As Long) As Long
    ' Note that if you declare the lpData pa
    '     rameter as String in RegSetValueEx, you
    '     must pass it ByVal.


Private Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" ( _
    ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, _
    ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long


Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" ( _
    ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long


Private Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" ( _
    ByVal hKey As Long, ByVal lpValueName As String) As Long


Private Declare Function RegDeleteKey Lib "advapi32.dll" Alias "RegDeleteKeyA" ( _
    ByVal hKey As Long, ByVal lpSubKey As String) As Long


Avatar of G3NOCIDE

ASKER

i have already tried doing it in the registry, and the effects dont happen until a reboot or login. which is no good because i need sticky keys to disable only when my program is running. I cant expect the user to reboot all the time so they can use sticky keys if the have to.

cheers
geno  
ASKER CERTIFIED SOLUTION
Avatar of Discofish
Discofish

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial