Nervous about posting code since i don't wanna be responsible for folks laughing themselves to death @ my ineptitude but here goes!
And yes Sergio...i am a sensei.
Main Code:
SetTitleMatchMode 2
setwindelay, 1500
fileread, exists, C:\temp\bnsfinfo.ini
if errorlevel ;if file doesn't exist
{
; call script to create .ini files for info
run "C:\users\justin\desktop\unpwsetup.ahk"
pause
gosub, finishsub
}
else
{
gosub, pwsub
return
}
finishsub:
Run "C:\Program Files\Internet Explorer\iexplore.exe"
https://www.bnsf.com/bnsf.was6/emu/main
Mousemove, 0,0
Sleep, 3000
iniread, UN, C:\temp\bnsfinfo.ini, section1, username
iniread, PW, C:\temp\bnsfinfo.ini, section2, password
winwait, Mainframe Login
winactivate, Mainframe Login
statusbarwait, Done, 45
if errorlevel
{
msgbox, The page did not load or was closed!
exitapp
}
else
send %UN%{tab}%PW%{enter}
winwait, Security Warning
send {enter}
winwait, Security Warning
send {enter}
Winwait, WebConnect
winactivate, WebConnect
winmove, WebConnect,,440,300
click 200,300
send bnsf
setkeydelay, 500
send {enter}
setkeydelay, 10
send %UN%{tab}%PW%
setkeydelay, 500
send {enter}
setkeydelay, 10
send nattey{space}
setkeydelay, 500
send {enter}{enter}{enter}
iniread, HTC, C:\temp\bnsfinfo.ini, section3, HomeCity
iniread, HTS, C:\temp\bnsfinfo.ini, section4, HomeState
iniread, POC, C:\temp\bnsfinfo.ini, section5, OfficeCode
StringLen, citylen, HTC
StringLen, statelen, HTS
StringLen, codeLen, POS
If CityLen<2
{
msgbox, city too short
Exitapp
}
Else If StateLen<2
{
msgbox, state too short
ExitApp
}
Else
send 8{enter}14{enter}
setkeydelay, 10
send %HTC%{space}%HTS%
If codelen<2
Send 01{enter}{F12}
Else
Send %POC%{enter}{F12}
ExitApp
pwsub:
MsgBox, 4387,P/W Option,Change Your Password?
IfMsgBox, No
Gosub, finishsub
else IfMsgBox, Cancel
exitapp
else IfMsgBox, Yes
{
iniread, pwtemp, C:\temp\bnsfinfo.ini, section2, password
Gui, +alwaysontop +owndialogs
Gui, Font, s10, arial
Gui, Add, Text, Enter your new 8 digit BNSF password.
Gui, Font, s8, arial
Gui, add, text, (This DOES NOT affect your password for BNSF!)
Gui, add, edit, +limit8 +number vbnsfpw
gui, add, button, default section, OK
Gui, show, w300h200 -sysmenu, New Password
Return
}
ButtonOK:
Gui, Submit
StringLen, length, bnsfpw
ifequal, length, 8
{
iniwrite, %bnsfpw%, C:\temp\bnsfinfo.ini, section2, password
goto, finishsub
}
else
goto, finishsub
unpwsetup code:
gui, +alwaysontop +owndialogs
Gui, font, s10, arial
Gui, Add, Text, w350, Enter your login information to setup AutoLogin
Gui, Add, Text,section, UserName(b number):
Gui, Add, Text,, Password:
Gui, Add, Edit, vbnsfun +limit8 ys ; The ym option starts a new column of controls.
Gui, Add, Edit, vbnsfpw +limit8 +number +password*
Gui, Add, Button, default section, OK
gui, add, button,ys, Cancel
Gui, Show,w400h200, AutoLogin Setup
return ; End of auto-execute section. The script is idle until the user does something.
GuiClose:
ButtonCancel:
DetectHiddenWindows On
SetTitleMatchMode 2
WinClose, emulator3.ahk
ExitApp
ButtonOK:
Gui, Submit ; Save the input from the user to each control's associated variable.
iniwrite, %bnsfun%, C:\temp\bnsfinfo.ini, section1, username
iniwrite, %bnsfpw%, C:\temp\bnsfinfo.ini, section2, password
run "C:\users\justin\desktop\bnhtsetup.ahk"
exitapp
return
bnhtsetup code:
;this code sets up special info
{
Gui, +Alwaysontop +owndialogs
Gui, font, s10, arial
Gui, Add, Text, W350, Enter Home Terminal Information.
Gui, font, s8, arial
Gui, Add, text, w350, (If You don't know, Click Cancel! You can add this later)
Gui, Font, s10, arial
Gui, Add, text, section, Program 333 city:
Gui, add, text,, State(ex. AZ):
Gui, add, text,, Program Office Code(ex. 01):
gui, add, edit, vHomeCity +limit9 +uppercase ys
gui, add, edit, vHomeSt +limit2 +uppercase
Gui, add, edit, vOffcode +limit2 +number
Gui, add, Button, default section, OK
Gui, add, Button, ys, Cancel
Gui, Show, w400h300 -sysmenu, Autologin Setup
Return
guiClose:
guiescape:
ButtonCancel:
ButtonOK:
Gui, Submit
iniwrite, %HomeCity%, C:\temp\bnsfinfo.ini, section3, HomeCity
iniwrite, %HomeSt%, C:\temp\bnsfinfo.ini, section4, HomeState
iniwrite, %OffCode%, C:\temp\bnsfinfo.ini, section5, OfficeCode
Detecthiddenwindows, on
settitlematchmode, 2
PostMessage, 0x111, 65306,,, emulator3.ahk
exitapp
}
Prolly easier ways to do this but this is what i got! Also for diagnostic purposes it'll be hard cuz can't actually be done w/o proper login information! Any help tho i appreciate!
So when i tried to put it all in one script w/gui's in separate subroutines i get the 'duplicate labels' error. All i could find was ways to change name of gui so can be called by another one.