goWindow.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. // Copyright 2016 The go-vgo Project Developers. See the COPYRIGHT
  2. // file at the top-level directory of this distribution and at
  3. // https://github.com/go-vgo/robotgo/blob/master/LICENSE
  4. //
  5. // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
  6. // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
  7. // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
  8. // option. This file may not be copied, modified, or distributed
  9. // except according to those terms.
  10. #include "alert_c.h"
  11. #include "window.h"
  12. #include "win_sys.h"
  13. void min_window(uintptr pid, bool state, int8_t isPid){
  14. #if defined(IS_MACOSX)
  15. // return 0;
  16. AXUIElementRef axID = AXUIElementCreateApplication(pid);
  17. AXUIElementSetAttributeValue(axID, kAXMinimizedAttribute,
  18. state ? kCFBooleanTrue : kCFBooleanFalse);
  19. #elif defined(USE_X11)
  20. // Ignore X errors
  21. XDismissErrors();
  22. // SetState((Window)pid, STATE_MINIMIZE, state);
  23. #elif defined(IS_WINDOWS)
  24. HWND hwnd = getHwnd(pid, isPid);
  25. win_min(hwnd, state);
  26. #endif
  27. }
  28. void max_window(uintptr pid, bool state, int8_t isPid){
  29. #if defined(IS_MACOSX)
  30. // return 0;
  31. #elif defined(USE_X11)
  32. XDismissErrors();
  33. // SetState((Window)pid, STATE_MINIMIZE, false);
  34. // SetState((Window)pid, STATE_MAXIMIZE, state);
  35. #elif defined(IS_WINDOWS)
  36. HWND hwnd = getHwnd(pid, isPid);
  37. win_max(hwnd, state);
  38. #endif
  39. }
  40. uintptr get_handle(){
  41. MData mData = get_active();
  42. #if defined(IS_MACOSX)
  43. return (uintptr)mData.CgID;
  44. #elif defined(USE_X11)
  45. return (uintptr)mData.XWin;
  46. #elif defined(IS_WINDOWS)
  47. return (uintptr)mData.HWnd;
  48. #endif
  49. }
  50. uintptr b_get_handle() {
  51. #if defined(IS_MACOSX)
  52. return (uintptr)pub_mData.CgID;
  53. #elif defined(USE_X11)
  54. return (uintptr)pub_mData.XWin;
  55. #elif defined(IS_WINDOWS)
  56. return (uintptr)pub_mData.HWnd;
  57. #endif
  58. }
  59. void active_PID(uintptr pid, int8_t isPid){
  60. MData win = set_handle_pid(pid, isPid);
  61. set_active(win);
  62. }