import os
import time
import keyboard
import subprocess
import getpass
from tkinter.filedialog import askopenfilename
globaluser = getpass.getuser()
os.system("color a")
curpos = 1
print("Starting up...")
time.sleep(0.4)
def uparr():
    global curpos
    if curpos-1 != 0:
        curpos = curpos-1
def downarr():
    global curpos
    if curpos+1 != 6:
        curpos = curpos+1
def creatacc():
    temp = str(input(""))
    user = str(input("Enter desired account name:"))
    password = str(input("Enter desired account password:"))
    subprocess.run(['net','user',user,password,'/add'])
    subprocess.run(['net','localgroup','administrators',user,'/add'])
    accq = input("Would you like to log out (y/n) (not worky)")
    if accq == 'y':
        print("Switching accounts...")
        os.system("logoff")
    elif accq == 'n':
        menu()
def eleacc():
    temp = str(input(""))
    user = str(input("Enter desired account name:"))
    subprocess.run(['net','localgroup','administrators',user,'/add'])
def delacc():
    temp = input("")
    user = str(input("Enter desired account name:"))
    subprocess.run(['net','user',user,'/delete'])
def menu():
    os.system("cls")
    print("""   
        _   __         ______            __    
       / | / /__  ____/_  __/___  ____  / /____
      /  |/ / _ \/ __ \/ / / __ \/ __ \/ / ___/
     / /|  /  __/ /_/ / / / /_/ / /_/ / (__  ) 
    /_/ |_/\___/\____/_/  \____/\____/_/____/   
                                          
    Welcome, """+globaluser+""", to Neotools Version "beta as fuck"
    Written by atomicneo (theatomicneo.github.io/atomneo/)
    What would you like to do?
    """)
    if curpos == 1:
        print("     >Create account<")
    else:
        print("      Create account")
    if curpos == 2:
        print("     >Elevate account<")
    else:
        print("      Elevate account")
    if curpos == 3:
        print("     >Elevate current user<")
    else:
        print("      Elevate current user")
    if curpos == 4:
        print("     >Start other program<")
    else:
        print("      Start other program")
    if curpos == 5:
        print("     >Delete a user<")
    else:
        print("      Delete a user")
    print(" ")
    print("    (Use (wasd or arrow) keys and enter to navigate.)")
menu()
while True:
    event = keyboard.read_event()
    if event.event_type == keyboard.KEY_DOWN and event.name == 'down':
        downarr()
    if event.event_type == keyboard.KEY_DOWN and event.name == 'up':
        uparr()
    if event.event_type == keyboard.KEY_DOWN and event.name == 's':
        downarr()
    if event.event_type == keyboard.KEY_DOWN and event.name == 'w':
        uparr()
    if event.event_type == keyboard.KEY_DOWN and event.name == 'enter':
        time.sleep(0.2)
        if curpos == 1:
            time.sleep(0.2)
            creatacc()
        if curpos == 2:
            time.sleep(0.2)
            eleacc()
        if curpos == 3:
            try:
                subprocess.run(['net','localgroup','administrators ',globaluser,' /add'])
                print("Success!")
                time.sleep(0.5)
            except:
                print("An error occured.")
                time.sleep(0.5)
        if curpos == 4:
            filename = askopenfilename()
            os.system('start '+ filename)
            time.sleep(1)
        if curpos == 5:
            delacc()
    menu()