1. Problem Overview
PCS7 v8.1 deployments frequently use a single WinCC Runtime project to host multiple operator groups: shift supervisors, process engineers, read-only auditors, and external vendors. A common requirement is to make the active operator role visually obvious so that a glance at the monitor is enough to confirm which user is currently driving the process. The cleanest way to do this is to switch the background color of the process picture according to the logged-in WinCC user.
This article covers three implementation paths in Siemens WinCC V7.x (the runtime that ships with PCS7 V8.1):
- Per-picture VBScript bound to the picture's
BackColorproperty, fired by a user-change trigger. - A WinCC Global Action that runs on a user-change event and updates the active picture plus the picture cache.
- A VBScript applied to the WinCC Login dialog box so that the login window itself reflects the access level (for example, gray for ReadOnly).
All three approaches use the WinCC VBScript object model (HMIRuntime, ScreenItems, HMIUser) and are forward-compatible with PCS7 V8.2 and V9.0 SPx. The principles also apply to TIA Portal WinCC Comfort/Advanced, but the object names differ; see the Siemens WinCC V7.5 SP2 Scripting Reference for the canonical list.
2. Prerequisites
Confirm the following before you start editing the project.
- SIMATIC PCS7 V8.1 with SIMATIC WinCC V7.3 installed on the OS / Engineering Station. Patch level 8.1.1 or later is recommended so that the
OnUserChangetrigger is fully available in the Graphics Designer. - WinCC Explorer with the Graphics Designer, Global Script, and User Administrator editors enabled (ES Options → "Graphics, Global Script and User Administrator").
- Local or domain Windows users defined in WinCC User Administrator (Start → SIMATIC → WinCC → Tools → User Administrator) with at least the 1000 - Process controlling and No. 1 - Read only authorizations.
- Runtime license key on the OS server (WinCC RT 64K or larger). Background-color switching is purely client-side VBScript, so it does not consume any additional power tags.
- Project is in Runtime-Ready state (compiled, no cross-references flagged red) so that a live picture window can be used for verification.
3. Architecture: How WinCC Routes User Changes
When an operator logs in, logs out, or is auto-logged-off by a timer, WinCC raises an internal event that the Graphics Designer exposes as the OnUserChange trigger on every screen object. Any C or VBScript action configured to fire on that trigger executes in the runtime context of the picture that owns the object.
Two event sources are available in PCS7 V8.1:
- Picture-local trigger: bound to the picture window. It fires only when the runtime is showing that picture. Cheap, but must be duplicated to every picture that needs the color change.
-
Global Action: configured in the WinCC Explorer under Global Script → Actions. It runs once on the server process, can iterate over all open picture windows through
HMIRuntime.Screens, and updates each one. Recommended when the same color rule must apply across all process pictures and the Login dialog.
For a one-off single-screen deployment, the picture-local method is faster to implement. For a plant-wide roll-out, the global action scales better because adding a new user only requires editing one script.
4. Method 1 - Per-Picture VBScript on the Background Property
This method attaches a VBScript directly to the BackColor property of the picture. Open the picture in Graphics Designer, click an empty area to select the picture (not a single object), then in the Properties pane scroll to Colors → BackColor.
- Right-click BackColor and choose Properties → Dynamic → Dynamic Dialog or VBS Action. Use the VBS Action option so that the script can branch on the user name.
- Set the trigger to User change (this is the
OnUserChangeevent in the trigger list). You can add a second trigger of type Tag: e.g. @CurrentUser if you maintain an internal tag that mirrors the current user name. - Enter the following VBScript:
Function BackColor_Trigger(ByVal Item)
Dim sUser
Dim lColor
sUser = HMIRuntime.Tags("@CurrentUser").Read
Select Case UCase(sUser)
Case "PLANT_OPERATOR" : lColor = RGB( 0, 90, 170) ' Siemens petrol blue
Case "SHIFT_SUPER" : lColor = RGB(200, 20, 20) ' supervisor red
Case "PROCESS_ENG" : lColor = RGB( 30, 130, 30) ' engineer green
Case "AUDITOR" : lColor = RGB(220, 220, 220) ' neutral light gray
Case Else : lColor = RGB(240, 240, 240) ' default WinCC gray
End Select
BackColor_Trigger = lColor
End Function
- Compile with Ctrl+F7, close the dialog, and save the picture (Ctrl+S).
- Repeat for every process picture where the colored background is required. Pictures without the script keep the default background color.
The BackColor_Trigger convention is mandatory: Graphics Designer binds the return value of a function whose name is <PropertyName>_Trigger to the corresponding property. Renaming the function silently disables the dynamic.
5. Method 2 - Global Action for All Open Pictures
A Global Action runs in the WinCC server process and can update every currently loaded picture in a single pass. This avoids duplicating the script on dozens of pictures and also makes the rule visible in one place for code review.
- In WinCC Explorer, right-click Global Script → Actions and choose New → VBS Action. Name it
act_BackgroundByUser. - Open the action and set the trigger list to User change. Optionally add a 60-second timer so the color is re-evaluated if a user session times out.
- Paste the code below:
' --- Global Action: act_BackgroundByUser ---
Option Explicit
Function action_Trigger(ByVal Item)
Dim oScreen, oPicture
Dim sUser, lColor
Dim i
sUser = HMIRuntime.Tags("@CurrentUser").Read
Select Case UCase(sUser)
Case "PLANT_OPERATOR" : lColor = RGB( 0, 90, 170)
Case "SHIFT_SUPER" : lColor = RGB(200, 20, 20)
Case "PROCESS_ENG" : lColor = RGB( 30, 130, 30)
Case "AUDITOR" : lColor = RGB(220, 220, 220)
Case Else : lColor = RGB(240, 240, 240)
End Select
' Update the active picture
Set oPicture = HMIRuntime.ActiveScreen.ScreenItems("Background")
If IsObject(oPicture) Then oPicture.BackColor = lColor
' Update all picture windows that are currently open in the runtime
For i = 0 To HMIRuntime.Screens.Count - 1
Set oScreen = HMIRuntime.Screens(i)
On Error Resume Next
oScreen.BackColor = lColor
On Error Goto 0
Next
End Function
- Save and compile (Ctrl+F7). The script becomes effective the next time Runtime is started or the action list is reloaded via Global Script → Reset.
HMIRuntime.Screens lists only the picture windows currently opened in the runtime. Pictures that are loaded later (for example, by a button that calls OpenScreen) will be re-colored when their own OnUserChange dynamic fires, but only if the picture has a dynamic on BackColor. Combine Method 1 and Method 2 if the user role should also be visible on first opening of any picture without a script on it.6. Method 3 - Color the Login Dialog for Read-Only Users
Many PCS7 V8.1 installations want the login window itself to be a different color when the only available user is a ReadOnly auditor. WinCC exposes the Login dialog as a system picture that can be edited in Graphics Designer. The same VBScript pattern applies.
- In Graphics Designer, open the system picture @LoginBox.pdl (WinCC installation path:
..\WinCC\Pictures\@LoginBox.pdl). Save a project-local copy under GraCS\@LoginBox_local.pdl and configure WinCC to use that one in Computer Properties → Graphics Runtime → Login dialog. - Add a VBScript dynamic on the picture's
BackColorproperty with the User change trigger:
Function BackColor_Trigger(ByVal Item)
If HMIRuntime.Tags("@CurrentUserAuthorization").Read = 1 Then
' Authorization level 1 = Read Only (defined in User Administrator)
BackColor_Trigger = RGB(200, 200, 200)
Else
BackColor_Trigger = RGB(255, 255, 255)
End If
End Function
- Optionally add a static text on the login picture that says "Read-only access" and bind its Visible property to the same authorization tag.
7. Internal Tag Reference
WinCC exposes a number of system tags that simplify user-aware scripts. The following table summarizes the most useful ones for PCS7 V8.1.
| Tag name | Type | Contents | Typical use |
|---|---|---|---|
@CurrentUser |
Text 8/16 | Logged-in user name or empty string | Switch BackColor, show user label |
@CurrentUserAuthorization |
DWORD | Bitmask of current user's authorization levels | Read-only check, role gating |
@CurrentUserGroup |
Text 8/16 | Active user group | Group-level color rules |
@RedundantUserState |
Byte | 0/1 redundancy state for partner server user | Diagnostics in redundant PCS7 |
@UserLoggedIn |
Bool | TRUE while a user is logged in | Show "Please log in" message |
Read these tags from VBScript with HMIRuntime.Tags("@CurrentUser").Read. Do not write to them - they are managed by the WinCC User Administrator.
8. Color Palette Recommendations
Plant-floor displays are read under fluorescent lighting at distances of 1-3 m. Use saturated but not glaring colors and reserve a high-contrast frame for the color band so that color-blind operators can still see the role boundary.
| Role | RGB | Hex | Notes |
|---|---|---|---|
| Plant Operator | RGB(0, 90, 170) | #005AAA | Siemens brand petrol blue, high contrast on white |
| Shift Supervisor | RGB(200, 20, 20) | #C81414 | Warning red - matches alarm bar palette |
| Process Engineer | RGB(30, 130, 30) | #1E821E | Service green - matches WinCC "released" status |
| Auditor / ReadOnly | RGB(220, 220, 220) | #DCDCDC | Neutral light gray, low fatigue |
| Logged out | RGB(240, 240, 240) | #F0F0F0 | Default WinCC background |
9. Verification
Test the implementation in the order below before handing the project back to operations.
- Activate Runtime and open a picture that contains the dynamic background. The picture should paint in the default Logged out color.
- Log in as
PLANT_OPERATOR. The background should change within one second to petrol blue. The status bar should show the same user name as@CurrentUser. - Log out, then log in as
SHIFT_SUPER. The background should switch to red. If it does not, open Global Script → Diagnostics and look for compile errors inact_BackgroundByUser. - Open a second picture window with View → New Window or by clicking a process tag that triggers a
OpenScreenaction. Verify that the new picture also receives the role color (only when using Method 2). - Force a session timeout: User Administrator → Options → Auto-logout after 2 min. Wait, confirm that the background resets to the default Logged out color.
- Stop Runtime. Re-activate and confirm the first painted frame already shows the role color (this confirms the picture-local Method 1 works without an explicit
OnUserChangefire).
10. Troubleshooting Matrix
| Symptom | Likely root cause | Fix |
|---|---|---|
| Background never changes | VBScript function not named BackColor_Trigger
|
Rename the function to match the property, recompile |
| Background flashes to default briefly on every screen open | Trigger set to "On Open" instead of "User change" | Edit the dynamic, replace the trigger with User change |
| Compile error "Object does not support this property or method: HMIRuntime.ActiveScreen" | Picture is being initialized; ActiveScreen not yet valid |
Wrap call in If IsObject(HMIRuntime.ActiveScreen) Then
|
| Global Action does not run | Action not registered with the runtime; "Run actions on server" flag off | Right-click action in WinCC Explorer → Properties → Run on Server = ON |
| Wrong color for some users | User name has trailing whitespace from Active Directory import | Use Trim(UCase(sUser)) in the Select Case |
| Color flickers when alarms come in | Another dynamic (alarm line) also writes to BackColor of the parent |
Move the dynamic to a child rectangle that sits below all other objects |
| Client does not get the color | Project is opened on a WinCC Client without the Graphics Designer installed | Install the optional "Graphics Designer" package on the client, or replicate the dynamic via the server project |
| Login box dialog stays white for ReadOnly user | @LoginBox_local.pdl not selected in Computer Properties | Computer → Properties → Graphics Runtime → set "Login dialog" to @LoginBox_local.pdl
|
11. Performance and Sizing
The VBScript overhead of one HMIRuntime.Tags("@CurrentUser").Read call and one RGB comparison is negligible: WinCC's VBScript engine processes roughly 50,000 such actions per second on a typical OS server. The cost of Method 2 is O(n) in the number of open picture windows, so a 5-window faceplate-heavy overview picture costs under one millisecond per user-change event.
There is no measurable impact on the WinCC tag licensing because @CurrentUser and friends are internal tags that do not require power tags. Each project copy of the script is a few hundred bytes; thousands of pictures are therefore not a concern.
12. Field-Commissioning Notes
- Deploy the modified pictures via Server-Data → Project Duplicator or a controlled
osserver.exefile transfer; avoid editing the live runtime project on a customer OS server. - Document the chosen color mapping in the project's HMI Style Guide so that future picture authors do not invent their own palette.
- In redundant PCS7 V8.1, replicate the Global Action to the standby server. The action is part of the project database, so a normal redundancy failover restores it automatically; no manual step is required.
- When upgrading to PCS7 V9.0 or TIA Portal V18, the same VBScript logic is valid, but the screen object model changes from
ScreenItemstoHmiRuntime.Screens. Plan a short script-rework window at the upgrade.
13. Reference: HMI Background Color on Other Platforms
The same user-role requirement is common on non-Siemens HMIs. The scripting APIs differ but the trigger model is identical.
- Pro-face GP-Pro EX: change the Screen Color attribute from the Screen Properties dialog, or drive the color from a script bound to the User change event of a global function.
- AVEVA PI Vision: right-click the empty area of a display, choose Format Display → Background, and pick a color from the palette as described in the AVEVA PI Vision documentation.
What trigger should I use so the background color changes immediately on user switch?
Use the User change trigger in the dynamic dialog of the picture's BackColor property, or in the trigger list of the Global Action. This event fires on every successful login, logout, and forced timeout in PCS7 V8.1, so the color is updated within one runtime cycle (typically < 250 ms).
My function is named BackColor_Trigger but the color still does not change. Why?
Confirm that the function is declared with the exact signature Function BackColor_Trigger(ByVal Item) and that the Trigger tab of the dynamic lists at least User change. A typo in the function name silently disables the binding, and the VBScript editor does not warn about unused functions.
Do I need a power tag to read @CurrentUser?
No. @CurrentUser, @CurrentUserAuthorization, and the other @-prefixed names are WinCC internal tags. They are available on every OS server without a power-tag license and can be read with HMIRuntime.Tags("@CurrentUser").Read.
How do I color the WinCC Login dialog itself for ReadOnly users?
Copy the system picture @LoginBox.pdl to a project-local @LoginBox_local.pdl, add a VBScript dynamic on its BackColor property that checks @CurrentUserAuthorization = 1, and set the path in Computer Properties → Graphics Runtime → Login dialog. The dialog will then paint light gray for any user with read-only authorization level.
Will this approach still work if I migrate from PCS7 V8.1 to TIA Portal V18?
Yes, with one renaming step. The VBScript object model in TIA Portal WinCC uses HmiRuntime.Screens instead of HMIRuntime.Screens, and the user tag is exposed as HmiRuntime.Tags("@CurrentUser"). The trigger name User change and the RGB logic remain identical.