#include #include "resource.h" bool IsKeyPressed(int iKey) { return ((GetAsyncKeyState(iKey) & 1) == 1); } void Start() { int i; MessageBox(0,"Started!", 0,MB_OK); Sleep(3000); do { keybd_event('A', (BYTE) MapVirtualKey('A', 0), 0, 0); Sleep(500); }while( ( IsKeyPressed(VK_F2 ) == 0)); } void Close() { MessageBox(0,"Closed!", 0,MB_OK); } LRESULT CALLBACK DlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam){ switch(msg) { case WM_INITDIALOG: SetTimer(hwnd,0,500,0); return true; case WM_LBUTTONDOWN: { ReleaseCapture(); SendMessage(hwnd,WM_NCLBUTTONDOWN,HTCAPTION,0); } break; case WM_TIMER: { if(IsKeyPressed(VK_F1)) { Start(); } if(IsKeyPressed(VK_F2)) { Close(); } } case WM_COMMAND: switch(LOWORD(wParam)) { } break; case WM_CLOSE: EndDialog(hwnd,0); break; default: return FALSE; } return TRUE; } int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd){ return DialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_DIALOG1), NULL, reinterpret_cast(DlgProc), NULL); }