Boot Straight to Desktop in Windows 8

Thu, Oct 11, 2012 2-minute read

I’ve written a little program that sends a “left Windows key pressed” key event which brings you to the desktop. All you have to do is start the .exe file after logging in.

You can do this by using either the task scheduler or the windows Startup folder (C:\Users\Username\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup).

However the task scheduler should be a bit faster.

How to use the task scheduler:

  1. Open the task scheduler and click on “Create Task…” on the right.

  2. Choose a name and go to Triggers.

  3. Click on “New” and choose “Begin the task: At Log on”.

  4. Go to Actions, click on “New”, browse for the .exe file and select it.

  5. If you are on a laptop, go to Conditions and deselect “Start the task only if the computer is on AC power”.

This should be all.

Here is the zipped .exe file:

 WinKey.zip

Here is the C++ source code:

#include </p>
<p>int main() {
	// This is the structure for the key input event
	INPUT keyevent;
	// Set the key event
	keyevent.type = INPUT_KEYBOARD;
	// Press the left Windows key
	keyevent.ki.wVk = 0x5B; // virtual-key code for the key http://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx
	keyevent.ki.dwFlags = 0; // 0 for key press
	SendInput(1, &keyevent, sizeof(INPUT));
	// Release the key
	keyevent.ki.dwFlags = KEYEVENTF_KEYUP; // KEYEVENTF_KEYUP for key release
	SendInput(1, &keyevent, sizeof(INPUT));
	return 0;
}

Thanks to batchloaf for the SendInput tutorial.