Advertisement
Guest User

Untitled

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