使用python3编写冒险岛079登录器

使用Python3开发冒险岛登录器,特别简单

效果图:

使用python3编写冒险岛079登录器_第1张图片

源码如下:

#!/usr/bin/env python3
# encoding=utf-8
from tkinter import *
from tkinter import messagebox as tkMessageBox
import base64
# import webbrowser
import tkinter as tk
import subprocess
import requests
import re
import os

def name_exist(name):
    url="http://221.10.118.241:55000/ser_user"
    res=requests.post(url,data={"username":name})
    if res.text=="1":
        return True
    else:
        return False

#处理注册
def newuser(name,pwd):
    #声明全局变量,传递给insert
    # global cursor,db
    if name=="" or pwd=="":
        tkMessageBox.showinfo(title='失败', message='账号和密码不能为空!')
        return False
    elif len(pwd)>10:
        tkMessageBox.showinfo(title='失败', message='密码长度不能大于10!')
        return False
    if name_exist(name): #返回正确的值说明用户名存在
            tkMessageBox.showinfo(title='失败', message='用户名已存在!')
            return False
    else:
        url = "http://221.10.118.241:55000/zc_user"
        data2={"username":name,"password":pwd}
        res=requests.post(url,data=data2)
        if res.text=="1":
            tkMessageBox.showinfo(title='成功', message='注册成功,获得的账号为:{} 密码为:{}'.format(name,pwd))
        else:
            tkMessageBox.showinfo(title='成功', message='注册失败!')
#验证是否是qq
def is_qq(qq):
    res=requests.get("http://www.webxml.com.cn/webservices/qqOnlineWebService.asmx/qqCheckOnline?qqCode={}".format(qq))
    result=re.findall('E', res.text)
    if result:
        return False
    else:
        return True
'''
注册账号
'''
def signin():
    win1 = Toplevel()
    width = 410
    height = 300
    # 获取屏幕尺寸以计算布局参数,使窗口居屏幕中央
    screenwidth = win1.winfo_screenwidth()
    screenheight = win1.winfo_screenheight()
    alignstr = '%dx%d+%d+%d' % (width, height, (screenwidth - width) / 2, (screenheight - height) / 2)
    win1.geometry(alignstr)
    # 设置窗口是否可变长、宽,True:可变,False:不可变
    win1.resizable(width=False, height=False)

    z_labe1 = Label(win1, text='注册冒险岛账号')
    z_labe1.place(x=150,y=30)

    z_labe2 = Label(win1, text='QQ:')
    z_labe2.place(x=100,y=80)
    z_sheet_text1 = StringVar()
    z_sheet1 = Entry(win1, textvariable=z_sheet_text1)
    z_sheet1.place(x=150,y=80)

    z_labe3 = Label(win1, text='密码:')
    z_labe3.place(x=100, y=120)
    z_sheet_text2 = StringVar()
    z_sheet2 = Entry(win1, textvariable=z_sheet_text2)
    z_sheet2.place(x=150, y=120)

    z_labe4 = Label(win1, text='确认密码:')
    z_labe4.place(x=75, y=160)
    z_sheet_text3 = StringVar()
    z_sheet3 = Entry(win1, textvariable=z_sheet_text3)
    z_sheet3.place(x=150, y=160)
    def on_click1():
        name = z_sheet_text1.get()
        pwd = z_sheet_text2.get()
        pwd2 = z_sheet_text3.get()
        if is_qq(name):
            if pwd!=pwd2:
                tkMessageBox.showinfo(title='失败', message='两次密码输入不一致,请重新输入!')
            #调用处理新用户窗口
            newuser(str(name),str(pwd))
            win1.destroy()
        else:
            tkMessageBox.showinfo(title='失败', message='注册账号必须使用QQ,请检查是否输入有误!')
            win1.destroy()
    btnz=Button(win1, text="注册", command=on_click1,width=10,bg = "#9393FF",bd=0,fg="#FFFFFF")
    btnz.place(x=180, y=200)

'''修改密码'''
def up_pwd():
    win1 = Toplevel()
    width = 410
    height = 300
    # 获取屏幕尺寸以计算布局参数,使窗口居屏幕中央
    screenwidth = win1.winfo_screenwidth()
    screenheight = win1.winfo_screenheight()
    alignstr = '%dx%d+%d+%d' % (width, height, (screenwidth - width) / 2, (screenheight - height) / 2)
    win1.geometry(alignstr)
    # 设置窗口是否可变长、宽,True:可变,False:不可变
    win1.resizable(width=False, height=False)

    z_labe1 = Label(win1, text='修改账号密码')
    z_labe1.place(x=170,y=30)

    z_labe2 = Label(win1, text='账号:')
    z_labe2.place(x=100,y=80)
    z_sheet_text1 = StringVar()
    z_sheet1 = Entry(win1, textvariable=z_sheet_text1)
    z_sheet1.place(x=150,y=80)

    z_labe3 = Label(win1, text='旧密码:')
    z_labe3.place(x=88, y=120)
    z_sheet_text2 = StringVar()
    z_sheet2 = Entry(win1, textvariable=z_sheet_text2)
    z_sheet2.place(x=150, y=120)

    z_labe4 = Label(win1, text='新密码:')
    z_labe4.place(x=88, y=160)
    z_sheet_text3 = StringVar()
    z_sheet3 = Entry(win1, textvariable=z_sheet_text3)
    z_sheet3.place(x=150, y=160)
    def on_click1():
        #此处需要继续修改
        name = z_sheet_text1.get()
        pwd = z_sheet_text2.get()
        pwd2 = z_sheet_text3.get()

        req_data={
            "username":name,
            "password":pwd2
        }
        url="http://221.10.118.241:5000/up_pwd"
        res=requests.post(url,data=req_data)
        if res.text=="1":
            tkMessageBox.showinfo(title='提示', message='密码修改成功!')
            win1.destroy()
        else:
            tkMessageBox.showinfo(title='提示', message='密码修改失败!')
            win1.destroy()
    btnz=Button(win1, text="确认修改", command=on_click1,width=10,bg = "#9393FF",bd=0,fg="#FFFFFF")
    btnz.place(x=180, y=200)

#退出程序
def quit1():
    root.quit()
#kf
def kefu():
    # webbrowser.open("https://jq.qq.com/?_wv=1027&k=5r8sedg")
    tkMessageBox.showinfo(title='提示', message='暂未开放此功能!')
#登录
def login():
    ocmd="MapleStory.exe "+sheet_text1.get().replace(":"," ")
    print(ocmd)
    os.popen(ocmd)
    open_game()
'''
tasklist
taskkill /pid 9396 -t
'''
def z_popen(cmd):
    try:
        popen = subprocess.Popen(cmd, stdout=subprocess.PIPE)
        lines = popen.stdout.readlines()
        return [line.decode('gbk') for line in lines]
    except Exception as ex:
        pass
'''
打开游戏
'''
def open_game():
    import time
    time.sleep(2)
    #关闭第一个弹窗页面
    cmd_text = z_popen("tasklist")
    for item in cmd_text:
        if "MapleStory.exe" in item:
            print(item)
            data_list = [x for x in item.split(" ") if x]
            n_cmd = "taskkill /pid {} -t".format(data_list[1])
            z_popen(n_cmd)
    time.sleep(2)


if __name__ == '__main__':

    root = tk.Tk()
    root.title('樱木冒险岛登录引导')
    width = 816
    height = 458
    # 增加背景图片
    photo = tk.PhotoImage(file="222.png")
    theLabel = tk.Label(root, image=photo, fg="white")  # 前景色
    theLabel.place(x=0,y=0)
    # 获取屏幕尺寸以计算布局参数,使窗口居屏幕中央
    screenwidth = root.winfo_screenwidth()
    screenheight = root.winfo_screenheight()
    alignstr = '%dx%d+%d+%d' % (width, height, (screenwidth - width) / 2, (screenheight - height) / 2)
    root.geometry(alignstr)
    # 设置窗口是否可变长、宽,True:可变,False:不可变
    root.resizable(width=False, height=False)
    # # ------------------------------------------
    #
    button1 = Button(root, text='注册账号', width=11, command=signin,bg = "#9393FF",fg="#FFFFFF",bd=0)
    button1.place(x=28, y=340)

    button2 = Button(root, text='修改密码', width=11, command=up_pwd,bg = "#9393FF",fg="#FFFFFF",bd=0)
    button2.place(x=122, y=340)

    button3 = Button(root, text='防爆内存', width=11, command=kefu,bg = "#9393FF",fg="#FFFFFF",bd=0)
    button3.place(x=215, y=340)

    button4 = Button(root, text='联系客服', width=11, command=kefu,bg = "#9393FF",fg="#FFFFFF",bd=0)
    button4.place(x=308, y=340)

    button5 = Button(root, text='卡号自救', width=11, command=kefu,bg = "#9393FF",fg="#FFFFFF",bd=0)
    button5.place(x=28, y=385)

    button6 = Button(root, text='礼包兑换', width=11, command=kefu,bg = "#9393FF",fg="#FFFFFF",bd=0)
    button6.place(x=122, y=385)

    button7 = Button(root, text='福利领取', width=11, command=kefu,bg = "#9393FF",fg="#FFFFFF",bd=0)
    button7.place(x=215, y=385)

    #-------------

    labe2 = Label(root, text='服务端IP+端口:', font=("", 11), bg="#FFFFFF",fg="#ADADAD",bd=0)
    labe2.place(x=530, y=340)

    sheet_text1 = StringVar()
    sheet1 = Entry(root, textvariable=sheet_text1,bd=0)
    sheet1.place(x=640, y=340)
    sheet_text1.set("221.10.118.241:3339")

    button8 = Button(root, text='一键进入游戏', width=20,height=2,fg="#FFFFFF", command=login, bg="#6A6AFF", bd=0,activebackground="#DDDDFF")
    button8.place(x=580, y=385)

    tk.mainloop()

 

你可能感兴趣的:(python)