满血外置准星开发完成,遵循MIT协议开源公布
如果你喜欢这个小作品,欢迎考虑在GitHub上打个标,感谢支持
GitHub - lixinhe4090/External_crosshair: Draw an external crosshair on top of the shooter!
游览器访问 lixinhe4090/External_crosshair: 在射手顶部画一个外部十字准线!
详见README.md文件
访问不上的同学,为各位附上源代码:
import tkinter as tk
import pyautogui# 初始化屏幕参数
screen_width, screen_height = pyautogui.size()
center_x, center_y = screen_width // 2, screen_height // 2# 创建透明窗口
window = tk.Tk()
window.overrideredirect(True)
window.attributes("-transparentcolor", "white", "-topmost", True, "-alpha", 0.5)
window.geometry(f"{screen_width}x{screen_height}+0+0")
window.configure(bg="white")# 创建画布
canvas = tk.Canvas(window, bg="white", highlightthickness=0)
canvas.pack(fill=tk.BOTH, expand=True)# 准星样式
def shotgun_crosshair():# 霰弹枪:一个圆,分成4段 + 中间一个点canvas.create_oval(center_x - 30, center_y - 30, center_x + 30, center_y + 30, outline="red", width=2)canvas.create_oval(center_x - 2, center_y - 2, center_x + 2, center_y + 2, fill="red", outline="red")def smg_rifle_sniper_crosshair():# 冲锋枪、步枪、狙击枪:默认的十字准星canvas.create_line(center_x - 50, center_y, center_x + 50, center_y, fill="red", width=2)canvas.create_line(center_x, center_y - 50, center_x, center_y + 50, fill="red", width=2)def rpg_crosshair():radius = 30canvas.create_oval(center_x - radius, center_y - radius, center_x + radius, center_y + radius, outline="red", width=2)canvas.create_line(center_x - radius, center_y, center_x + radius, center_y, fill="red", width=2)canvas.create_line(center_x, center_y - radius, center_x, center_y + radius, fill="red", width=2)def vehicle_crosshair():# 载具:正方形 + 十字准星size = 30canvas.create_rectangle(center_x - size, center_y - size, center_x + size, center_y + size, outline="red", width=2)canvas.create_line(center_x - 50, center_y, center_x + 50, center_y, fill="red", width=2)canvas.create_line(center_x, center_y - 50, center_x, center_y + 50, fill="red", width=2)def custom_crosshair():# 自定义准星样式line_length = 30gap = 10line_width = 2dot_radius = 2canvas.create_line(center_x - line_length, center_y, center_x - gap, center_y, width=line_width, fill="red")canvas.create_line(center_x + gap, center_y, center_x + line_length, center_y, width=line_width, fill="red")canvas.create_line(center_x, center_y - line_length, center_x, center_y - gap, width=line_width, fill="red")canvas.create_line(center_x, center_y + gap, center_x, center_y + line_length, width=line_width, fill="red")canvas.create_oval(center_x - dot_radius, center_y - dot_radius, center_x + dot_radius, center_y + dot_radius, fill="red", outline="red")# 准星字典
crosshairs = {"Shotgun": shotgun_crosshair,"SMG/Rifle/Sniper": smg_rifle_sniper_crosshair,"RPG": rpg_crosshair,"Vehicle": vehicle_crosshair,"Custom": custom_crosshair
}# 切换准星
current_index = 0
crosshair_keys = list(crosshairs.keys())def switch_crosshair(event):global current_indexcanvas.delete("all") # 清除当前准星if event.keysym == "Prior": # Page Upcurrent_index = (current_index - 1) % len(crosshair_keys)elif event.keysym == "Next": # Page Downcurrent_index = (current_index + 1) % len(crosshair_keys)crosshairs[crosshair_keys[current_index]]() # 绘制新的准星# 绑定按键事件
window.bind("<Prior>", switch_crosshair) # Page Up
window.bind("<Next>", switch_crosshair) # Page Down# 初始化第一个准星
crosshairs[crosshair_keys[current_index]]()# 运行主循环
window.mainloop()'''MIT LicenseCopyright (c) 2025 Muze LiPermission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.'''
常见问题解答(Q&A)
1.如何使用?答:建议使用第三方工具将PY打包为EXE运行,防止IDE占用后台过于严重
2.为什么点PU和PD后没有反应?答:你需要用鼠标点击准星选中(图层),后可以用PU/PD或这其他快捷键
3.如何结束这个应用?答:使用CMD,任务管理器,或根据问题2的操作方法进行ALT+F4
4.游戏兼容性:这个程序兼容几乎所有系统和游戏,但是请确保使用的公平性,不作为外挂使用!
如果还有其它问题欢迎咨询