9/29 AHK 自瞄腳本 分享
https://www.youtube.com/watch?v=ZxJ64DtG9B0程式
**** Hidden Message *****
密碼:
102030405060708090Haha
原始碼#NoTrayIcon
#SingleInstance, Force
#NoEnv
#Include, gdip.ahk
global layout, tooltipArray, pToken, Scan0, Stride, ts
SetBatchLines,-1
SetMouseDelay,-1
coordmode,mouse,screen
coordmode,tooltip,screen
LoadLayout()
Tooltip()
ts := new TempSettings()
ts.Refresh()
altMouse := 1
return
~F12::
~home::
~delete::
Tooltip()
return
~up::Tooltip(,-1)
~down::Tooltip(,1)
~right::Tooltip(1)
~left::Tooltip(-1)
aim:
if (!active) {
active := true
while (GetKeyState(strreplace(a_thishotkey,"~"),"P")) {
match := false
QPX(True)
movepoint := new point(0,0)
movepoint2 := new point(0,-1)
if (ts.alternative == 1) {
pbmp := Gdip_BitmapFromScreen(ts.search_offset.x "|" ts.search_offset.y "|" ts.dimensions.x "|" ts.dimensions.y)
E1 := Gdip_LockBits(pbmp, 0, 0, ts.dimensions.x, ts.dimensions.y, Stride, Scan0, BitmapData,1)
}
else if (ts.alternative == 2) {
}
else {
pbmp := BitmapFromScreen2(ts.search_offset.x, ts.search_offset.y, ts.dimensions.x, ts.dimensions.y,ts.dc)
E1 := Gdip_LockBits(pbmp, 0, 0, ts.dimensions.x, ts.dimensions.y, Stride, Scan0, BitmapData,1,0x21808)
}
loop % (ts.dimensions.max()/ts.spread)**2 {
if ((-ts.dimensions.x/2 < movepoint.x) <= ts.dimensions.x/2) && ((-ts.dimensions.y/2 < movepoint.y) <= ts.dimensions.y/2) {
search_point := new point((movepoint.x*ts.spread) + (ts.dimensions.x/2), (movepoint.y*ts.spread) + (ts.dimensions.y/2))
if (search_point.x >= 0 && search_point.x < ts.dimensions.x) && (search_point.y >= 0 && search_point.y < ts.dimensions.y) {
;~ GetRGB(search_point,"dwm|" handle,r,g,b)
GetRGB(search_point,"",r,g,b)
if (r > 240 && g < 20 && b < 20) && (b > 0) && (g == 0) {
match := true
found_point := new point(search_point.x-3,search_point.y)
FindLeftEdge(found_point)
mouse_point := new point((ts.search_offset.x+found_point.x)-ts.window_center.x, (ts.search_offset.y+found_point.y-ts.offset_y)-ts.window_center.y)
DllCall("mouse_event", "UInt", 0x01, "UInt", (mouse_point.x+ts.mouse_offset.x)/ts.ingame_sens, "UInt", (mouse_point.y+ts.mouse_offset.y)/(ts.ingame_sens*2.41))
;~ if (!altMouse)
;~ match_search_offset := new point(ts.window_center.x+(mouse_point.x*0.5)-ts.match_dimensions.x/1.5 , ts.window_center.y+(mouse_point.y*0.5)-ts.match_dimensions.y/2+ts.offset_y)
;~ else
match_search_offset := new point(ts.window_center.x+(mouse_point.x)-ts.match_dimensions.x+ts.mouse_offset.x, ts.window_center.y+(mouse_point.y)-ts.match_dimensions.y+ts.mouse_offset.y+ts.offset_y)
}
}
}
if (!match) {
if (movepoint.x == movepoint.y || (movepoint.x < 0 && movepoint.x == -movepoint.y) || (movepoint.x > 0 && movepoint.x == 1-movepoint.y)) {
movepoint2.swap()
}
movepoint.add(movepoint2.x,movepoint2.y)
}
} until (match)
if (match) {
ts.dimensions := new point(ts.match_dimensions.x,ts.match_dimensions.y)
ts.search_offset := match_search_offset
if (ts.overlayShow)
overlay(ts.search_offset.x, ts.search_offset.y, ts.dimensions.x, ts.dimensions.y,,1)
dur := QPX(false)
if (dur < 0.008) {
delay(0.008-dur)
}
}
else {
if (ts.dimensions.max() < ts.start_dimensions.min()) {
ts.dimensions.x += 200
ts.dimensions.y += 100
ts.search_offset.sub(100,50)
if (ts.overlayShow)
overlay(ts.search_offset.x, ts.search_offset.y, ts.dimensions.x, ts.dimensions.y,,1)
}
else {
ts.dimensions := ts.start_dimensions
ts.search_offset := ts.start_search_offset
if (ts.overlayShow)
overlay(ts.search_offset.x, ts.search_offset.y, ts.dimensions.x, ts.dimensions.y)
}
dur := QPX(false)
if (dur < 0.008) {
delay(0.008-dur)
}
}
Gdip_UnlockBits(pbmp, BitmapData)
Gdip_DisposeImage(pbmp)
}
active := false
}
ts.dimensions := ts.start_dimensions
ts.search_offset := ts.start_search_offset
overlay(ts.search_offset.x, ts.search_offset.y, ts.dimensions.x, ts.dimensions.y)
return
FindHPBar() {
}
GetRGB(point,mode,byref r, byref g, byref b) {
mode := strsplit(mode,"|")
if (mode == "dwm") {
Gdip_FromRGB(DllCall("gdi32.dll\GetPixel", "UInt", ts.dc, "Int", point.x, "Int", point.y, "UInt"),b,g,r)
}
else
Gdip_FromRGB(NumGet(Scan0+0, (point.x*3)+(point.y*Stride)),r,g,b)
}
FindLeftEdge(byref found_point) {
mismatch := 0
loop 100{
if (found_point.x < 0 || found_point.x > dimensions.x)
mismatch := 9
GetRGB(search_point,"",r,g,b)
if !((r > 200 && g < 100 && b < 100))
mismatch++
else
mismatch := 0
found_point.x-=2
} until % mismatch > 8
}
BitmapFromScreen2(s_x,s_y,s_w,s_h,dc) {
chdc := CreateCompatibleDC(dc), hbm := CreateDIBSection(s_w, s_h, chdc), obm := SelectObject(chdc, hbm)
BitBlt(chdc, 0, 0, s_w, s_h, dc, s_x, s_y)
pbmp := Gdip_CreateBitmapFromHBITMAP(hbm)
SelectObject(chdc, obm), DeleteObject(hbm), DeleteDC(chdc)
return pbmp
}
Gdip_FromRGB(RGB, ByRef R, ByRef G, ByRef B)
{
R := (0x00ff0000 & RGB) >> 16
G := (0x0000ff00 & RGB) >> 8
B := 0x000000ff & RGB
}
Delay( D=0.001 ) {
Static F
Critical
F ? F : DllCall( "QueryPerformanceFrequency", Int64P,F )
DllCall( "QueryPerformanceCounter", Int64P,pTick ), cTick := pTick
While( ( (Tick:=(pTick-cTick)/F)) <D ) {
DllCall( "QueryPerformanceCounter", Int64P,pTick )
Sleep -1
}
Return Round( Tick,3 )
}
QPX( N=0 ) {
Static F,A,Q,P,X
If ( N && !P )
Return DllCall("QueryPerformanceFrequency",Int64P,F) + (X:=A:=0) + DllCall("QueryPerformanceCounter",Int64P,P)
DllCall("QueryPerformanceCounter",Int64P,Q), A:=A+Q-P, P:=Q, X:=X+1
Return ( N && X=N ) ? (X:=X-1)<<64 : ( N=0 && (R:=A/X/F) ) ? ( R + (A:=P:=X:=0) ) : 1
}
overlay(x ,y ,w ,h, create=0,c=0) {
static overlay_ID
if (!overlay_ID) {
Gui, 2: +E0x20 -Caption +E0x80000 +LastFound +AlwaysOnTop +ToolWindow +OwnDialogs
Gui, 2: Show,,Window
overlay_ID := WinExist()
}
overlay_dib := CreateDIBSection(w, h)
overlay_dc := CreateCompatibleDC()
overlay_obm := SelectObject(overlay_dc, overlay_dib)
G := Gdip_GraphicsFromHDC(overlay_dc)
if (!c)
overlay_pen := Gdip_CreatePen(Gdip_ToARGB(255,255,0,0), 2)
else
overlay_pen := Gdip_CreatePen(Gdip_ToARGB(255,0,255,0), 2)
Gdip_DrawRectangle(G, overlay_pen, 0, 0, w, h)
Gdip_DeletePen(overlay_pen)
UpdateLayeredWindow(overlay_ID, overlay_dc, x, y, w, h)
SelectObject(overlay_dc, overlay_obm)
DeleteObject(overlay_dib)
DeleteDC(overlay_dc)
Gdip_DeleteGraphics(G)
}
class point {
__new(x,y) {
this.x := x
this.y := y
}
swap() {
ty := -this.y
this.y := this.x
this.x := ty
}
max() {
if (this.x > this.y)
return % this.x
else
return % this.y
}
min() {
if (this.x < this.y)
return % this.x
else
return % this.y
}
add(x,y) {
this.x += x
this.y += y
}
sub(x,y) {
this.x -= x
this.y -= y
}
}
pickItem(subs,val=0) {
temp := strsplit(layout,"|")
if (instr(temp,"num")) {
temp2 := strsplit(temp,":")
newVal := temp+(temp2*val)
if (newVal >= 0) {
if (temp2 < 1)
temp := round(newVal,2)
else
temp := round(newVal,0)
}
layout := temp "|" temp
return % temp
}
else if (instr(temp,"bool")) {
temp2 := strsplit(temp,":")
temp := temp2 ":" !temp2
temp := (temp2) ? "Enabled" : "Disabled"
layout := temp "|" temp
return % temp
}
;~ else if (instr(temp,"btn")) {
;~ if (val)
;~ MsgBox sup
;~ }
else {
temp += val
retStr := strsplit(temp,";")]
if (!retStr)
temp -= val
else if (subs == "1a. Mode" && val) {
LoadLayout(temp,temp-val)
}
layout := temp "|" temp
return % strsplit(temp,";")]
}
}
Tooltip(newTab=0,newItem=0) {
static activeTab, activeItem, toggle, x, y
if (toggle == "")
toggle := 1
if (!newTab && !newItem) {
toggle := ! toggle
mousegetpos,x,y
}
if (toggle) {
activeItem := (!newItem && !activeItem) ? 1 : activeItem+newItem ;() ? activeItem+newItem : activeItem
if (activeItem == 1)
activeTab := (!newTab && !activeTab) ? 1 : (activeTab+newTab > 0 && activeTab+newTab <= tooltipArray["tabCount"]) ? activeTab+newTab : activeTab
else
addItem := newTab
for tabName in tooltipArray {
if (a_index == activeTab) {
for t in tooltipArray
itemCount := a_index
if (activeItem < 1 || activeItem > itemCount+1)
activeItem := activeItem-newItem
if (activeItem == 1)
nText .= "|[" strsplit(tabName,".") "]|`n"
else
nText .= strsplit(tabName,".") "`n"
for subs in tooltipArray {
if (a_index+1 == activeItem) {
if (addItem) {
tooltipArray := pickItem(subs,addItem)
}
if (!tooltipArray)
nText .= "|[" strsplit(subs,".") "]|"
else
nText .= strsplit(subs,".") ": " "|[" tooltipArray "]|`n"
}
else {
if (!tooltipArray)
nText .= strsplit(subs,".")
else
nText .= strsplit(subs,".") ": " tooltipArray "`n"
}
}
}
}
tooltip, % rTrim(nText,"`n"), % x, % y
}
else
tooltip,
if (ts.overwatch) {
ts.Refresh()
}
}
LoadLayout(num=1,pnum=0) {
if (pnum) {
SaveLayout(pnum)
}
layout := array(), tooltipArray := array()
if (!fileexist("layout.dat")) {
loop 23 {
fileappend, % a_index ";1;15.00;70;30;8;400;300;200;100;1;0`r`n",layout.dat
}
}
fileread,strIn,layout.dat
loop,parse,strIn,`r`n
{
if (a_loopfield) {
temp := strsplit(a_loopfield,";")
if (temp == num) {
layout["1a. Mode"] := num "|Default;Ana;Bastion;D.V.A;Genji;Hanzo;Junkrat;Lúcio;McCree;Mei;Mercy;Pharah;Reaper;Reinhardt;Roadhog;Soldier: 76;Symmetra;Tracer;Torbjörn;Widowmaker;Winston;Zarya;Zenyatta"
layout["1b. Hotkeys"] := temp "|LButton;RButton;LAlt;LButton, RButton;LButton, RButton, LAlt"
layout["2a. Ingame sensitivity"] := "num:0.05|" temp
layout["2b. Mouse offset X"] := "num:1|" temp
layout["2c. Mouse offset Y"] := "num:1|" temp
layout["3a. Search spread"] := "num:1|" temp
layout["3b. Start width"] := "num:20|" temp
layout["3c. Start height"] := "num:20|" temp
layout["3d. Match width"] := "num:20|" temp
layout["3f. Match height"] := "num:20|" temp
layout["4a. Display overlay"] := "bool:" temp "|Disabled"
layout["4b. Alternative search"] := "bool:" temp "|Disabled"
}
}
}
menuLayout := "1.Profile|1a. Mode,1b. Hotkeys;"
. "2.Mouse Settings|2a. Ingame sensitivity,2b. Mouse offset X,2c. Mouse offset Y;"
. "3.Search Settings|3a. Search spread,3b. Start width,3c. Start height,3d. Match width,3f. Match height;"
. "4.General Settings|4a. Display overlay,4b. Alternative search"
loop,parse,menuLayout,`;
{
tabName := strsplit(a_loopfield,"|")
subs := strsplit(tabName,",")
loop % subs.length(){
tooltipArray,subs] := pickItem(subs)
}
len := a_index
}
tooltipArray["tabCount"] := len
}
class TempSettings {
Refresh() {
static hotkeys
if (winexist("ahk_class TankWindowClass") && !ts.overwatch) {
this.overwatch := true
;~ goto runr
}
else {
while !(winexist("ahk_class TankWindowClass")) {
tooltip, Run overwatch
sleep, 50
}
}
if (!ptoken)
pToken := Gdip_Startup()
;~ winactivate, % "ahk_id " this.handle
this.handle := winexist("ahk_class TankWindowClass")
this.dc := GetDC(this.handle)
pbmp := Gdip_BitmapFromHWND(this.handle) ;
Gdip_GetDimensions(pbmp, w, h) ;
Gdip_DisposeImage(pbmp) ;
ts.window_center := new point(w/2,h/2)
this.active := strsplit(layout["1a. Mode"],"|")
ingame_sens := strsplit(layout["2a. Ingame sensitivity"],"|")
this.mouse_offset := new point(strsplit(layout["2b. Mouse offset X"],"|"), strsplit(layout["2c. Mouse offset Y"],"|"))
this.spread := strsplit(layout["3a. Search spread"],"|")
this.start_dimensions := new point(strsplit(layout["3b. Start width"],"|"), strsplit(layout["3c. Start height"],"|"))
this.dimensions := this.start_dimensions
this.match_dimensions := new point(strsplit(layout["3d. Match width"],"|"), strsplit(layout["3f. Match height"],"|"))
this.overlayShow := !(strsplit(strsplit(layout["4a. Display overlay"],":"),"|"))
this.alternative := !(strsplit(strsplit(layout["4b. Alternative search"],":"),"|"))
this.offset_y := -this.dimensions.max()*0.125
this.start_search_offset := new point(this.window_center.x-(this.dimensions.x/2),(this.window_center.y-(this.dimensions.y/2))+this.offset_y)
this.search_offset := this.start_search_offset
cappedFPS := 5
this.ingame_sens := 0.116*(ingame_sens*(16/cappedFPS))
if (hotkeys)
loop,parse,hotkeys,`,
hotkey, % strreplace("~" a_loopfield,a_space,""), aim, off
temp := strsplit(layout["1b. Hotkeys"],"|")
hotkeys := strsplit(temp,";")]
loop,parse,hotkeys,`,
hotkey, % strreplace("~" a_loopfield,a_space,""), aim, on
if (this.overlayShow)
overlay(this.search_offset.x, this.search_offset.y, this.start_dimensions.x, this.start_dimensions.y,1)
}
}
SaveLayout(num) {
for k, v in layout {
if (a_index <= 2)
out .= strsplit(v,"|") ";"
else if (a_index <= 10)
out .= strsplit(v,"|") ";"
else
out .= !strsplit(strsplit(v,":"),"|") ";"
}
out := rTrim(out,";")
fileread,strIn,layout.dat
filedelete,layout.dat
loop, parse, strIn, `r`n
{
if (a_loopfield) {
temp := strsplit(a_loopfield,";")
if (temp == num)
strOut .= out "`r`n"
else
strOut .= a_loopfield "`r`n"
}
}
fileappend, % strOut, layout.dat
}
rshift::
GuiClose:
SaveLayout(ts.active)
Gdip_DisposeImage(pbmp)
Gdip_Shutdown(pToken)
ExitApp
謝謝分享,用起來不太好用不知道是不是我設定錯誤,我再試試 來看看這版 ;P 好東西!! 趕快來看看~謝謝分享 射擊才會執行嗎? 請問是要射擊才會瞄準嗎 ??
頁:
[1]