Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Auto login script for GMail and MSN Messenger 7


  • Please log in to reply
3 replies to this topic
Martijn
  • Members
  • 1 posts
  • Last active: May 05 2005 09:05 PM
  • Joined: 05 May 2005
Hi all,

I got in to AHK some time ago and I've been experimenting a bit since then, and this is my first fully functional script :)

Features:

- It can sign you in to GMail and MSN Messenger either automatically or by asking for both in one dialog (login name and password)
- Settings are saves in an .ini file (this may be insecure is you choose to save your password for logging in automatically though :( )

But the features aren't the main reason I'm posting this, since they're not that special :wink: . The real reason is that it'd be much appreciated if people would comment on the effectiveness, and maybe give me some tips to make future scripts even better, thanks in advance if you're willing to post such a comment :D

Also maybe this can help out some other beginners too :p

Just try out this script, there's more inside it that you may think :D

; Login script by Martijn
; -----------------------
; Setting properties and variables:

#NoTrayIcon
#singleinstance force
settitlematchmode, 2
setkeydelay, 0
errtext = You've decided to skip the dialog when loading the script, however this option cannot be turned on without autorizing to save all account names and passwords. Due to this, the option will be reset to it's default value.
errtitle = Warning
dlgwarning = You have just succesfully enabled the option to skip the dialog at startup, from now on, running the script will simply log you in without any questions. If you ever want to revert this setting to it's default value, hold Q while starting the script and wait for the Recovery Window to show up. All passwords that are to be used in the future should be entered now, since the dialog won't show anymore after pressing OK the next time.
resettext = The feature to skip the dialog has been bypassed, release the Q button and press OK to continue.
resettitle = Recovery
welcometitle = First Run - Welcome
welcometext = This script was written by Martijn, I hope you'll find use in it =)

; Read settings.ini

iniread, RemMessengerAccount, settings.ini, Remember, MessengerAccount, 1
iniread, RemMessengerPassword, settings.ini, Remember, MessengerPassword, 0
iniread, RemGMailAccount, settings.ini, Remember, GMailAccount, 1
iniread, RemGMailPassword, settings.ini, Remember, GMailPassword, 0
iniread, RemMessengerState, settings.ini, Remember, MessengerState, 1
iniread, RemGMailState, settings.ini, Remember, GMailState, 1
iniread, DialogOnStart, settings.ini, GUI, Show, 1
iniread, DialogCaption, settings.ini, GUI, Caption, 1
iniread, MessengerPath, settings.ini, Paths, Messenger, C:\Program files\MSN Messenger\msnmsgr.exe
iniread, GMailPath, settings.ini, Paths, GMail, C:\Program files\Google\Gmail Notifier\gnotify.exe
iniread, MessengerAccount, settings.ini, DATA, MessengerAccount, 00
iniread, MessengerPassword, settings.ini, DATA, MessengerPassword, 00
iniread, GMailAccount, settings.ini, DATA, GMailAccount, 00
iniread, GMailPassword, settings.ini, DATA, GMailPassword, 00
iniread, MessengerState, settings.ini, DATA, MessengerState, 1
iniread, GMailState, settings.ini, DATA, GMailState, 1

; Checking for First Run:

ifnotexist settings.ini
msgbox, 0, %welcometitle%, %welcometext%

; Emptying some variables containing 00 :)

ifequal, MessengerAccount, 00
	MessengerAccount = 
ifequal, MessengerPassword, 00
	MessengerPassword = 
ifequal, GMailAccount, 00
	GMailAccount = 
ifequal, GMailPassword, 00
	GMailPassword = 

; Check if Q is being pressed (and showing the recovery dialog if so)

getkeystate, QState, Q, P
ifequal, QState, D
{
msgbox, 0, %resettitle%, %resettext%
goto, start
}

; Check if dialog is requested

ifequal, DialogOnStart, 0
	goto, login

; Start tag and GUI loading

start:

Gui, Add, Checkbox, x16 y13 w510 h20 vGMailState Checked%GMailState%, Sign in to GMail:
Gui, Add, Text, x16 y35 w120 h20, Account name:
Gui, Add, Text, x16 y55 w120 h20, Password:
Gui, Add, Edit, x136 y33 w390 h20 vGMailAccount, %GMailAccount%
Gui, Add, Edit, x136 y53 w390 h20 vGMailPassword Password, %GMailPassword%  
Gui, Add, Checkbox, x16 y83 w510 h20 vMessengerState Checked%MessengerState%, Sign in to Messenger:
Gui, Add, Edit, x136 y103 w390 h20 vMessengerAccount, %MessengerAccount%
Gui, Add, Edit, x136 y123 w390 h20 vMessengerPassword Password, %MessengerPassword%
Gui, Add, Text, x16 y105 w120 h20, Account name:
Gui, Add, Text, x16 y125 w120 h20, Password:
Gui, Add, Button, x16 y153 w120 h30, Cancel
Gui, Add, Button, x166 y153 w130 h30, Settings
Gui, Add, Button, x326 y153 w200 h30, OK
ifequal, DialogCaption, 0
gui, -caption
Gui, Show, h194 w540, Log In
Return

; Exit procedure:

GuiClose:
ButtonCancel:
gui, submit
gui, destroy
ifequal, RemMessengerAccount, 1
	iniwrite, %MessengerAccount%, settings.ini, DATA, MessengerAccount
ifequal, RemMessengerPassword, 1
	iniwrite, %MessengerPassword%, settings.ini, DATA, MessengerPassword
ifequal, RemGMailAccount, 1
	iniwrite, %GMailAccount%, settings.ini, DATA, GMailAccount
ifequal, RemGMailPassword, 1
	iniwrite, %GMailPassword%, settings.ini, DATA, GMailPassword
ifequal, RemGMailState, 1
	iniwrite, %GMailState%, settings.ini, DATA, GMailState
ifequal, RemMessengerState, 1
	iniwrite, %MessengerState%, settings.ini, DATA, MessengerState
ExitApp

; Settings dialog loading:

ButtonSettings:
gui, submit
Gui, destroy
Gui, Add, Checkbox, x6 y13 w230 h20 vRemMessengerAccount Checked%RemMessengerAccount%, Remember Messenger Account
Gui, Add, Checkbox, x236 y13 w230 h20 vRemMessengerPassword Checked%RemMessengerPassword%, Remember Messenger Password
Gui, Add, Checkbox, x6 y33 w230 h20 vRemGMailAccount Checked%RemGMailAccount%, Remember GMail Account
Gui, Add, Checkbox, x236 y33 w230 h20 vRemGMailPassword Checked%RemGMailPassword%, Remember GMail Password
Gui, Add, Checkbox, x236 y53 w230 h20 vRemGMailState Checked%RemGMailState%, Remember GMail State
Gui, Add, Checkbox, x6 y53 w230 h20 vRemMessengerState Checked%RemMessengerState%, Remember Messenger State
Gui, Add, Checkbox, x6 y73 w230 h20 vDialogOnStart Checked%DialogOnStart%, Show dialog on start
Gui, Add, Checkbox, x6 y93 w230 h20 vDialogCaption Checked%DialogCaption%, Show captions
Gui, Add, Button, x236 y83 w100 h30, Discard
Gui, Add, Button, x356 y83 w100 h30, Save
Gui, Add, Text, x6 y126 w460 h20, MSN Messenger Path:
Gui, Add, Text, x6 y166 w460 h20, GMail Notifier Path:
Gui, Add, Edit, x6 y143 w460 h20 vMessengerPath, %MessengerPath%
Gui, Add, Edit, x6 y183 w460 h20 vGMailPath, %GMailPath%
ifequal, DialogCaption, 0
gui, -caption
Gui, Show, h218 w475, Settings
Return

; Saving settings and checking wether they're possible to use

ButtonSave:
gui, submit
gui, destroy
ifequal, DialogOnStart, 0
{
ifequal, RemMessengerAccount, 0
{
msgbox, 0, %errtitle%, %errtext%
DialogOnStart = 1
goto, save
}
ifequal, RemMessengerPassword, 0
{
msgbox, 0, %errtitle%, %errtext%
DialogOnStart = 1
goto, save
}
ifequal, RemGMailAccount, 0
{
msgbox, 0, %errtitle%, %errtext%
DialogOnStart = 1
goto, save
}
ifequal, RemGMailPassword, 0
{
msgbox, 0, %errtitle%, %errtext%
DialogOnStart = 1
goto, save
}
msgbox, 0, %errtitle%, %dlgwarning%
}
save:
ifequal, RemMessengerAccount, 0
	inidelete, settings.ini, DATA, MessengerAccount
