Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; TRIBES:ASCEND CROSSHAIR v2.2
- ; --------------------------------------------------
- ;by Klyith
- ;from work by:
- ;http://www.autohotkey.com/forum/topic35517.html
- ;
- ;Thanks to tic (Tariq Porter) for his GDI+ Library
- ;http://www.autohotkey.com/forum/viewtopic.php?t=32238
- ;
- ; SCROLL TO LINES MARKED BY VVVVV / ^^^^^ FOR CUSTOMIZATION (hotkey on line 100)
- SetTitleMatchMode, 3
- Menu, Tray, Icon, xhair.ico
- Menu, Tray, NoStandard
- Menu, Tray, Add, Disable Crosshair, m_hide
- Menu, Tray, Default, Disable Crosshair
- Menu, Tray, Add, &Reload, _reload
- Menu, Tray, Add, E&xit, _exit
- onexit _exit
- OnMessage(0x6, "TA_activate")
- #Include, Gdip.ahk
- x_state := 1
- ; VVVVV edit to change crosshair filenames. PNG works best, supports full alpha. Some GIFs have transparency errors.
- xFile := "Crosshair.png" ;the image's default location is wherever this script is located
- aFile := "Alternate.png" ;alternate crosshair
- ; ^^^^^
- Gui, +LastFound -Caption +E0x80000 +E0x20 +E0x8 +Owner
- hGui := WinExist()
- pToken := Gdip_Startup()
- x_Bitmap := Gdip_CreateBitmapFromFile(xFile)
- x_Width := Gdip_GetImageWidth(x_Bitmap)
- x_Height := Gdip_GetImageHeight(x_Bitmap)
- a_Bitmap := Gdip_CreateBitmapFromFile(aFile)
- a_Width := Gdip_GetImageWidth(a_Bitmap)
- a_Height := Gdip_GetImageHeight(a_Bitmap)
- nWidth := x_Width >= a_Width ? x_Width : a_Width
- nHeight := x_Height >= a_Height ? x_Height : a_Height
- IfWinExist, "DayZ (32-bit, DX9)"
- {
- WinGet, hTribs, ID, ahk_class LaunchUnrealUWindowsClient
- Gosub TA_getposition ;center within tribes's window area
- }
- Else
- {
- Center_X := Round(A_ScreenWidth/2-(nWidth/2)) ;center on whole screen is tribes is not active
- Center_Y := Round(A_ScreenHeight/2-(nHeight/2))
- }
- _create:
- hbm := CreateDIBSection(nWidth,nHeight)
- hdc := CreateCompatibleDC()
- obm := SelectObject(hdc, hbm)
- pGraphics := Gdip_GraphicsFromHDC(hdc)
- Gui, Show, X%Center_X% Y%Center_Y% NoActivate
- UpdateLayeredWindow(hGui, hdc, Center_X,Center_Y,nWidth,nHeight)
- Gdip_SetCompositingMode(pGraphics,1)
- _update:
- pBrush:=Gdip_BrushCreateSolid(0x0000000)
- Gdip_FillRectangle(pGraphics, pBrush, 0, 0, nWidth, nHeight)
- ;rem Gdip_DrawImage (pointer, source image, x,y to draw at , width, height)
- if (x_state == 1)
- {
- this_X := Round((nWidth - x_Width)/2)
- this_Y := Round((nHeight - x_Height)/2)
- Gdip_DrawImage(pGraphics, x_Bitmap, this_X, this_Y, x_Width, x_Height)
- }
- else
- {
- this_X := Round((nWidth - a_Width)/2)
- this_Y := Round((nHeight - a_Height)/2)
- Gdip_DrawImage(pGraphics, a_Bitmap, this_X, this_Y, a_Width, a_Height)
- }
- UpdateLayeredWindow(hGui, hdc)
- Gdip_DeleteBrush(pBrush)
- Return
- ;VVVVV uncomment this line and line 120 to make hotkey only work when T:A is ACTIVE
- ;#IfWinActive, ahk_class LaunchUnrealUWindowsClient
- ;^^^^^
- ;VVVVV EDIT HERE TO CHANGE HOTKEY ASSIGNMENT, KEEP UP TO PREVENT OVERFLOW
- +^End UP::
- ;^^^^^
- if (x_state == 0)
- {
- x_state := 1
- Gosub TA_getposition
- Gui, +LastFound -Caption +E0x80000 +E0x20 +E0x8 +Owner
- hGui := WinExist()
- Gosub _create
- }
- else if (x_state == 1)
- {
- x_state := 2
- Gosub _update
- }
- else
- {
- Gui, Destroy
- x_state := 0
- }
- Return
- ;VVVVV
- ;#IfWinActive
- ;^^^^^
- m_hide:
- ;hide the crosshair and disable the hotkey until re-enabled
- Menu, Tray, ToggleCheck, Disable Crosshair
- Suspend
- if (x_state == -1)
- {
- x_state := 1
- Gui, Show, NoActivate
- Return
- }
- Gui, Hide
- x_state := -1
- Return
- TA_getposition:
- ;get the location & size of tribes's window, find center point
- WinGetPos, tribs_x, tribs_y, tribs_width, tribs_height, ahk_class LaunchUnrealUWindowsClient
- if !tribs_width
- Return
- Center_X := Round(tribs_x + (tribs_width/2) - (nWidth/2))
- Center_Y := Round(tribs_y + (tribs_height/2) - (nHeight/2))
- Return
- if gActivateScript = 1
- {
- Loop
- {
- MouseClick, left,,, 1, 0, D
- ;delay between simu. mouse btn down and up
- Sleep, 0
- MouseClick, left,,, 1, 0, U
- GetKeyState, LButtonState, LButton, P
- If LButtonState = U
- {
- ;break the loop if physical state of mouse btn is up.
- break
- }
- ;delay between each simu. click events
- Sleep, 0
- }
- }
- exit
- return
- TA_activate()
- {
- WinActivate, ahk_class LaunchUnrealUWindowsClient
- }
- _reload:
- SelectObject(hdc, obm)
- DeleteObject(hbm)
- DeleteDC(hdc)
- Gdip_DeleteGraphics(pGraphics)
- Gdip_DisposeImage(x_Bitmap)
- Gdip_DisposeImage(a_Bitmap)
- Gdip_Shutdown(pToken)
- Reload
- _exit:
- GuiClose:
- SelectObject(hdc, obm)
- DeleteObject(hbm)
- DeleteDC(hdc)
- Gdip_DeleteGraphics(pGraphics)
- Gdip_DisposeImage(x_Bitmap)
- Gdip_DisposeImage(a_Bitmap)
- Gdip_Shutdown(pToken)
- ExitApp
- #MaxThreadsPerHotkey 2
- #InstallMouseHook
- #Hotstring NoMouse
- #InstallKeybdHook
- #list:="1"
- ^!f::
- WinGetTitle, currentWindow, A
- IfWinExist %currentWindow%
- {
- WinSet, Style, ^0xC00000 ; toggle title bar
- WinMove, , , 0, 0, 1920, 1080
- }
- return
- !^f5::Suspend
- return
- ^+f5::pause
- ^+f6::reload
- return
- ^MButton::
- SetTimer, Label6,% GetKeyState("w") ? "off" : "50"
- Send % GetKeyState("w") ? "{w Up}" : "{w Down}"
- Return
- Label6:
- Sendevent {w Down}
- Return
- ^!MButton::
- SetTimer, Label7,% GetKeyState("s") ? "off" : "50"
- Send % GetKeyState("s") ? "{s Up}" : "{s Down}"
- Return
- Label7:
- Sendevent {s Down}
- Return
- +^SPACE::
- if list=3
- {
- Send {Space}
- Sleep, 0
- Sendevent {%list% Down}
- Sleep, 0
- list +=1
- Return
- }
- if list <= 3
- {
- Sendevent {%list% Down}
- list +=1
- Send {Space}
- Sleep, 0
- return
- }
- else
- {
- list = 1
- Sleep, 0
- return
- }
- return
- ^!LButton::
- SetTimer, Label2,% GetKeyState("LButton") ? "off" : "100"
- Send % GetKeyState("LButton") ? "{LButton Up}" : "{LButton Down}"
- Return
- Label2:
- Send {LButton Down}
- Return
- ^!RButton::
- SetTimer, Label3,% GetKeyState("RButton") ? "off" : "100"
- Send % GetKeyState("RButton") ? "{RButton Up}" : "{RButton Down}"
- Return
- Label3:
- Send {RButton Down}
- Return
- SetClipboard()
- {
- ClipSaved := ClipboardAll ;Save the clipboard
- Clipboard = ;Empty the clipboard
- SendInput, ^c
- ClipWait, 2
- if ErrorLevel
- {
- MsgBox % "The attempt to copy text onto the clipboard failed."
- return
- }
- NewClipboard = %clipboard%
- StringReplace, NewClipboard, NewClipBoard, `r`n, `n, All
- Clipboard := ClipSaved ;Restore the clipboard
- ClipSaved = ;Free the memory in case the clipboard was very large.
- Return NewClipboard
- }
- +^BS::ClipBoard_X1 := SetClipboard()
- +BS::SendInput {Raw}%ClipBoard_X1%
- return
- !+^END::ClipBoard_X2 := SetClipboard()
- !+END::SendInput {Raw}%ClipBoard_X2%
- return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement