Advertisement
Guest User

ahk script compilation

a guest
Feb 14th, 2014
655
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;    TRIBES:ASCEND CROSSHAIR         v2.2
  2. ; --------------------------------------------------
  3. ;by Klyith
  4. ;from work by:
  5. ;http://www.autohotkey.com/forum/topic35517.html
  6. ;
  7. ;Thanks to tic (Tariq Porter) for his GDI+ Library
  8. ;http://www.autohotkey.com/forum/viewtopic.php?t=32238
  9. ;
  10. ; SCROLL TO LINES MARKED BY VVVVV  /  ^^^^^ FOR CUSTOMIZATION (hotkey on line 100)
  11.  
  12. SetTitleMatchMode, 3
  13. Menu, Tray, Icon, xhair.ico
  14. Menu, Tray, NoStandard
  15. Menu, Tray, Add, Disable Crosshair, m_hide
  16. Menu, Tray, Default, Disable Crosshair
  17. Menu, Tray, Add, &Reload, _reload
  18. Menu, Tray, Add, E&xit, _exit
  19. onexit _exit
  20. OnMessage(0x6, "TA_activate")
  21. #Include, Gdip.ahk
  22.  
  23. x_state := 1
  24.  
  25. ; VVVVV edit to change crosshair filenames. PNG works best, supports full alpha. Some GIFs have transparency errors.
  26. xFile := "Crosshair.png"     ;the image's default location is wherever this script is located
  27. aFile := "Alternate.png"     ;alternate crosshair
  28. ; ^^^^^
  29.  
  30.  
  31. Gui, +LastFound -Caption +E0x80000 +E0x20 +E0x8 +Owner
  32. hGui := WinExist()
  33.  
  34. pToken := Gdip_Startup()
  35.  
  36. x_Bitmap := Gdip_CreateBitmapFromFile(xFile)
  37. x_Width  := Gdip_GetImageWidth(x_Bitmap)
  38. x_Height := Gdip_GetImageHeight(x_Bitmap)
  39. a_Bitmap := Gdip_CreateBitmapFromFile(aFile)
  40. a_Width  := Gdip_GetImageWidth(a_Bitmap)
  41. a_Height := Gdip_GetImageHeight(a_Bitmap)
  42. nWidth := x_Width >= a_Width ? x_Width : a_Width
  43. nHeight := x_Height >= a_Height ? x_Height : a_Height
  44.  
  45.  
  46. IfWinExist, "DayZ (32-bit, DX9)"
  47. {
  48.    WinGet, hTribs, ID, ahk_class LaunchUnrealUWindowsClient
  49.    Gosub TA_getposition                        ;center within tribes's window area
  50. }
  51. Else
  52. {
  53.    Center_X := Round(A_ScreenWidth/2-(nWidth/2))     ;center on whole screen is tribes is not active
  54.    Center_Y := Round(A_ScreenHeight/2-(nHeight/2))
  55. }
  56.  
  57. _create:
  58. hbm := CreateDIBSection(nWidth,nHeight)
  59. hdc := CreateCompatibleDC()
  60. obm := SelectObject(hdc, hbm)
  61. pGraphics := Gdip_GraphicsFromHDC(hdc)
  62.  
  63. Gui, Show, X%Center_X% Y%Center_Y% NoActivate
  64. UpdateLayeredWindow(hGui, hdc, Center_X,Center_Y,nWidth,nHeight)
  65. Gdip_SetCompositingMode(pGraphics,1)
  66.  
  67.  
  68. _update:
  69.  
  70. pBrush:=Gdip_BrushCreateSolid(0x0000000)
  71. Gdip_FillRectangle(pGraphics, pBrush, 0, 0, nWidth, nHeight)
  72.  
  73. ;rem Gdip_DrawImage (pointer, source image, x,y to draw at , width, height)
  74.  
  75. if (x_state == 1)
  76. {
  77.    this_X := Round((nWidth - x_Width)/2)
  78.    this_Y := Round((nHeight - x_Height)/2)
  79.    Gdip_DrawImage(pGraphics, x_Bitmap, this_X, this_Y, x_Width, x_Height)
  80. }
  81. else
  82. {
  83.    this_X := Round((nWidth - a_Width)/2)
  84.    this_Y := Round((nHeight - a_Height)/2)
  85.    Gdip_DrawImage(pGraphics, a_Bitmap, this_X, this_Y, a_Width, a_Height)
  86. }
  87.  
  88.  
  89. UpdateLayeredWindow(hGui, hdc)
  90. Gdip_DeleteBrush(pBrush)
  91. Return
  92.  
  93.  
  94. ;VVVVV uncomment this line and line 120 to make hotkey only work when T:A is ACTIVE
  95. ;#IfWinActive, ahk_class LaunchUnrealUWindowsClient
  96. ;^^^^^
  97.  
  98. ;VVVVV EDIT HERE TO CHANGE HOTKEY ASSIGNMENT, KEEP UP TO PREVENT OVERFLOW
  99. +^End UP::
  100. ;^^^^^
  101.  
  102. if (x_state == 0)
  103. {
  104.    x_state := 1
  105.    Gosub TA_getposition
  106.    Gui, +LastFound -Caption +E0x80000 +E0x20 +E0x8 +Owner
  107.    hGui := WinExist()
  108.    Gosub _create
  109. }
  110. else if (x_state == 1)
  111. {
  112.    x_state := 2
  113.    Gosub _update
  114. }
  115. else
  116. {
  117.    Gui, Destroy
  118.    x_state := 0
  119. }
  120.  
  121. Return
  122. ;VVVVV
  123. ;#IfWinActive
  124. ;^^^^^
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131. m_hide:
  132. ;hide the crosshair and disable the hotkey until re-enabled
  133.    Menu, Tray, ToggleCheck, Disable Crosshair
  134.    Suspend
  135.    if (x_state == -1)
  136.    {
  137.       x_state := 1
  138.       Gui, Show, NoActivate
  139.       Return
  140.    }
  141.    Gui, Hide
  142.    x_state := -1
  143. Return
  144.  
  145.  
  146. TA_getposition:
  147. ;get the location & size of tribes's window, find center point
  148.    WinGetPos, tribs_x, tribs_y, tribs_width, tribs_height, ahk_class LaunchUnrealUWindowsClient
  149.    if !tribs_width
  150.       Return
  151.    Center_X := Round(tribs_x + (tribs_width/2) - (nWidth/2))
  152.    Center_Y := Round(tribs_y + (tribs_height/2) - (nHeight/2))
  153. Return
  154.  
  155. if gActivateScript = 1
  156. {
  157. Loop
  158. {
  159. MouseClick, left,,, 1, 0, D
  160. ;delay between simu. mouse btn down and up
  161. Sleep, 0
  162. MouseClick, left,,, 1, 0, U
  163. GetKeyState, LButtonState, LButton, P
  164. If LButtonState = U
  165. {
  166. ;break the loop if physical state of mouse btn is up.
  167. break
  168. }
  169. ;delay between each simu. click events
  170. Sleep, 0
  171. }
  172. }
  173. exit
  174. return
  175.  
  176. TA_activate()
  177. {
  178.    WinActivate, ahk_class LaunchUnrealUWindowsClient
  179. }
  180.  
  181.  
  182. _reload:
  183. SelectObject(hdc, obm)
  184. DeleteObject(hbm)
  185. DeleteDC(hdc)
  186. Gdip_DeleteGraphics(pGraphics)
  187. Gdip_DisposeImage(x_Bitmap)
  188. Gdip_DisposeImage(a_Bitmap)
  189. Gdip_Shutdown(pToken)
  190. Reload
  191.  
  192.  
  193. _exit:
  194. GuiClose:
  195. SelectObject(hdc, obm)
  196. DeleteObject(hbm)
  197. DeleteDC(hdc)
  198. Gdip_DeleteGraphics(pGraphics)
  199. Gdip_DisposeImage(x_Bitmap)
  200. Gdip_DisposeImage(a_Bitmap)
  201. Gdip_Shutdown(pToken)
  202. ExitApp
  203.  
  204.  
  205.  
  206. #MaxThreadsPerHotkey 2
  207. #InstallMouseHook
  208. #Hotstring NoMouse
  209. #InstallKeybdHook
  210. #list:="1"
  211.  
  212.  
  213. ^!f::
  214. WinGetTitle, currentWindow, A
  215. IfWinExist %currentWindow%
  216. {
  217.     WinSet, Style, ^0xC00000 ; toggle title bar
  218.     WinMove, , , 0, 0, 1920, 1080
  219. }
  220. return
  221.  
  222.  
  223. !^f5::Suspend
  224. return
  225.  
  226.  
  227. ^+f5::pause
  228.  
  229.  
  230. ^+f6::reload
  231. return
  232.  
  233.  
  234. ^MButton::
  235. SetTimer, Label6,% GetKeyState("w") ? "off" : "50"
  236. Send % GetKeyState("w") ? "{w Up}" : "{w Down}"
  237. Return
  238. Label6:
  239. Sendevent {w Down}
  240. Return
  241.  
  242.  
  243. ^!MButton::
  244. SetTimer, Label7,% GetKeyState("s") ? "off" : "50"
  245. Send % GetKeyState("s") ? "{s Up}" : "{s Down}"
  246. Return
  247. Label7:
  248. Sendevent {s Down}
  249. Return
  250.  
  251.  
  252.  
  253.  
  254. +^SPACE::
  255. if list=3
  256. {  
  257. Send {Space}
  258. Sleep, 0
  259. Sendevent {%list% Down}
  260. Sleep, 0
  261. list +=1
  262. Return
  263. }
  264. if list <= 3
  265. {
  266. Sendevent {%list% Down}
  267. list +=1
  268. Send {Space}
  269. Sleep, 0
  270. return
  271. }
  272. else
  273. {
  274. list = 1
  275. Sleep, 0
  276. return
  277. }
  278. return
  279.  
  280.  
  281.  
  282.  
  283.  
  284. ^!LButton::
  285. SetTimer, Label2,% GetKeyState("LButton") ? "off" : "100"
  286. Send % GetKeyState("LButton") ? "{LButton Up}" : "{LButton Down}"
  287. Return
  288. Label2:
  289. Send {LButton Down}
  290. Return
  291.  
  292.  
  293. ^!RButton::
  294. SetTimer, Label3,% GetKeyState("RButton") ? "off" : "100"
  295. Send % GetKeyState("RButton") ? "{RButton Up}" : "{RButton Down}"
  296. Return
  297. Label3:
  298. Send {RButton Down}
  299. Return
  300.  
  301.  
  302.  
  303. SetClipboard()
  304. {
  305. ClipSaved := ClipboardAll ;Save the clipboard
  306. Clipboard = ;Empty the clipboard
  307. SendInput, ^c
  308. ClipWait, 2
  309. if ErrorLevel
  310. {
  311.      MsgBox % "The attempt to copy text onto the clipboard failed."
  312.      return
  313. }
  314. NewClipboard = %clipboard%
  315. StringReplace, NewClipboard, NewClipBoard, `r`n, `n, All
  316. Clipboard := ClipSaved ;Restore the clipboard
  317. ClipSaved = ;Free the memory in case the clipboard was very large.
  318. Return NewClipboard
  319. }
  320.  
  321.  
  322. +^BS::ClipBoard_X1 := SetClipboard()
  323.  
  324.  
  325. +BS::SendInput {Raw}%ClipBoard_X1%
  326. return
  327.  
  328.  
  329. !+^END::ClipBoard_X2 := SetClipboard()
  330.  
  331.  
  332. !+END::SendInput {Raw}%ClipBoard_X2%
  333. return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement