robotgo_mac_win.go 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. //go:build darwin || windows
  11. // +build darwin windows
  12. package robotgo
  13. // GetBounds get the window bounds
  14. func GetBounds(pid int, args ...int) (int, int, int, int) {
  15. var isPid int
  16. if len(args) > 0 || NotPid {
  17. isPid = 1
  18. }
  19. return internalGetBounds(pid, isPid)
  20. }
  21. // GetClient get the window client bounds
  22. func GetClient(pid int, args ...int) (int, int, int, int) {
  23. var isPid int
  24. if len(args) > 0 || NotPid {
  25. isPid = 1
  26. }
  27. return internalGetClient(pid, isPid)
  28. }
  29. // internalGetTitle get the window title
  30. func internalGetTitle(pid int, args ...int) string {
  31. var isPid int
  32. if len(args) > 0 || NotPid {
  33. isPid = 1
  34. }
  35. gtitle := cgetTitle(pid, isPid)
  36. return gtitle
  37. }
  38. // ActivePid active the window by PID,
  39. //
  40. // If args[0] > 0 on the Windows platform via a window handle to active
  41. //
  42. // Examples:
  43. //
  44. // ids, _ := robotgo.FindIds()
  45. // robotgo.ActivePid(ids[0])
  46. func ActivePid(pid int, args ...int) error {
  47. var isPid int
  48. if len(args) > 0 || NotPid {
  49. isPid = 1
  50. }
  51. internalActive(pid, isPid)
  52. return nil
  53. }
  54. // DisplaysNum get the count of displays
  55. func DisplaysNum() int {
  56. return getNumDisplays()
  57. }
  58. // Alert show a alert window
  59. // Displays alert with the attributes.
  60. // If cancel button is not given, only the default button is displayed
  61. //
  62. // Examples:
  63. //
  64. // robotgo.Alert("hi", "window", "ok", "cancel")
  65. func Alert(title, msg string, args ...string) bool {
  66. return showAlert(title, msg, args...)
  67. }