macro_command main()
short currentclass = 0 // current class - anything other than 0 means a user is logged in
short newwindownumber = 11 // this is the new window we want to direct the user to if they logout or are autologged out
short currentwindownumber = 0 // The current window #
GetData(currentclass, "Local HMI", LW, 9222, 1) // get the current user class value
GetData(currentwindownumber, "Local HMI", LW, 9050,1) // get current window number
if currentclass == 0 then
select case currentwindownumber // = 80 or currentwindownumber = 11) then // if the user is logged out and the currentwindow the screen saver...
case 11 // The user is logged out but on the main window
// Do nothing
break
case 80 // The user is logged out but on the screen saver window
// Do nothing
break
case 10 // The user is on page 10
SetData(newwindownumber, "Local HMI", LW, 100, 1) // set LW 100, the word defined in PLC Control Window change to 11
Beep()
DELAY(250)
Beep()
DELAY(250)
Beep()
break
case 12 // The user is on page 12
SetData(newwindownumber, "Local HMI", LW, 100, 1) // set LW 100, the word defined in PLC Control Window change to 11
Beep()
DELAY(250)
Beep()
DELAY(250)
Beep()
break
case 13 // The user is on page 13
SetData(newwindownumber, "Local HMI", LW, 100, 1) // set LW 100, the word defined in PLC Control Window change to 11
Beep()
DELAY(250)
Beep()
DELAY(250)
Beep()
break
end select
else
if currentclass > 0 and currentwindownumber == 70 then
// The user is logged in and the Login & Logout window is the current window
SetData(newwindownumber, "Local HMI", LW, 100, 1) // set LW 100, the word defined in PLC Control Window change to 11
end if
end if
//
end macro_command
Here is my Macro that was created to auto change the window if the auto logout occurs. If the Auto logout occurs and the user is on certain windows, they will be returned to window 11 (the main starting window within this app).
This macro was altered to try and get the window 70 Login & Logout to close and switch the user back to window 11 if the login was a success. But its not working. Window 70 is a pop-up window and I don't think the proper window # is getting read back from LW-9050.
Thoughts?
Code:macro_command main() short currentclass = 0 // current class - anything other than 0 means a user is logged in short newwindownumber = 11 // this is the new window we want to direct the user to if they logout or are autologged out short currentwindownumber = 0 // The current window # GetData(currentclass, "Local HMI", LW, 9222, 1) // get the current user class value GetData(currentwindownumber, "Local HMI", LW, 9050,1) // get current window number if currentclass == 0 then select case currentwindownumber // = 80 or currentwindownumber = 11) then // if the user is logged out and the currentwindow the screen saver... case 11 // The user is logged out but on the main window // Do nothing break case 80 // The user is logged out but on the screen saver window // Do nothing break case 10 // The user is on page 10 SetData(newwindownumber, "Local HMI", LW, 100, 1) // set LW 100, the word defined in PLC Control Window change to 11 Beep() DELAY(250) Beep() DELAY(250) Beep() break case 12 // The user is on page 12 SetData(newwindownumber, "Local HMI", LW, 100, 1) // set LW 100, the word defined in PLC Control Window change to 11 Beep() DELAY(250) Beep() DELAY(250) Beep() break case 13 // The user is on page 13 SetData(newwindownumber, "Local HMI", LW, 100, 1) // set LW 100, the word defined in PLC Control Window change to 11 Beep() DELAY(250) Beep() DELAY(250) Beep() break end select else if currentclass > 0 and currentwindownumber == 70 then // The user is logged in and the Login & Logout window is the current window SetData(newwindownumber, "Local HMI", LW, 100, 1) // set LW 100, the word defined in PLC Control Window change to 11 end if end if // end macro_command
My bad, LW-8950 is not an internal register but the PLC Control register I'm using.macro_command main()
short login
short currentwindownumber
short newwindownumber = 13
GetData(login, "Local HMI", LW, 8950, 1)
GetData(currentwindownumber, "Local HMI", LW, 9050, 1)
if login == 2 then
SetData(newwindownumber, "Local HMI", LW, 9050, 1)
end if
end macro_command
Try this, it works. The internal register for login is LW-8950. If this register is 2 then the login is successful, if not the register is 3. The periodical execution I've set is 100ms. This code is only to change the window if login is successful tho, just write the rest of your logic.
Nah don't listen to me, I'm tripping right now. This code just changes window when you press "Login" button, this button itself writes '2' in LW-8950 and "Logout" writes '3'. It doesn't matter if the username and password are correct, the window is going to change. I will test out these things later this week.macro_command main()
short login
short currentwindownumber
short newwindownumber = 13
GetData(login, "Local HMI", LW, 8950, 1)
GetData(currentwindownumber, "Local HMI", LW, 9050, 1)
if login == 2 then
SetData(newwindownumber, "Local HMI", LW, 9050, 1)
end if
end macro_command
Try this, it works. The internal register for login is LW-8950. If this register is 2 then the login is successful, if not the register is 3. The periodical execution I've set is 100ms. This code is only to change the window if login is successful tho, just write the rest of your logic.
create a Function Key with the “Close window” property. Then, you can place the Function Key and Set Word object for your sign-in button on top of one another in EBPro. This will allow a single button press to both sign the user in and trigger the “Close Window” function.
You’re able to make the Function Key invisible by de-selecting “Use picture”, “Use shape”, and “Use label” in the Function Key’s properties:
That's not a good idea since you don't have to enter the right credentials, you are always going to close the login window + that you won't be able to tell if the login is successful or not. Gaj, I can send you my program so you can test it out yourself, just give me your email. There is a macro too, long story short I check if the login is successful and change windows if it is. I change windows on logout too. So far It's working good, I can explain you the details in private.Just wanted post an answer that I got from tech support. It's good enough for me:
Unfortunately I can't send you the program via Direct Message so I'm just going to post screenshots here.Thanks for the concern. I'd like to see the method you used. Can you send it via Direct Message on this forum?
The reason I'm not concerned is because the main user window has most of the controls hidden and secured. Plus there is a 'logged out' message at the bottom when that is appropriate. So if they get the wrong password, they will be right back where they started. But I would like to see a more polished method.