ifequal, RemMessengerPassword, 0
	inidelete, settings.ini, DATA, MessengerPassword
ifequal, RemGMailAccount, 0
	inidelete, settings.ini, DATA, GMailAccount
ifequal, RemGMailPassword, 0
	inidelete, settings.ini, DATA, GMailPassword
ifequal, RemGMailState, 0
	inidelete, settings.ini, DATA, GMailState
ifequal, RemMessengerState, 0
	inidelete, settings.ini, DATA, MessengerState
iniwrite, %MessengerPath%, settings.ini, Paths, Messenger
iniwrite, %GMailPath%, settings.ini, Paths, GMail
iniwrite, %RemMessengerAccount%, settings.ini, Remember, MessengerAccount
iniwrite, %RemMessengerPassword%, settings.ini, Remember, MessengerPassword
iniwrite, %RemGMailAccount%, settings.ini, Remember, GMailAccount
iniwrite, %RemGMailPassword%, settings.ini, Remember, GMailPassword
iniwrite, %RemGMailState%, settings.ini, Remember, GMailState
iniwrite, %RemMessengerState%, settings.ini, Remember, MessengerState
iniwrite, %DialogOnStart%, settings.ini, GUI, Show
iniwrite, %DialogCaption%, settings.ini, GUI, Caption
goto, start

; Discard settings when discard is pressed:

ButtonDiscard:
gui, destroy
goto, start

; Saving settings on OK and continueing to login procedure:

ButtonOK:
Gui, submit
gui, destroy
ifequal, RemMessengerAccount, 1
	iniwrite, %MessengerAccount%, settings.ini, DATA, MessengerAccount
ifequal, RemMessengerPassword, 1
	iniwrite, %MessengerPassword%, settings.ini, DATA, MessengerPassword
ifequal, RemGMailAccount, 1
	iniwrite, %GMailAccount%, settings.ini, DATA, GMailAccount
ifequal, RemGMailPassword, 1
	iniwrite, %GMailPassword%, settings.ini, DATA, GMailPassword
ifequal, RemGMailState, 1
	iniwrite, %GMailState%, settings.ini, DATA, GMailState
ifequal, RemMessengerState, 1
	iniwrite, %MessengerState%, settings.ini, DATA, MessengerState

; Start of login precedure:

login:
ifequal GMailState, 1
{
run, %GMailPath%
winwait, www.google.com
winactivate, www.google.com
winwaitactive, www.google.com
controlsendraw, Edit2, %GMailAccount%
controlsendraw, Edit3, %GMailPassword%
send, {ENTER}
}
ifequal, MessengerState, 1
{
run, %MessengerPath%
winwait, MSN Messenger
winactivate, MSN Messenger
winwaitactive, MSN Messenger
controlsend, DirectUIHWND1, {ENTER}
winwait, .NET Messenger Service
winactivate, .NET Messenger Service
winwaitactive, .NET Messenger Service
controlsendraw, Edit2, %MessengerAccount%
controlsendraw, Edit3, %MessengerPassword%
send, {ENTER}
}
exitapp


nyanimefool
  • Members
  • 13 posts
  • Last active: Jul 29 2005 03:45 PM
  • Joined: 04 Jul 2005
I haven't tried your script yet but I will when I get home tonight. I e-mailed the gMail people about this but I'm sure they won't get back to me anytime soon. I have 2 gMail accounts and only 1 notifier. When I turn on another one, I don't have the option of checking the 'other' e-mail by clicking on the notifier in the system tray. The 2 icons in the system tray leads me to the same account.

2 suggestions that I hope you can help me with.

1. The obvious one which is a notifier that allows me to switch between accounts easily and still tells me when I have new e-mail.

2. In regards to the storing of my password, I do that now with so is that unsafe since I don't even know where I store my password with the notifier. Is there a way to have the ini file deleted upon logging off or restarting?

  • Guests
  • Last active:
  • Joined: --

I have 2 gMail accounts and only 1 notifier. When I turn on another one, I don't have the option of checking the 'other' e-mail by clicking on the notifier in the system tray. The 2 icons in the system tray leads me to the same account.

Subscribe to the RSS feeds of your inboxes. This way you can monitor multiple accounts simultaneously.

  • Guests
  • Last active:
  • Joined: --
http://mail.google.c... ... swer=13465