Hey there,
I am very glad to have found this forum, I didn't think anyone still used this program. I work at a large company and I have been trying to figure out ways to make things more efficient. I noticed that everyone at the company logged into our program having to type several commands and I thought that was pretty annoying, so I tried making a login script using some code I found on this message board, the input dialog post.
The problem I am having with it is that when the user finishes inputting the User Id #: and then hits enter instead of clicking the OK button, it does not capture the User Id#. Also, how do I get the whole thing to cancel and stop if the user clicks the cancel button?
here is a screenshot of the dialog box:
here is the code:
Thank you very much.
I am very glad to have found this forum, I didn't think anyone still used this program. I work at a large company and I have been trying to figure out ways to make things more efficient. I noticed that everyone at the company logged into our program having to type several commands and I thought that was pretty annoying, so I tried making a login script using some code I found on this message board, the input dialog post.
The problem I am having with it is that when the user finishes inputting the User Id #: and then hits enter instead of clicking the OK button, it does not capture the User Id#. Also, how do I get the whole thing to cancel and stop if the user clicks the cancel button?
here is a screenshot of the dialog box:

here is the code:
Code:
Declare Function WaitClock
Declare Function FileDlgFunction(identifier$, action, suppvalue)
Dim UserInput(4) as string
GLOBAL MyScreen as Object
GLOBAL Sess0 as Object
GLOBAL System as Object
Sub Main()
Dim http as object
Dim Vers as integer
Set System = CreateObject("EXTRA.System") ' Gets the system object
Set Sess0 = System.ActiveSession
Set MyScreen = Sess0.Screen
Vers = 3
Set http = CreateObject("Microsoft.XMLHTTP")
Updater = "[URL unfurl="true"]http://xxxxxxxxxx/macros/login.asp"[/URL]
http.Open "GET", Updater, False
http.Send
if right(http.responseText,1) <> CStr(Vers) then
if (Dir$(ServerName + SavePath + "login4.ebm") <> "") then
FileCopy ServerName + SavePath +"login4.ebm", "C:\\program files\\e!pc\\macros\\login4.ebm"
end if
end if
Screen = Trim(Sess0.Screen.GetString(2, 2, 7)) ' Get current screen name.
if Screen <> "WELCOME" then
MsgBox "You must be at the Welcome Screen to use the Login Macro. Please Disconnect and Reconnect in the Session Menu."
Exit Sub
end if
Begin Dialog userdialog 118, 87, "User Login", .FileDlgFunction
TextBox 48, 7, 65, 9, .TextBox1
TextBox 48, 22, 65, 9, .TextBox2
TextBox 48, 38, 65, 9, .TextBox3
TextBox 48, 54, 65, 9, .TextBox4
OkButton 11, 70, 35, 14
CancelButton 68, 70, 30, 14
Text 6, 6, 40, 8, "Username:"
Text 6, 22, 40, 8, "Password:"
Text 6, 38, 40, 9, "District:"
Text 6, 53, 40, 12, "User ID #:"
End Dialog
Dim mydialog as UserDialog
On Error Resume Next
Dialog mydialog
If Err=102 then
MsgBox "Dialog box canceled."
End If
Dim Username
Dim Password
Dim District
Dim UserIDNum
Username = UserInput(1)
Password = UserInput(2)
District = UserInput(3)
UserIDNum = UserInput(4)
'for x = 1 to 4
' msgbox "UserInput "+str(x)+" = "+ UserInput(x)
'next
MyScreen.SendKeys ("<Home><down><down>")
MyScreen.SendKeys ("H382C0<Enter>")
WaitClock
Pause (3)
MyScreen.SendKeys ("<Clear>")
WaitClock
MyScreen.SendKeys ("cesn<Enter>")
WaitClock
MyScreen.SendKeys (Username)
MyScreen.SendKeys ("<tab><tab>")
MyScreen.SendKeys (Password)
MyScreen.SendKeys ("<enter>")
WaitClock
MyScreen.SendKeys ("ps30<Enter>")
WaitClock
MyScreen.SendKeys (District)
MyScreen.SendKeys ("<tab>")
MyScreen.SendKeys (UserIDNuM)
MyScreen.SendKeys ("<enter>")
WaitClock
End Sub
Function FileDlgFunction(identifier$, action, suppvalue)
Select Case action
Case 1 'dialog box initialized
Case 2 'button or control value changed
Case 3 'text or combo box changed
UserInput(1) = DlgText$(0)
UserInput(2) = DlgText$(1)
UserInput(3) = DlgText$(2)
UserInput(4) = DlgText$(3)
Case 4 'control focus changed
Case 5 'idle
DoEvents
End Select
End Function
Sub WaitClock()
Do While MyScreen.OIA.XStatus <> 0
Loop
End Sub
Thank you very much.