Advertisement
Guest User

Untitled

a guest
Oct 10th, 2019
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.48 KB | None | 0 0
  1. #include <windows.h>
  2.  
  3. #ifndef VK_MEDIA_NEXT_TRACK
  4. #define VK_MEDIA_NEXT_TRACK 0xB0
  5. #endif
  6. #ifndef VK_MEDIA_PREV_TRACK
  7. #define VK_MEDIA_PREV_TRACK 0xB1
  8. #endif
  9. #ifndef VK_MEDIA_STOP
  10. #define VK_MEDIA_STOP 0xB2
  11. #endif
  12. #ifndef VK_MEDIA_PLAY_PAUSE
  13. #define VK_MEDIA_PLAY_PAUSE 0xB3
  14. #endif
  15.  
  16. /**
  17. */
  18.  
  19. HINSTANCE hInst;
  20. TCHAR szTitle[] = "ATKMEDIA";
  21. TCHAR szWindowClass[] = "ATKMEDIA";
  22.  
  23. ATOM MRegisterClass(HINSTANCE hInstance);
  24. BOOL InitInstance(HINSTANCE, int);
  25. LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
  26.  
  27. int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
  28. {
  29. //int main(int argc, char** argv)
  30. //{
  31. // HINSTANCE hInstance = 0;
  32. // HINSTANCE hPrevInstance = 0;
  33. // LPTSTR lpCmdLine = 0;
  34. // int nCmdShow = SW_SHOWNORMAL;
  35.  
  36. MSG msg;
  37.  
  38. MRegisterClass(hInstance);
  39.  
  40. if (!InitInstance (hInstance, nCmdShow))
  41. {
  42. return FALSE;
  43. }
  44.  
  45. while (GetMessage(&msg, NULL, 0, 0))
  46. {
  47. TranslateMessage(&msg);
  48. DispatchMessage(&msg);
  49. }
  50.  
  51. return (int) msg.wParam;
  52. }
  53.  
  54. ATOM MRegisterClass(HINSTANCE hInstance)
  55. {
  56. WNDCLASSEX wcex;
  57.  
  58. wcex.cbSize = sizeof(WNDCLASSEX);
  59.  
  60. wcex.style = CS_HREDRAW | CS_VREDRAW;
  61. wcex.lpfnWndProc = WndProc;
  62. wcex.cbClsExtra = 0;
  63. wcex.cbWndExtra = 0;
  64. wcex.hInstance = hInstance;
  65. wcex.hIcon = 0;//LoadIcon(hInstance, MAKEINTRESOURCE(IDI_APPLICATION));
  66. wcex.hCursor = 0;
  67. wcex.hbrBackground = 0;
  68. wcex.lpszMenuName = 0;
  69. wcex.lpszClassName = szWindowClass;
  70. wcex.hIconSm = 0;//LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_APPLICATION));
  71.  
  72. return RegisterClassEx(&wcex);
  73. }
  74.  
  75. BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
  76. {
  77. HWND hWnd;
  78.  
  79. hInst = hInstance; // Store instance handle in our global variable
  80.  
  81. hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
  82. CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
  83.  
  84. if (!hWnd)
  85. {
  86. return FALSE;
  87. }
  88.  
  89. //ShowWindow(hWnd, nCmdShow);
  90. //UpdateWindow(hWnd);
  91.  
  92. return TRUE;
  93. }
  94.  
  95. void RunProc(LPSTR path) {
  96. STARTUPINFO si;
  97. PROCESS_INFORMATION pi;
  98.  
  99. ZeroMemory( &si, sizeof(si) );
  100. si.cb = sizeof(si);
  101. ZeroMemory( &pi, sizeof(pi) );
  102.  
  103. CreateProcess(NULL, path, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
  104.  
  105. WaitForSingleObject( pi.hProcess, INFINITE );
  106. CloseHandle( pi.hProcess );
  107. CloseHandle( pi.hThread );
  108. }
  109.  
  110. #define ATKMEDIA_MESSAGE 0x0917
  111. #define ATKMEDIA_PLAY 0x0002
  112. #define ATKMEDIA_STOP 0x0003
  113. #define ATKMEDIA_PREV 0x0005
  114. #define ATKMEDIA_NEXT 0x0004
  115. #define ATKMEDIA_CALC 0x002B
  116.  
  117. LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
  118. {
  119. char proc[] = "calc.exe";
  120. int wmId, wmEvent;
  121.  
  122. switch (message)
  123. {
  124. case WM_COMMAND:
  125. wmId = LOWORD(wParam);
  126. wmEvent = HIWORD(wParam);
  127.  
  128. switch (wmId)
  129. {
  130. case WM_CLOSE:
  131. DestroyWindow(hWnd);
  132. break;
  133.  
  134. case ATKMEDIA_MESSAGE:
  135.  
  136. switch(wmEvent)
  137. {
  138. case ATKMEDIA_PLAY:
  139. keybd_event(VK_MEDIA_PLAY_PAUSE, 0, 0, 0);
  140. break;
  141. case ATKMEDIA_STOP:
  142. keybd_event(VK_MEDIA_STOP, 0, 0, 0);
  143. break;
  144. case ATKMEDIA_NEXT:
  145. keybd_event(VK_MEDIA_NEXT_TRACK, 0, 0, 0);
  146. break;
  147. case ATKMEDIA_PREV:
  148. keybd_event(VK_MEDIA_PREV_TRACK, 0, 0, 0);
  149. break;
  150. case ATKMEDIA_CALC:
  151. RunProc(proc);
  152. break;
  153. }
  154.  
  155. default:
  156. return DefWindowProc(hWnd, message, wParam, lParam);
  157. }
  158. break;
  159. case WM_DESTROY:
  160. PostQuitMessage(0);
  161. break;
  162. default:
  163. return DefWindowProc(hWnd, message, wParam, lParam);
  164. }
  165. return 0;
  166. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement