I am trying to automatically run a program every afternoon through the Windows Scheduler. The program must send keystrokes to the desktop. The program runs fine as long as the computer is not "locked" (i.e., the screen that reads "Press Ctrl-Alt-Del to unlock this computer") is not showing. To unlock the computer, I am trying to send the Ctrl+Alt+Del key combination to the screen to bring up the "Unlock Computer" dialog box and then send password keystrokes to that screen. I have found C code to accomplish this. However, I am not a C programmer. I have included the code below. Will someone please show me how to convert this code to Visual FoxPro. Thank you very much!!!!
// Static routine used to fool Winlogon into thinking CtrlAltDel was pressed
void *
SimulateCtrlAltDelThreadFn(void *context)
{
HDESK old_desktop = GetThreadDesktop(GetCurrentThreadId());
// Switch into the Winlogon desktop
if (!vncService::SelectDesktop("Winlogon"))
{
vnclog.Print(LL_INTERR, VNCLOG("failed to select logon desktop\n"));
return FALSE;
}
vnclog.Print(LL_ALL, VNCLOG("generating ctrl-alt-del\n"));
// Fake a hotkey event to any windows we find there.... :(
// Winlogon uses hotkeys to trap Ctrl-Alt-Del...
PostMessage(HWND_BROADCAST, WM_HOTKEY, 0, MAKELONG(MOD_ALT | MOD_CONTROL, VK_DELETE));
// Switch back to our original desktop
if (old_desktop != NULL)
vncService::SelectHDESK(old_desktop);
return NULL;
}
Brent L. Hackett