TaskDialog infront of dynamo player (foreground)

Hey guys,

some of my scripts are using the taskdialog to inform the user about issues. Unfortunately the taskdialog opens behind the dynamo-player. Is there an opportunity to show it infront of the dynamo player? I don’t want to drag the dynamo-player before executing.

Thanks for your help in advance :slight_smile:

I think Dynamo and the Dynamo Player are programmed to be always on top.
What does your dialog box look like? It’s hard to help you without more information.

Hello
You can try to reduce the window player at start with user32 API

reduce_player2

import clr
import sys
import System
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
import Autodesk.Revit.DB as DB

#import Revit APIUI namespace
clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *


clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument

pf_path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.ProgramFilesX86)
sys.path.append(pf_path + '\\IronPython 2.7\\Lib')
import ctypes

titleproject = doc.Title

windowPlayer = ctypes.windll.user32.FindWindowW(None, titleproject + ".rvt - Lecteur Dynamo")
if windowPlayer:
	hWndParent = windowPlayer
	SW_MAXIMIZE = 3
	SW_MINIMIZE = 6
	ctypes.windll.user32.ShowWindow(hWndParent, SW_MINIMIZE)

	dial = TaskDialog("Info")
	dial.MainInstruction = "Player has been reduced"
	dial.Show()

Need to adapt this line with your language

windowPlayer = ctypes.windll.user32.FindWindowW(None, titleproject + ".rvt - Lecteur Dynamo")

7 Likes

@c.poupin always coming with the random Python diamonds!!!

This looks so so so useful as often we run into the issue of users losing task dialogues behind player and thinking the script is stuck.

Going to incorporate this code into our popup node so that by default it minimises player for people.

Cheers

2 Likes

@c.poupin

That’s a really nice solution. I bet with “SW_MAXIMIZE” you can maximize it again after the user confirmed the taskdialog :+1: via the result of taskdialog.

Just wanted to show another method I use a bit using Winforms and the self.TopMost variable.
dnkJxYm5va

import clr
clr.AddReference('System.Windows.Forms')
clr.AddReference('System.Drawing')

from System.Drawing import *
from System.Windows.Forms import *
from System import Array, Object

class SimpleForm(Form):
    def __init__(self):
        
        # The text to show in the top bar
        self.Text = "A Dialog with Information"
        # The width of the form in pixels
        self.Width = 500
        # The height of the form in pixels
        self.Height = 240
        # Make the form a fixed size
        self.FormBorderStyle = FormBorderStyle.FixedDialog		
        # Position the form in the center of the screen
        self.StartPosition = FormStartPosition.CenterScreen 
        # Bring the form to the front of all windows
        self.TopMost = True
        # Show top bar controls	
        self.ControlBox = True
        self.MaximizeBox = False
        self.MinimiseBox = True
        

runMe = IN[0]

if runMe:
    # Create the form
    form = SimpleForm()
    # Run the form
    Application.Run(form)
else:
    OUT = "Set RunMe to True";
4 Likes

Also a really good solution, but I think I will stick to minimizing and restoring the dynamo player window. :+1:

1 Like