Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
XiaoJiang0208 committed Jan 30, 2024
1 parent aa6db7c commit c8ee27d
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 9 deletions.
24 changes: 18 additions & 6 deletions TKFtool.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from selenium import webdriver
from selenium import webdriver
from selenium.webdriver.common.by import By
import requests
import keyboard as kb
Expand All @@ -7,6 +7,7 @@
import pathlib
import json
import traceback
import atexit


#截图路径
Expand All @@ -31,6 +32,7 @@

tmp=''
def getPosition():
'''获取截图位置信息'''
global tmp
dir=os.listdir(ImgPath)
if len(dir)==0:
Expand All @@ -40,18 +42,21 @@ def getPosition():
return tmp

def InitDir():
'''初始化截图文件夹'''
dir=os.listdir(ImgPath)
for d in dir:
os.remove(ImgPath+d)

def getkb(event):
def setScreenShoot(event):
'''设置自动截图状态'''
global auto
if event.name==on_auto:
auto=True
if event.name==off_auto:
auto=False

def getConfig():
'''获取配置文件配置'''
global ImgPath, sleeptime, on_auto, off_auto, key, roomid, playerid, server
if 'setting.json' not in os.listdir('.\\'):
with open('setting.json','w') as setting:
Expand All @@ -76,11 +81,12 @@ def getConfig():
server=cfg['server']

def getMarker(driver:webdriver.Edge):
'''获取地图标记位置'''
marker=driver.find_element(By.XPATH, "//*[@class='marker']")
return marker.get_attribute('style').rstrip("visibility: hidden;")+";"

def setMarker(driver:webdriver.Edge,id,ps='',color='#f9ff01'):
'''设置新marker'''
'''设置新marker位置'''
if not id:
id='offline'
try:
Expand All @@ -101,23 +107,29 @@ def setMarker(driver:webdriver.Edge,id,ps='',color='#f9ff01'):


def setPlayerData(marker)->dict:
'''上传玩家数据到在线,返回所有玩家数据'''
print({'player':playerid,'marker':marker})
PlayerData=requests.post(server+roomid,json={'player':playerid,'marker':marker}).json()
return PlayerData

"""@atexit.register
def offline():
'''注册退出事件,退出时从服务器离线'''
setPlayerData('')"""#无法使用

if __name__ == "__main__":
getConfig()
driver = webdriver.Edge()
driver.get('https://tarkov-market.com/maps/ground-zero')
InitDir()
kb.on_press(getkb)
kb.on_press(setScreenShoot)#绑定键盘事件调整键盘事件
playerList=[]
while True:
time.sleep(sleeptime)
try:
if auto: #是否自动截图
kb.press_and_release(key)
bt=driver.find_element(By.XPATH, "//*[@placeholder='Paste file name here']")
bt=driver.find_element(By.XPATH, "/html/body/div/div/div/div[2]/div/div/div[1]/div/input")
bt.click()
time.sleep(0.01)
bt.send_keys(getPosition())
Expand All @@ -141,7 +153,7 @@ def setPlayerData(marker)->dict:
except:
print(traceback.format_exc())
try:
driver.find_element(By.XPATH, "//button[contains(text(),'Where am i?')]").click()
driver.find_element(By.XPATH, "/html/body/div/div/div/div[2]/div/div/div[1]/div/button").click()
print('获取输入框。。。')
except:
print('无法打开输入框')
7 changes: 5 additions & 2 deletions TKFtoolServer.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@ def index(page):
if page not in database.keys():
database[page]={}
database[page][player['player']]=player['marker']
#清理正常离线玩家
if player['marker']=='':
database[page].pop(player['player'])
#重置死亡事件
database[page]["borntime"]=int(datetime.datetime.now().strftime("%H"))
database[page]["borntime"]=int(datetime.datetime.now().strftime("%M"))
#垃圾清理
for page in database.keys():
if database[page]["borntime"]<int(datetime.datetime.now().strftime("%H"))-death:
if database[page]["borntime"]<int(datetime.datetime.now().strftime("%M"))-death:
database.pop(page)
#输出数据
for page in database.keys():
Expand Down
11 changes: 10 additions & 1 deletion VPlayer.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,28 @@
import signal
import requests
import json
import time


#房间号
roomid='test'
roomid='test1'
#用户id
playerid='vp'
#联机服务器
server='http://everyspower.xyz:5000/'

def setPlayerData(marker)->dict:
PlayerData=requests.post(server+roomid,json={'player':playerid,'marker':marker}).json()
print(PlayerData)
return PlayerData

"""def offline():
'''注册退出事件,退出时从服务器离线'''
print(1)
setPlayerData('')
signal.signal(signal.SIGINT, offline) # 捕捉 Ctrl+C
signal.signal(signal.SIGTERM, offline)"""#无用😢

if __name__ == "__main__":
i=1600
s=20
Expand Down
Binary file modified dist/TKFtool.exe
Binary file not shown.

0 comments on commit c8ee27d

Please sign in to comment.