Advertisement
djvj

RLUI window detect

Apr 17th, 2016
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.81 KB | None | 0 0
  1. #Include, %A_ScriptDir%\Lib\Classes\Util\MiscUtils.ahk
  2. #Include, %A_ScriptDir%\Lib\Classes\Util\Environment\StringUtils.ahk
  3. #Include, %A_ScriptDir%\Lib\Classes\Util\File\File.ahk
  4. #Include, %A_ScriptDir%\Lib\Classes\Util\File\Process.ahk
  5. #Include, %A_ScriptDir%\Lib\Classes\Util\UI\Control.ahk
  6. #Include, %A_ScriptDir%\Lib\Classes\Util\UI\Window.ahk
  7. #Include, %A_ScriptDir%\Lib\Classes\Util\UI\WindowTitle.ahk
  8. #Include, %A_ScriptDir%\Module Extensions\VA_Extension.ahk
  9. #Include, %A_ScriptDir%\Module Extensions\VA.ahk
  10. Hotkey, Esc, closescript
  11.  
  12. DetectHiddenWindows, on
  13. FEPath := "D:\RocketLauncher\RocketLauncherUI\RocketLauncherUI.exe"
  14. FEName := "ahk_exe RocketLauncherUI.exe"
  15. FrontEndProcess := new Process(FEPath)
  16.  
  17. ; Storing the FE's x,y,width, & height to restore it on exit if an application changed it going fullscreen
  18. FrontEndProcess.Process("Exist") ; store PID in object
  19. If FrontEndProcess.PID { ; If the FE is running, store the position and size
  20. RLLog.Info("Main - Detected " . FrontEndProcess.FileName . " is currently running")
  21. ; FrontEndWindow := new Window(new WindowTitle("","","","",FrontEndProcess.PID)) ; instantiate Front End window object from PID
  22. FrontEndWindow := new Window(new WindowTitle("","",FrontEndProcess.FileFullPath)) ; instantiate Front End window object from PID
  23. FrontEndWindow.Get("ID")
  24. ; MsgBox % FrontEndWindow.ID
  25. FrontEndWindow.WinTitle.PID := ""
  26. ; FrontEndWindow.WinTitle.ID := FrontEndWindow.ID
  27. FrontEndWindow.GetPos(frontendX, frontendY, frontendW, frontendH)
  28. RLLog.Info("Main - " . FrontEndProcess.FileName . " coordinates are x" . FrontEndWindow.X . " y" . FrontEndWindow.Y . " w" . FrontEndWindow.W . " h" . FrontEndWindow.H)
  29. } Else
  30. RLLog.Info("Main - " . FrontEndProcess.FileName . " is not currently running")
  31.  
  32. titlename := FrontEndWindow.GetTitle(0)
  33. classname := FrontEndWindow.GetClass(0)
  34. tpid := "ahk_pid " . FrontEndWindow.PID
  35. ; class := "ahk_class " . class
  36. ; tid := "ahk_id " . WinID
  37. ; WinGet, WinID, ID, %tpid%
  38. ; WinGet, WinPID, PID, %tpid%
  39. ; WinGetClass, class, %tpid%
  40. ; WinGetTitle, title, %tpid%
  41. ; WinGetPos, X, Y, Width, Height, %tpid%
  42. WinGet, WinID, ID, RocketLauncherUI
  43. WinGet, WinPID, PID, RocketLauncherUI
  44. WinGetClass, class, RocketLauncherUI
  45. WinGetTitle, title, RocketLauncherUI
  46. WinGetPos, X, Y, Width, Height, RocketLauncherUI
  47. TestWindow := new Window(new WindowTitle("RocketLauncherUI"))
  48. TestWindow.Get("ID")
  49. TestWindow.Get("PID")
  50. TestWindow.GetPos(frontendX, frontendY, frontendW, frontendH)
  51. testtitlename := TestWindow.GetTitle(0)
  52. testclassname := TestWindow.GetClass(0)
  53. MsgBox % "OLD:`nX: " . X . "`nY: " . Y . "`nW: " . Width . "`nH: " . Height . "`nWinPID: " . WinPID . "`nWinID: " . WinID . "`nTitle: " . title . "`nClass: " . class . "`n`nNEW`nX: " . FrontEndWindow.X . "`nY: " . FrontEndWindow.Y . "`nW: " . FrontEndWindow.W . "`nH: " . FrontEndWindow.H . "`nFrontEndProcess.PID: " . FrontEndProcess.PID . "`nFrontEndWindow.ID: " . FrontEndWindow.ID . "`nFrontEndWindow.Title: " . titlename . "`nFrontEndWindow.Class: " . classname . "`n`nTEST`nX: " . TestWindow.X . "`nY: " . TestWindow.Y . "`nW: " . TestWindow.W . "`nH: " . TestWindow.H . "`nFrontEndProcess.PID: " . TestWindow.PID . "`nFrontEndWindow.ID: " . TestWindow.ID . "`nFrontEndWindow.Title: " . testtitlename . "`nFrontEndWindow.Class: " . testclassname
  54. ExitApp
  55.  
  56. ScriptError(txt,a="") {
  57. msgbox % txt
  58. }
  59.  
  60. GetFullName( fn ) {
  61. ; http://msdn.microsoft.com/en-us/library/Aa364963
  62. ; Static buf, i ; removed i from static because it was always using HS's root folder as the working dir which threw off all relative paths
  63. Static buf
  64. ; If !i
  65. i := VarSetCapacity(buf, 512)
  66. DllCall("GetFullPathNameA", "str", fn, "uint", 512, "str", buf, "str*", 0)
  67. Return buf
  68. }
  69. GetOSVersion() {
  70. VarSetCapacity(v,148), NumPut(148,v)
  71. DllCall("GetVersionEx", "uint", &v)
  72. ; Return formatted version string similar to A_AhkVersion.
  73. ; Assume build number will never be more than 4 characters.
  74. return NumGet(v,4) ; major
  75. . "." NumGet(v,8) ; minor
  76. . "." SubStr("0000" NumGet(v,12), -3) ; build
  77. }
  78.  
  79. closescript:
  80. ExitApp
  81.  
  82.  
  83. ReStartExplorer( WaitSecs = 10 ) { ; SKAN, CD:07-Dec-2013 LM:14-Dec-2014 | goo.gl/UnS2rl
  84. ; Credit: Gracefully Exit Explorer (Programmatically) - Stack Overflow | goo.gl/tAA9HY
  85. ; Thanks to chaz - http://ahkscript.org/boards/viewtopic.php?p=7099#p7099
  86.  
  87. If A_OSVersion not in WIN_XP,WIN_VISTA,WIN_7
  88. Return 0, ErrorLevel := 1
  89.  
  90. If ( A_OSVersion = "WIN_XP" ) {
  91. WinGet, ShellPID, PID, ahk_class Progman
  92. PostMessage, 0x012, 0, 0,, ahk_class Progman ; WM_QUIT = 0x12
  93. } Else {
  94. WinGet, ShellPID, PID, ahk_class Shell_TrayWnd
  95. PostMessage, 0x5B4, 0, 0,, ahk_class Shell_TrayWnd ; WM_USER + 0x1B4
  96. }
  97.  
  98. Process, WaitClose, %ShellPID%, %WaitSecs%
  99. IfEqual, ErrorLevel, 0, Run %A_WinDir%\explorer.exe
  100. Return !ErrorLevel
  101. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement