Sign in to follow this  
Followers 0
Hawkwing

username and password script

9 posts in this topic

I want to make some scripts that automate things that have username and password. I want to have it create a place for you to enter your username and password and save them so you don't have to enter them again. But I also want to have set a hotkey to change the username and password that it will use.


The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again.

Share this post


Link to post
Share on other sites



I can make the gui that asks for the username and password, I just don't know how to have it save these so that I don't have to re-enter them every time I run it. I also don't know how to set up a hotkey to change the username and password. I have used hotkeys before, I just don't know how to make it change the saved username and password.


The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again.

Share this post


Link to post
Share on other sites

check out iniwrite and iniread, or just keep that exe running all the time and assign the controls to variables

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

OK, I'm making this so that I can later edit it to use for different things. This is what I have so far.

CODE
#include <GUIConstantsEx.au3>

#include <EditConstants.au3>

$nameofappfolder = "" ;Write the name of the app folder here. NOTE: this assumes that the folder is located in the Program Files folder on your C drive.

$nameofapp = "" ;Write the name of the executable file here WITHOUT the .exe at the end.

If Not FileExists ("C:\Program Files\UserPassAU3\"$nameofapp.ini"") Then :)

FileOpen ("C:\Program Files\UserPassAU3\"$nameofapp.ini"")

FileClose ("C:\Program Files\UserPassAU3\"$nameofapp.ini"")

Opt ("GUIOnEventMode", 1)

GUICreate ("Enter your Username and Password", 200, 140, 200, 200)

GUICtrlCreateLabel ("Enter Username", 5, 5)

GUICtrlCreateLabel ("Enter Password", 5, 40)

GUICtrlCreateLabel ("Enter File Location", 5, 75)

$inputuser = GUICtrlCreateInput ("", 5, 18, 190)

$inputpass = GUICtrlCreateInput ("", 5, 53, 190, , $ES_PASSWORD)

$inputfilelocation = GUICtrlCreateInput ("", 5, 88, 190)

$userpassok = GUICtrlCreateButton ("OK", 5, 113, 190)

GUICtrlSetOnEvent (-1, "userpassok")

GUISetState (@SW_SHOW)

EndIf

FileOpen ("C:\Program Files\$nameofappfolder\"$nameofapp.exe"")

Sleep (2000)

MouseClick ("left", , ) ;put the x and y coordinates of the username box

Send ($readfilelocation)

Func userpassok ()

$readuser = GUICtrlRead ($inputuser)

$readpass = GUICtrlRead ($inputpass)

$readfilelocation = GUICtrlRead ($inputfilelocation)

IniWrite ("C:\Program Files\UserPassAU3\"$nameofapp.ini", "$nameofapp", ""Username", ""$readuser"")

IniWrite ("C:\Program Files\UserPassAU3\"$nameofapp.ini", "$nameofapp"", "Password", ""$readpass"")

IniWrite ("C:\Program Files\UserPassAU3\"$nameofapp.ini", "$nameofapp"", "File Location", ""$readfilelocation"")

EndFunc

it has an error on line 21 (If Not FileExists ("C:\Program Files\UserPassAU3\"$nameofapp.ini"") Then) that says variable must me of type "Object".

Edited by pigeek

The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

OK, I'm making this so that I can later edit it to use for different things. This is what I have so far.

CODE
#include <GUIConstantsEx.au3>

#include <EditConstants.au3>

$nameofappfolder = "" ;Write the name of the app folder here. NOTE: this assumes that the folder is located in the Program Files folder on your C drive.

$nameofapp = "" ;Write the name of the executable file here WITHOUT the .exe at the end.

If Not FileExists ("C:\Program Files\UserPassAU3\"$nameofapp.ini"") Then :)

FileOpen ("C:\Program Files\UserPassAU3\"$nameofapp.ini"")

FileClose ("C:\Program Files\UserPassAU3\"$nameofapp.ini"")

Opt ("GUIOnEventMode", 1)

GUICreate ("Enter your Username and Password", 200, 140, 200, 200)

GUICtrlCreateLabel ("Enter Username", 5, 5)

GUICtrlCreateLabel ("Enter Password", 5, 40)

GUICtrlCreateLabel ("Enter File Location", 5, 75)

$inputuser = GUICtrlCreateInput ("", 5, 18, 190)

$inputpass = GUICtrlCreateInput ("", 5, 53, 190, , $ES_PASSWORD)

$inputfilelocation = GUICtrlCreateInput ("", 5, 88, 190)

$userpassok = GUICtrlCreateButton ("OK", 5, 113, 190)

GUICtrlSetOnEvent (-1, "userpassok")

GUISetState (@SW_SHOW)

EndIf

Func userpassok ()

$readuser = GUICtrlRead ($inputuser)

$readpass = GUICtrlRead ($inputpass)

$readfilelocation = GUICtrlRead ($inputfilelocation)

IniWrite ("C:\Program Files\UserPassAU3\"$nameofapp.ini", "$nameofapp", ""Username", ""$readuser"")

IniWrite ("C:\Program Files\UserPassAU3\"$nameofapp.ini", "$nameofapp"", "Password", ""$readpass"")

IniWrite ("C:\Program Files\UserPassAU3\"$nameofapp.ini", "$nameofapp"", "File Location", ""$readfilelocation"")

FileOpen ("C:\Program Files\$nameofappfolder\"$nameofapp.exe"")

Sleep (2000)

MouseClick ("left", , ) ;put the x and y coordinates of the username box

Send ($readfilelocation)

EndFunc

it has an error on line 21 (If Not FileExists ("C:\Program Files\UserPassAU3\"$nameofapp.ini"") Then) that says variable must me of type "Object".
You have to learn how to properly concatenate strings with variables and such:
If Not FileExists(@ProgramFilesDir & "\UserPassAU3\" & $nameofapp.ini) Then
Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

Thanks, I'll try and fix it. :)


The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again.

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

:) Aha, I finally got it! Here's the script.

CODE
#include <GUIConstantsEx.au3>

#include <EditConstants.au3>

#include <File.au3>

HotKeySet ("{printscreen}", "changeini")

$nameofini = ".ini" ;Write the name of the executable file here but replace the .exe with .ini

If Not FileExists (@ProgramFilesDir & "\UserPassAU3\" & $nameofini) Then

_FileCreate (@ProgramFilesDir & "\UserPassAU3\" & $nameofini)

Opt ("GUIOnEventMode", 1)

$UandPgui = GUICreate ("Enter U & P", 200, 140, 200, 200)

GUICtrlCreateLabel ("Enter Username", 5, 5)

GUICtrlCreateLabel ("Enter Password", 5, 40)

GUICtrlCreateLabel ("Enter File Location", 5, 75)

$inputuser = GUICtrlCreateInput ("", 5, 18, 190)

$inputpass = GUICtrlCreateInput ("", 5, 53, 190, "", $ES_PASSWORD)

$inputfilelocation = GUICtrlCreateInput ("", 5, 88, 190)

$userpassok = GUICtrlCreateButton ("OK", 5, 113, 190)

GUICtrlSetOnEvent (-1, "userpassok")

GUISetState (@SW_SHOW)

WinWaitClose ("Enter U & P")

EndIf

$iniuser = IniRead (@ProgramFilesDir & "\UserPassAU3\" & $nameofini, $nameofini, "Username", "No Username")

$inipass = IniRead (@ProgramFilesDir & "\UserPassAU3\" & $nameofini, $nameofini, "Password", "No Password")

$inifilelocation = IniRead (@ProgramFilesDir & "\UserPassAU3\" & $nameofini, $nameofini, "File Location", "No Username")

Sleep (2000)

RunWait ($inifilelocation)

MouseClick ("left", , ) ;put the x and y coordinates of the username box

Sleep (100)

Send ($iniuser)

Sleep (100)

Send ("{tab}")

Sleep (100)

Send ($inipass)

Sleep (100)

Send ("{enter}")

Func userpassok ()

$readuser = GUICtrlRead ($inputuser)

$readpass = GUICtrlRead ($inputpass)

$readfilelocation = GUICtrlRead ($inputfilelocation)

IniWrite (@ProgramFilesDir & "\UserPassAU3\" & $nameofini, $nameofini, "Username", $readuser)

IniWrite (@ProgramFilesDir & "\UserPassAU3\" & $nameofini, $nameofini, "Password", $readpass)

IniWrite (@ProgramFilesDir & "\UserPassAU3\" & $nameofini, $nameofini, "File Location", $readfilelocation)

GUIDelete ($UandPgui)

EndFunc

Func changeini ()

Opt ("GUIOnEventMode", 1)

GUICreate ("Enter your Username and Password", 200, 140, 200, 200)

GUICtrlCreateLabel ("Enter Username", 5, 5)

GUICtrlCreateLabel ("Enter Password", 5, 40)

GUICtrlCreateLabel ("Enter File Location", 5, 75)

$inputuser = GUICtrlCreateInput ("", 5, 18, 190)

$inputpass = GUICtrlCreateInput ("", 5, 53, 190, "", $ES_PASSWORD)

$inputfilelocation = GUICtrlCreateInput ("", 5, 88, 190)

$userpassok = GUICtrlCreateButton ("OK", 5, 113, 190)

GUICtrlSetOnEvent (-1, "userpassok")

GUISetState (@SW_SHOW)

WinWaitClose ("Enter U & P")

EndFunc

I decided not to have the username box x,y coordinates be variables, so I'll have to edit the script when I want to adapt it to anything, but at least it works!

Thanks SmOke_N, and bob00037 for the help! :lmao:

Edited by pigeek

The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again.

Share this post


Link to post
Share on other sites

np its why we are here

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0