Minimize window button

Hello Everyone

My client wants a button to minimize the window in Perspective, they access Perspective workstation through a RDP with the connection bar of the RDP disabled. Perspective workstation is running in Fullscreen / kiosk mode.

We would like to create a button that minimizes the Perspective window.

We imagine this can be done with a script on a button? or is there a build in command for this?

Hello, you may try add an event onActionPerformed to your button with:

Example Using Jython (subprocess):

import subprocess

try:
    # PowerShell command to minimize all windows (you can target Perspective specifically if needed)
    command = [
        "powershell",
        "-Command",
        "(New-Object -ComObject Shell.Application).MinimizeAll()"
    ]
    
    # Execute the PowerShell script
    subprocess.Popen(command)
except Exception as e:
    system.perspective.print("Error minimizing window: " + str(e))

Since Perspective Workstation is a standalone application (not browser-based), you can call an external script to interact with the operating system and minimize the application window.

Another way would be:

1st: PowerShell Script for Minimizing a Specific WindowÇ

# PowerShell script to minimize a window by title
Add-Type @"
    using System;
    using System.Runtime.InteropServices;
    public class User32 {
        [DllImport("user32.dll")]
        [return: MarshalAs(UnmanagedType.Bool)]
        public static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
        [DllImport("user32.dll", SetLastError = true)]
        public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
    }
"@

$windowTitle = "Perspective Workstation"  # Adjust to the title of your Perspective window
$hwnd = [User32]::FindWindow($null, $windowTitle)
if ($hwnd -ne [IntPtr]::Zero) {
    [User32]::ShowWindow($hwnd, 6)  # Minimize the window (6 = SW_MINIMIZE)
} else {
    Write-Output "Window not found"
}

2nd: Jython Script to Call PowerShell:

import subprocess

try:
    # Path to the PowerShell script
    script_path = "C:\\path\\to\\MinimizePerspective.ps1"

    # Execute PowerShell
    command = ["powershell", "-ExecutionPolicy", "Bypass", "-File", script_path]
    subprocess.Popen(command)
except Exception as e:
    system.perspective.print("Error minimizing Perspective Workstation: " + str(e))

I haven´t try any of this methods. You may check if they work.

You cannot. That is a Vision capability.

The whole point of kiosk mode is to forbid access to the desktop.

Don't run in kiosk mode.

2 Likes

We are trying to preserve space by running in kiosk / Fullscreen mode to avoid scaling our views.

If the client wants to minimize and we would prefer not to run in window mode is there any other options?

@ pturmel What mode would u recommend? is there only window mode else?

Try using this function on a button (perhaps in a dock):

system.perspective.workstation.toWindowed()

Note that there is a peer function for going back to kiosk mode.

My client doesn't like the way it switches they would prefer if it was 1 button press to minimize and we ran in Fullscreen and not window

But it does seem like a impossible task, i appreciate the help

Correct. There is no single function to go from kiosk mode to minimized. Sorry. Perhaps this should be put up on IA's Feature Request portal, as it probably isn't a big task to add to Workstation.

This smells of ChatGPT. Don't put user questions from here into there - it really does not have a good understanding of the Ignition (especially perspective) architecture or jython.

3 Likes

Alejandro has been asked several times not to do that.

3 Likes