Skip to content

Instantly share code, notes, and snippets.

@400-17
Last active October 27, 2016 00:13
Show Gist options
  • Save 400-17/471663474af1952c75cd3380fb5d38d7 to your computer and use it in GitHub Desktop.
Save 400-17/471663474af1952c75cd3380fb5d38d7 to your computer and use it in GitHub Desktop.
cortana command (for cmd)
#include "stdafx.h"
#include<windows.h>
int main()
{
INPUT key;
LPINPUT lpkey = &key;
WORD wkey;
//set LWIN
wkey = VK_LWIN;
lpkey->type = INPUT_KEYBOARD;
lpkey->ki.wVk = wkey;
lpkey->ki.wScan = (WORD)MapVirtualKey(wkey, 0);
lpkey->ki.dwFlags = 0;
lpkey->ki.dwExtraInfo = 0;
lpkey->ki.time = 0;
//send LWIN
SendInput((UINT)1, lpkey, sizeof(INPUT));
//send shift
wkey = VK_SHIFT;
lpkey->type = INPUT_KEYBOARD;
lpkey->ki.wVk = wkey;
lpkey->ki.wScan = (WORD)MapVirtualKey(wkey, 0);
lpkey->ki.dwFlags = 0;
lpkey->ki.dwExtraInfo = 0;
lpkey->ki.time = 0;
//send shift
SendInput((UINT)1, lpkey, sizeof(INPUT));
//set C
wkey = 'C';
lpkey->type = INPUT_KEYBOARD;
lpkey->ki.wVk = wkey;
lpkey->ki.wScan = (WORD)MapVirtualKey(wkey, 0);
lpkey->ki.dwFlags = 0;
lpkey->ki.dwExtraInfo = 0;
lpkey->ki.time = 0;
//send C
SendInput((UINT)1, lpkey, sizeof(INPUT));
//set flag
lpkey->ki.dwFlags = KEYEVENTF_KEYUP;
//release C
SendInput((UINT)1, lpkey, sizeof(INPUT));
//reset SHIFT
wkey = VK_SHIFT;
lpkey->type = INPUT_KEYBOARD;
lpkey->ki.wVk = wkey;
lpkey->ki.wScan = (WORD)MapVirtualKey(wkey, 0);
lpkey->ki.dwExtraInfo = 0;
lpkey->ki.time = 0;
//release SHIFT
SendInput((UINT)1, lpkey, sizeof(INPUT));
//reset LWIN
wkey = VK_LWIN;
lpkey->type = INPUT_KEYBOARD;
lpkey->ki.wVk = wkey;
lpkey->ki.wScan = (WORD)MapVirtualKey(wkey, 0);
lpkey->ki.dwExtraInfo = 0;
lpkey->ki.time = 0;
//release LWIN
SendInput((UINT)1, lpkey, sizeof(INPUT));
printf("call cortana...");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment