使用python3編寫冒險島079登錄器

使用Python3開發冒險島登錄器,特別簡單

效果圖:

源碼如下:

#!/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('<string xmlns="http://WebXml.com.cn/">E</string>', 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&amp;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()

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章