Differentiating Object Properties in WinCC WebUX vs Client Runtime
WinCC V7/V8 and WinCC Runtime Professional share one picture database between the native WinCC Client, WinCC WebNavigator, and WinCC WebUX. Because the picture and its object properties live in the server project, the same color, visible, or position value reaches every viewer. This article consolidates field-proven methods to detect whether a screen is being rendered by a native WinCC Client or by a WebUX browser session, and to drive object properties accordingly.
1. Problem Statement and Scope
A typical requirement is "the same page, different appearance":
- A button is larger, with full text, on a WinCC Client (touch or 24" operator station).
- The same button is smaller, with abbreviated tooltip, on a WebUX browser session running on a tablet.
- Color palette shifts because the WebUX client does not support a custom ActiveX control, but the native Client does.
WinCC WebUX is the HTML5-based successor to WebNavigator. WebUX uses an in-house browser-independent rendering engine (Siemens' "Plant WebUX" client) that streams VSTA-compiled screen objects through HTTPS, while WebNavigator is an ActiveX-based plug-in for Internet Explorer. The two have very different scripting and object support surfaces, which is why property differentiation is needed in the first place.
2. Why ifdef RUN_ON_WEBNAVIGATOR Does Not Work in WebUX
The classic WinCC preprocessor directive is:
// C-Script in Graphics Designer
#ifdef RUN_ON_WEBNAVIGATOR
SetPropChar(lpszPictureName, "Button1", "Caption", "WebNav");
#else
SetPropChar(lpszPictureName, "Button1", "Caption", "Client");
#endif
This directive is resolved at compile time of the C-script project. It evaluates to True when the project is compiled for a WebNavigator client target, and False for a native WinCC Client. There is no RUN_ON_WEBUX macro in WinCC V7.x/V8.x as of the TIA Portal V20 / WinCC V8.1 documentation set. Therefore, conditional compilation is not a viable method when WebUX is the target.
| Macro | Evaluates True when | WebUX usable? |
|---|---|---|
RUN_ON_WEBNAVIGATOR |
Script compiled for WebNavigator target | No - false on WebUX |
RUN_ON_WEBUX |
Not defined in any released version | No |
RUN_ON_CLIENT |
Script compiled for native client | No |
3. Runtime Context Detection Methods
Because compile-time selection is unavailable, three runtime mechanisms are used in practice:
-
Internal tag
@LocalMachineName- returns the local machine identifier, which differs in format between a native Client and a WebUX client. -
User-based differentiation - assign separate WinCC users to native Client operators and to WebUX users; use the
GetUserNameAPI or the configured operator station rights to switch properties. - Separate screen objects / separate pictures - the most reliable method when the visual change is large (e.g., an HTML5-friendly control vs. a WinCC native control).
4. The @LocalMachineName Approach
The internal tag @LocalMachineName is a string that WinCC populates per client session. Its value depends on the runtime context:
| Context | Value of @LocalMachineName
|
Reliable? |
|---|---|---|
| Native WinCC Client (own process) | Computername of the client PC | Yes |
| WinCC Client running WebUX browser locally | Computername of that client (same as above) | Yes but indistinguishable from native client |
| External WebUX client (browser on a different PC) | IP address of the WebUX browser host | Yes, distinguishable from native |
| WinCC Server's own runtime | Computername of the server | Yes |
Field-proven behavior: in WinCC V8 with the WebUX server role enabled, the @LocalMachineName tag observed in a WebUX browser session returns the IP address of the machine hosting the browser when the browser is external. When the same browser runs on a real WinCC Client PC, the tag returns the client's computer name - making differentiation between "native client" and "WebUX on native client" impossible using this tag alone.
4.1 Practical C-Script Example
// Triggered on picture open
#include "apdefap.h"
void OnOpen(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName)
{
char* szLocal = GetTagChar("@LocalMachineName");
// IP-like content: contains digits separated by dots
int bIsWebUX = 0;
if (strlen(szLocal) > 0) {
int dots = 0, digits = 0;
for (int i = 0; szLocal[i] != '\0'; i++) {
if (szLocal[i] == '.') dots++;
if (szLocal[i] >= '0' && szLocal[i] <= '9') digits++;
}
if (dots >= 3 && digits >= 4) bIsWebUX = 1;
}
if (bIsWebUX) {
// WebUX: small button, short caption, dim color
SetPropChar(lpszPictureName, "Button_Ack", "Caption", "OK");
SetPropWord(lpszPictureName, "Button_Ack", "BackColor", 0xC0C0C0);
} else {
// Native client
SetPropChar(lpszPictureName, "Button_Ack", "Caption", "Acknowledge Alarm");
SetPropWord(lpszPictureName, "Button_Ack", "BackColor", 0x00FF00);
}
}
ComputerName happens to be set to a dotted-IPv4-style name (unusual but legal in some legacy environments) will be misclassified. Always combine with a user check for safety-critical displays.5. User-Based Differentiation
The most robust method, used by integrators when context cannot be inferred reliably, is to create two distinct WinCC users:
-
OP_WebUX- assigned only to operators who log in via the WebUX portal. -
OP_Client- assigned only to native client operators.
Both users can be linked to the same authorization level (e.g., level 4 "Process control"), so functional rights are identical. Differentiation is purely cosmetic.
5.1 Detecting the Logged-in User from a Script
// Returns the currently logged-in WinCC user (or "" if not logged in)
char* szUser = GetUserName(lpszPictureName);
if (strcmp(szUser, "OP_WebUX") == 0) {
// WebUX look-and-feel
SetPropBOOL(lpszPictureName, "ctrlHTML5Chart", "Visible", 1);
SetPropBOOL(lpszPictureName, "ctrlWinCCChart", "Visible", 0);
} else if (strcmp(szUser, "OP_Client") == 0) {
SetPropBOOL(lpszPictureName, "ctrlHTML5Chart", "Visible", 0);
SetPropBOOL(lpszPictureName, "ctrlWinCCChart", "Visible", 1);
}
5.2 Detecting the User via Tag
The internal tag @CurrentUser always returns the user name string for the active session. Linking a tag connection to a project-wide dynamization is generally simpler than scripting per object:
// Dyn configuration of a property, type "Tag/Value"
Tag: @CurrentUser
Comparison type: string
Value: OP_WebUX
On TRUE: set object property to "WebUX variant"
On FALSE: set object property to "Client variant"
| Criterion | @LocalMachineName |
User-based | Separate pictures |
|---|---|---|---|
| Maintenance effort | Low | Low | High (duplication) |
| Robustness against renaming | Medium | High | Highest |
| Differentiates WebUX-on-native-client | No | Yes | Yes |
| Works without script | Yes (string dynamization) | Yes | Yes |
| Recommended for safety displays | No | Yes | Yes |
6. WebNavigator vs WebUX - Object Property Surface Differences
When property differentiation is required, it is usually because the two clients support different object sets. The following table summarizes the most common gaps encountered in field projects.
| Object / Property | WebNavigator | WebUX (RT Professional) | Notes |
|---|---|---|---|
| Custom ActiveX controls | Yes (IE-only ActiveX) | No | WebUX supports a defined set of WinCC Controls only |
SetPropChar / SetPropWord in C scripts |
Yes | Limited - not all object properties are runtime-writable in WebUX | Refer to WebUX Controls and Scripting |
VBS HMIRuntime.Screens(...).Items(...).Properties(...)
|
Yes | Yes (subset) | WebUX blocks methods that require direct COM access |
| Direct object "BackColor" dynamization | Yes | Yes | Use property "Miscellaneous > Web-enabled = Yes" |
| Object name change at runtime | Yes | No | Object name is part of the picture tree in WebUX |
| Geometric rotation / 3D | Yes | No | HTML5 renderer limitation |
7. Enabling WebUX on a Screen Object
By default, picture objects are not published to the WebUX client. To make an object available:
- Open the screen in the Graphics Designer (WinCC V7/V8) or in the TIA Portal editor (RT Professional).
- Select the object and open Object properties > Miscellaneous.
- Set the property Web-enabled to Yes.
- Recompile / republish the WebUX project (button "WebUX Publisher" or via the WebUX configurator).
For TIA Portal V20 / WinCC Runtime Professional, the same property is set in the Inspector window of the screen editor: Configuring WinCC screens for WebUX (RT Professional).
WebUX runtime cache. Changes to property defaults are only visible after republishing. Re-publishing on the server is required even if the client is remote.8. Supported Screen Objects in WebUX
WebUX supports most static and dynamic screen objects, but not all. The official list is published in the TIA Portal help:
- Static objects: line, polygon, ellipse, rectangle, static text, graphic view.
- Smart objects: I/O field, button, option group, bar, slider, date/time field, text list, combo box, list box.
- Windows: picture window, screen window.
- WinCC Controls (selected): Alarm Control, Online Trend Control, Online Table Control, Function Trend Control, User Archive Control, RulerControl, Browser View (HTML), Process Control.
Not supported in WebUX: custom ActiveX, OCX, faceplate instances that internally use unsupported objects, and several Smart objects depending on WinCC version. Always verify against the current TIA Portal help page Supported functions: Screen objects (RT Professional) before designing dual-target screens.
8.1 Property Restrictions That Apply to All Objects in WebUX
- Geometric rotation (property "Rotation") is not supported.
- Property "Layer" is read-only at runtime.
- Property "Operability in the monitoring" cannot be toggled dynamically when the object uses HTML5 rendering.
- Custom-defined properties on faceplates may be missing in WebUX if they target a non-supported type.
9. Scripting Pattern: Property Switching via VBS on Picture Open
For RT Professional (TIA Portal), VBS is the recommended scripting language. The pattern below detects the user and applies a property set per session.
' Trigger: Picture > Event > Opened
Dim sUser, bWeb
sUser = HMIRuntime.Screens("Main").Tags("@CurrentUser").Read
bWeb = (sUser = "OP_WebUX")
If bWeb Then
HMIRuntime.Screens("Main").Items("Button_Ack").Properties("Caption") = "OK"
HMIRuntime.Screens("Main").Items("Button_Ack").Properties("BackColor") = RGB(192,192,192)
HMIRuntime.Screens("Main").Items("ctrlTrendWin").Properties("Visible") = False
HMIRuntime.Screens("Main").Items("ctrlTrendHTML").Properties("Visible") = True
Else
HMIRuntime.Screens("Main").Items("Button_Ack").Properties("Caption") = "Acknowledge"
HMIRuntime.Screens("Main").Items("Button_Ack").Properties("BackColor") = RGB(0,255,0)
HMIRuntime.Screens("Main").Items("ctrlTrendWin").Properties("Visible") = True
HMIRuntime.Screens("Main").Items("ctrlTrendHTML").Properties("Visible") = False
End If
If HMIType <> 0 Then tests sparingly - the runtime type is exposed in the WebNavigator client only. For WebUX-only logic, prefer the user-based pattern shown above.10. Topology: Where Property Switches Happen
The diagram below summarizes where the differentiation logic lives in a typical WinCC V8 architecture with WebUX enabled.
11. State Machine: Picture Open Behavior
12. Verification Checklist After Configuration
- Republish the WebUX project on the server. WebUX clients cache the published result - they do not pick up "live" changes to the server project.
-
Log in as
OP_WebUXfrom an external browser; confirm@CurrentUser=OP_WebUXvia the WinCC tag browser (HMI control "Diagnostics"). -
Log in as
OP_Clienton a native WinCC Client; confirm the script took the "else" branch and the original caption is shown. - Open a picture window that uses a faceplate with user-dependent properties. Verify that faceplate instances do not retain the previous user's settings after a user change.
-
Test on the WebUX host machine itself (browser opened on the WinCC Server or a WinCC Client). Confirm whether the same browser is recognized as "external" or "local" - this depends on the URL used (
localhostvs. FQDN). -
Verify back color and caption changes in the runtime diagnostics window. Use the "Watch" pane to inspect
HMIRuntime.Screens("Pic1").Items("Button_Ack").Properties("BackColor")on both clients.
13. Field-Proven Best Practices
- Always combine
@LocalMachineNamedetection with a user check. The two together eliminate false positives and make renaming of clients non-fatal. - Use the WebUX Publisher cache as the source of truth in change-management processes. Old pictures will otherwise keep showing in cached browser sessions until republish.
- When the appearance difference is large, prefer two parallel pictures with a user-dependent picture-window redirection - it is more reliable than dynamizing 30 properties in a single picture.
- For C-scripts that call
SetPropChar,SetPropWord, orSetPropBOOL, only call them on properties that are listed as runtime-writable in the WebUX object reference. Calling a non-writable property logs a runtime warning and is silently ignored on some firmware levels. - Reserve ActiveX-specific logic for native clients and HTML5-friendly controls for WebUX - do not try to hide the unsupported control through
Visible = 0if the object itself is not Web-enabled (the picture will fail to load entirely). - Document the user-naming convention (
OP_WebUX,OP_Client,OP_Nav) in the project configuration document. The same convention is also used in Siemens' WebUX documentation examples.
14. Limitations and Constraints
- Conditional compilation is not available for WebUX in WinCC V7/V8. Plan for runtime dynamization only.
- Object name and layer cannot be changed in WebUX at runtime. If your differentiation requires moving objects between layers, use separate pictures.
- Picture window contents are not user-dependent by default; you must implement the picture selection yourself in the OnOpen event of the parent picture.
- WinCC faceplate instance properties are partly read-only in WebUX. Refer to the TIA Portal V20 supported functions page for the current matrix.
- Scripting in WebUX follows the WebUX Controls and Scripting restrictions: not all methods available in WebNavigator work in WebUX, and Siemens explicitly recommends setting properties directly on the control instead of using indirect methods.
15. Quick Reference: Object Property Methods
| Target | C-script | VBS (RT Professional) |
|---|---|---|
| Static text caption | SetPropChar(...,"Caption","...") |
.Properties("Text") = "..." |
| Background color | SetPropWord(...,"BackColor",0xRRGGBB) |
.Properties("BackColor") = RGB(r,g,b) |
| Visibility | SetPropBOOL(...,"Visible",1) |
.Properties("Visible") = True |
| Geometry (X, Y, W, H) | SetPropWord(...,"Position.X",...) |
.Properties("Left") = ... |
| Layer | Not runtime-writable in WebUX | Not runtime-writable in WebUX |
16. Frequently Asked Questions
Is there an ifdef RUN_ON_WEBUX macro in WinCC?
No. Siemens only ships RUN_ON_WEBNAVIGATOR and RUN_ON_CLIENT preprocessor directives. WebUX requires runtime context detection using @CurrentUser, @LocalMachineName, or separate pictures.
Can object properties on the server project change depending on the viewer?
No. Object properties are stored in the server project. Adaptation happens at runtime on the client through dynamization, VBS scripts, or C-scripts, or at design time by publishing two parallel pictures.
What value does @LocalMachineName return in a WebUX browser session?
For an external WebUX client (browser on a different PC), the tag returns the IP address of the browser host. For a browser running on a real WinCC Client or on the server itself, the tag returns that computer's hostname, which is the same value seen in a native client session - this makes the two cases indistinguishable using the tag alone.
How do I make a screen object available in WebUX?
Set Object properties > Miscellaneous > Web-enabled = Yes in the Graphics Designer (WinCC V7/V8) or use the Inspector window in TIA Portal (RT Professional). Then republish the WebUX project so the enabled objects are pushed into the WebUX cache.
Which method is most reliable for differentiating a WebUX client from a native WinCC Client?
User-based differentiation. Create dedicated users (OP_WebUX and OP_Client) with identical rights, then read @CurrentUser in the picture open event. This survives client renames, mixed local/remote browsers, and is independent of the IP-vs-host ambiguity of @LocalMachineName.