update 2024/9/26

This commit is contained in:
Dengrb 2024-09-26 18:01:24 +08:00
parent 0f74c8fc48
commit cedfd837eb
12 changed files with 140 additions and 101 deletions

3
.idea/.gitignore generated vendored Normal file
View File

@ -0,0 +1,3 @@
# 默认忽略的文件
/shelf/
/workspace.xml

View File

@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

7
.idea/misc.xml generated Normal file
View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Black">
<option name="sdkName" value="Python 3.11" />
</component>
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11" project-jdk-type="Python SDK" />
</project>

8
.idea/modules.xml generated Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/python.iml" filepath="$PROJECT_DIR$/.idea/python.iml" />
</modules>
</component>
</project>

8
.idea/python.iml generated Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

6
.idea/vcs.xml generated Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

View File

@ -1,36 +0,0 @@
# Python_flie
#### Description
{**When you're done, you can delete the content in this README and update the file with details for others getting started with your repository**}
#### Software Architecture
Software architecture description
#### Installation
1. xxxx
2. xxxx
3. xxxx
#### Instructions
1. xxxx
2. xxxx
3. xxxx
#### Contribution
1. Fork the repository
2. Create Feat_xxx branch
3. Commit your code
4. Create Pull Request
#### Gitee Feature
1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md
2. Gitee blog [blog.gitee.com](https://blog.gitee.com)
3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore)
4. The most valuable open source project [GVP](https://gitee.com/gvp)
5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help)
6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)

View File

@ -1 +1,3 @@
**_本仓库为私人仓库_**
**b667c019058732967262412c7aee4475** **b667c019058732967262412c7aee4475**

View File

@ -1,65 +0,0 @@
import ctypes
import sys
import os
from time import sleep
import shelve
path = os.getcwd()
with shelve.open('main.db') as db:
bin_name = db['bin_name']
db.close()
print(path)
def is_admin():
# 检查当前是否有管理员权限
try:
return ctypes.windll.shell32.IsUserAnAdmin()
except:
return False
if is_admin():
# 如果已经是管理员,执行主要的逻辑
while True:
print("已获得管理员权限")
print(f"当前模式(1为cs原版,2为csso):{bin_name}")
print("请选择模式")
print("1.改为csso 2.改回原版 3.退出")
ip = input(int('>>>'))
# 逻辑系统bin2为csso文件 bin1为cs原版文件 bin为现在使用的游戏文件
if ip == int(1):
if bin_name == int(1):
print('错误,你已是原版')
sleep(1.5)
sys.exit()
os.system(f"ren {path}/bin {path}/bin1")
os.system(f"ren {path}/bin2 {path}/bin")
with shelve.open('main.db') as db:
db['bin_name'] = int(1)
db.close()
print("完成!")
sleep(1.85)
sys.exit()
elif ip == int(2):
if bin_name == int(2):
print("错误,你已是csso!")
sleep(1.5)
sys.exit()
os.system(f"ren {path}/bin {path}/bin2")
os.system(f"ren {path}/bin1 {path}/bin")
with shelve.open('main.db') as db:
db['bin_name'] = int(2)
db.close()
print("完成!")
sleep(1.55)
sys.exit()
elif ip == int(3):
sys.exit()
else:
print("输入错误!")
else:
# 如果没有管理员权限,重新以管理员权限运行脚本
print("请求管理员权限...")
# 使用 `ctypes` 模块提升权限,重新运行脚本
ctypes.windll.shell32.ShellExecuteW(None, "runas", sys.executable, " ".join(sys.argv), None, 1)

82
change/change.py Normal file
View File

@ -0,0 +1,82 @@
import ctypes
import sys
import os
from time import sleep
import shelve
def get_path(relative_path):
try:
path = sys._MEIPASS # pyinstaller 打包后的路径
except AttributeError:
path = os.path.abspath(".") # 当前工作目录的路径
return os.path.normpath(os.path.join(path, relative_path)) # 返回实际路径
with shelve.open('main.db') as db:
# 如果数据库中没有 'bin_name',返回 '1'(默认值)
bin_name = db.get('bin_name', '1')
if bin_name is None:
os.startfile(get_path('load.exe'))
def is_admin():
"""检查当前是否有管理员权限"""
try:
return ctypes.windll.shell32.IsUserAnAdmin()
except:
return False
if is_admin():
# 如果已经是管理员,执行主要的逻辑
print("已获得管理员权限")
print(f"当前模式(1为CS原版, 2为CS:SO): {bin_name}")
print("请选择模式")
print("1. 改为CS:SO\n2. 改回原版\n3. 退出")
choice = input('>>> ')
path = get_path('') # 获取当前工作目录的实际路径
if choice == '1':
if bin_name == '2':
print('错误你已是CS:SO!')
sleep(1.5)
sys.exit()
# 切换到 CS:SO
os.system(f"ren {path}/bin {path}/bin1")
os.system(f"ren {path}/bin2 {path}/bin")
with shelve.open('main.db') as db:
db['bin_name'] = '2' # 切换至 CS:SO
print("完成!")
sleep(1.85)
sys.exit()
elif choice == '2':
if bin_name == '1':
print("错误,你已是原版!")
sleep(1.5)
sys.exit()
# 切换到原版 CS
os.system(f"ren {path}/bin {path}/bin2")
os.system(f"ren {path}/bin1 {path}/bin")
with shelve.open('main.db') as db:
db['bin_name'] = '1' # 切换至 CS 原版
print("完成!")
sleep(1.55)
sys.exit()
elif choice == '3':
sys.exit()
else:
print("输入错误!")
else:
# 如果没有管理员权限,重新以管理员权限运行脚本
print("请求管理员权限...")
# 使用 `ctypes` 模块提升权限,重新运行脚本
ctypes.windll.shell32.ShellExecuteW(None, "runas", sys.executable, " ".join(sys.argv), None, 1)

8
change/load.py Normal file
View File

@ -0,0 +1,8 @@
import shelve
#初始化数据库文件
with shelve.open('main') as db:
db['bin_name'] = 1
db.close()
exit()

10
pyinstaller_sys.py Normal file
View File

@ -0,0 +1,10 @@
import sys
import os
def get_path(relative_path):
try:
base_path = sys._MEIPASS # pyinstaller打包后的路径
except AttributeError:
base_path = os.path.abspath(".") # 当前工作目录的路径
return os.path.normpath(os.path.join(base_path, relative_path)) # 返回实际路径