Guest User

Untitled

a guest
Mar 22nd, 2012
2,278
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; Generic crosshair overlay v1.0
  2. ; By evilc@evilc.com
  3.  
  4. ; Instructions:
  5. ; =============
  6. ; Will ONLY work in WINDOWED mode
  7. ; 1) Run app to overlay crosshair to and make it active
  8. ; 2) Hit WIN+Insert to designate that as app to overlay to
  9. ; 3) Crosshair will appear but probably in wrong place
  10. ; 4) Use WIN+Arrow keys to move crosshair to right place
  11.  
  12. ; Crosshair will ONLY appear while designated app is active
  13. ; Settings saved to INI file so you only have to set up once
  14.  
  15. ; This is NOT a hack, it merely creates a transparent window
  16. ; that has "Always on top" property set
  17. ; Custom crosshairs can be used, edit ch.gif and edit size vars below
  18.  
  19. ch_x = 78 ; X size of ch.gif
  20. ch_y = 400 ; Y size of ch.gif
  21.  
  22. ; DO NOT EDIT BELOW HERE UNLESS YOU KNOW WHAT YOU ARE DOING!
  23. ; ==========================================================
  24.  
  25. ; Remove .ahk and .exe from filename to get name for INI file
  26. ScriptName := A_ScriptName
  27. StringReplace, ScriptName, ScriptName, .ahk,, All
  28. StringReplace, ScriptName, ScriptName, .exe,, All
  29.  
  30. ; Find position of window on screen
  31. WinGetPos, winx, winy, winw, winh, ahk_class %progclass%
  32.  
  33. ; PosX and PosY hold offset of cursor within window (From centre)
  34. PosX := 0
  35. PosY := 0
  36.  
  37. ; Read vals from INI file
  38. IniRead, PosX, %ScriptName%.ini, Main, PosX, %PosX%
  39. IniRead, PosY, %ScriptName%.ini, Main, PosY, %PosY%
  40. IniRead, progclass, %ScriptName%.ini, Main, progclass, %progclass%
  41.  
  42. ; Calculate offsets
  43. GoSub, offsetch
  44.  
  45. ; Init overlay
  46. Gui, Add, Picture, w%ch_x% h%ch_y% AltSubmit, TaMortarReticle.png
  47. Gui, Color, FFFFFF
  48. GoSub, showch
  49. Gui +AlwaysOnTop
  50. WinSet, TransColor, White, %A_ScriptName%
  51. Gui -Caption +ToolWindow
  52.  
  53. ; Hide overlay
  54. GoSub, hidech
  55.  
  56. ; MAIN LOOP
  57. SetTimer, tick, 500
  58.  
  59. ; ================================================================================
  60.  
  61. ; HOTKEYS
  62. !Up::
  63. PosY -= 1
  64. GoSub, showch
  65. IniWrite, %PosY%, %ScriptName%.ini, Main, PosY
  66. return
  67.  
  68. !Down::
  69. PosY += 1
  70. GoSub, showch
  71. IniWrite, %PosY%, %ScriptName%.ini, Main, PosY
  72. return
  73.  
  74. !Left::
  75. PosX -= 1
  76. GoSub, showch
  77. IniWrite, %PosX%, %ScriptName%.ini, Main, PosX
  78. return
  79.  
  80. !Right::
  81. PosX += 1
  82. GoSub, showch
  83. IniWrite, %PosX%, %ScriptName%.ini, Main, PosX
  84. return
  85.  
  86. !Insert::
  87. WinGetActiveTitle, wint
  88. WinGetClass, progclass, %wint%
  89. IniWrite, %progclass%, %ScriptName%.ini, Main, progclass
  90. return
  91.  
  92.  
  93. ; Shows the crosshair
  94. showch:
  95. GoSub, offsetch
  96. Gui, Show, NA x%chx% y%chy%
  97. return
  98.  
  99. ; Hides the crosshair
  100. hidech:
  101. Gui, Cancel
  102. return
  103.  
  104. ; Calculate offset
  105. offsetch:
  106. chx := 797
  107. chy := 501
  108. return
  109.  
  110. tick:
  111. IfWinActive, ahk_class %progclass%
  112. {
  113. ; Check to see if window moved
  114. WinGetPos, winx, winy, winw, winh, ahk_class %progclass%
  115. ; Draw crosshair
  116. GoSub, showch
  117. }
  118. else
  119. {
  120. GoSub, hidech
  121. }
  122. return
RAW Paste Data