Disable/Enable Windows key on the fly w/no reboot?

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
ukdboyd
Newbie
Posts: 11
Joined: Wed May 25, 2005 6:09 pm

Disable/Enable Windows key on the fly w/no reboot?

Post by ukdboyd » Mon Nov 26, 2007 7:47 pm

Is there any way to disable the Windows/Start Menu key via Macro Scheduler? And then re-enable it?

I know that there are a couple of registry tweaks that will do it, but it requires a reboot to activate.

Here's what I'm trying to accomplish: After a user logs into the computer, a special application runs from the Startup folder that covers the entire screen and requires input from the user. Until the user inputs their information they cannot use the computer. Problem is, the Windows key still works and therefore they have access to everything in the Start Menu. I want to be able to disable the Windows key until they have entered their info.

Any ideas?

Thank you!

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Tue Nov 27, 2007 9:20 pm

This won't make the winkeys non-functional but it will make them unusable. Use Onevent>KEY_DOWN,VK91 and VK92. The left and right winkey codes. When the user presses a winkey the menu pops up but the subroutine called by onevent immediately presses esc 30 times (or however many times you need to press it). The number of times isn't important as long as its enough to catch the menu and close it. Really only one well timed esc press is needed. This will stop the winkey from being used but what about ctrl+exc or alt+tab or alt+f4 or other hot keys the user could set up? We can't interupt key presses but we can similarly deal with their results. Have fun.

Sample:

Code: Select all

OnEvent>KEY_DOWN,VK91,0,WinKey
OnEvent>KEY_DOWN,VK92,0,WinKey

SRT>WinKey
Let>kk=0
Repeat>kk
  Add>kk,1
  Release LWinKey
  Release LWinKey
  Press Esc
  Wait>0.01
Until>kk,30
END>WinKey

Label>loop
wait>0.01
goto>loop

ukdboyd
Newbie
Posts: 11
Joined: Wed May 25, 2005 6:09 pm

Post by ukdboyd » Wed Nov 28, 2007 5:55 pm

That worked!! Thanks :D

I almost have this thing the way I want but it's not quite right. Here's what I have now:
  • Run Program>c:\program files\stats\complab.exe

    OnEvent>KEY_DOWN,VK91,0,WinKey
    OnEvent>KEY_DOWN,VK92,0,WinKey

    SRT>WinKey
    Let>kk=0
    Repeat>kk
    Add>kk,1
    Release LWinKey
    Release LWinKey
    Press Esc
    SetFocus>Comp*
    Wait>0.01
    Until>kk,30
    END>WinKey

    Label>WindowCheck
    GetWindowHandle>Comp*,hwnd
    LibFunc>User32,IsIconic,rI,hwnd
    LibFunc>User32,IsZoomed,rZ,hwnd
    If>rI=1
    GoTo>EndProgram
    Else
    If>rZ=1
    Goto>WindowCheck
    Endif
    Endif

    Label>loop
    wait>0.01
    goto>loop

    Label>EndProgram
    Press Shift
    Press ESC
    END>EndProgram
I want Complab.exe to run. SRT WinKey will kill any Windows Key presses and put the focus back on the Complab window (I think). Although that doesn't always seem to work.

After the user logs into Complab, that program minimizes itself. At that point. i want the script to stop, so that the user has access to the Windows keys again. That's the part that isn't quite right yet. The script never stops.

Any suggestions? Thanks again!

ukdboyd
Newbie
Posts: 11
Joined: Wed May 25, 2005 6:09 pm

Post by ukdboyd » Wed Nov 28, 2007 6:19 pm

I got this to work, if anyone is interested. Took out the Release LWinkey and Release RWinkey statements and reworked the focus app and kill script sections. Here's what I have now. Any streamlining suggestions would be appreciated.
  • Run Program>c:\program files\stats\complab.exe

    OnEvent>KEY_DOWN,VK91,0,WinKey
    OnEvent>KEY_DOWN,VK92,0,WinKey

    SRT>WinKey
    Let>kk=0
    Repeat>kk
    Add>kk,1
    Press ESC
    Wait>0.05
    GoSub>FocusApp
    Until>kk,5
    END>WinKey

    SRT>FocusApp
    SetFocus>Comp*
    End>FocusApp

    SRT>EndProgram
    Press Shift
    Press ESC
    End>EndProgram

    GoTo>WindowCheck

    Label>WindowCheck
    GetWindowHandle>Comp*,hwnd
    LibFunc>User32,IsIconic,rI,hwnd
    LibFunc>User32,IsZoomed,rZ,hwnd
    If>rI=1
    GoSub>EndProgram
    Else
    Goto>WindowCheck
    Endif

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Fri Jun 04, 2010 3:35 am

Here we are approaching three years later. I have a "streamlined" way to stop those pesky user key presses. Basically you just kill explorer.exe. When you're ready to give the computer back to the user you restart explorer.exe

Code: Select all

Run>taskkill /f /im explorer.exe

MDL>ok,  test all the button combinations you know and see if any work.

Run>explorer.exe
This works for me in WinXP, I have no idea if it will work in Vista or Win7.

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts