Advertisement
Guest User

Launch PeerBlockPortable

a guest
Apr 12th, 2015
356
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
  2. SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
  3. SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
  4.  
  5.  
  6. ; dialogbox, features read from "ActiveWindowInfoInclude"
  7. /*
  8. Window title, Class and Process
  9. PeerBlock Portable (PortableApps.com Launcher)
  10. ahk_class #32770
  11. ahk_exe PeerBlockPortable.exe
  12.  
  13. Mouse Position
  14. Absolute:   437, 670 (less often used)
  15. Relative:   363, 103 (default)
  16. Client: 360, 74 (recommended)
  17.  
  18. Control Under Mouse Position (musepeker over OK-knappan)
  19. ClassNN:    Button1
  20. Text:   OK
  21. Color:  F1F1ED (Red=F1 Green=F1 Blue=ED)
  22.  
  23. Active Window Position
  24. x: 74   y: 567  w: 726  h: 126
  25. Client:     w: 720  h: 94
  26.  
  27. Visible Text (same as "All Text")
  28. OK
  29. PeerBlock Portable did not close properly last time it was run and will now clean up. Please then start PeerBlock Portable again manually.
  30. */
  31.  
  32.  
  33. tryStartAgain:
  34. ; Launc the program
  35. Run, PeerBlockPortable.exe
  36.  
  37. ; Searching for errormessage (only if dialogbox size matchhes given criterias)
  38. ; Last about ten seconds. Then stop searching.
  39. Loop, 100
  40. {
  41.     If (windowSizeMatchErrorMsg()) {
  42.         WinActivate, PeerBlock Portable (PortableApps.com Launcher)
  43.         Sleep, 100
  44.         Click 363, 103  ; OK button
  45.         Sleep 500
  46.         Goto, tryStartAgain
  47.         Break
  48.     }
  49.     Else
  50.         Sleep 100
  51. }
  52.  
  53. ; Returns 1 if active window have matching size
  54. windowSizeMatchErrorMsg() {
  55.     IfWinExist, PeerBlock Portable (PortableApps.com Launcher)
  56.     {
  57.         ; Gathering basic info about window
  58.         WinGetPos, X, Y, Width, Height, PeerBlock Portable (PortableApps.com Launcher)
  59.         If (Width=726 && (Height=126 || Height=119)) {
  60.             Return 1
  61.         }
  62.     }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement