Bring Max Process to Front


#21

i moved to 2016 :sunglasses:


#22

Yes, I can confirm this. In Windows 7 it brings the windows to the front but in Windows 10 it only flashes on the taskbar.

The code from Denis works on both.


#23

same for me…
anyway, I put the SwitchToThisWindow method in my mxs extension … although I don’t know how it works and how it can help :roll_eyes:


#24

Actually the very best use of this on Windows 10 is to combine both…

So you trigger switchToThisWindow() then trigger the toast notification… this way if the toast dissappears (side-note can we make it stay up until clicked?) then the user can see max is trying to get attention because it’s flashing on the taskbar. :slight_smile:


#25

Unfortunately not.

public void ShowBalloonTip (int timeout);

This parameter is deprecated as of Windows Vista. Notification display times are now based on system accessibility settings. (URL)

Even if we could, it could be overridden by another notification.

But having it flashing on the taskbar is good.

PD: If 3ds Max is minimized, it won’t be maximized, at least it doesn’t for me.


#26

Here is another option that seems to work.

The good: no need to compile.
The bad: it won’t work if Max is minimized neither.

(
	
	fn SwitchToMax sender args =
	(
		form   = dotnetobject "MaxCustomControls.MaxForm"
		intPtr = dotnetobject "System.IntPtr" (windows.getMAXHWND())
		--hwnd   = dotnetobject "MaxCustomControls.Win32HandleWrapper" intPtr
		hwnd   = (dotnetobject "System.Windows.Forms.NativeWindow").FromHandle intPtr
		
		--form.Opacity = 0
		form.Show hwnd
		form.Activate()
		form.TopMost = true
		form.TopMost = false
		form.Dispose()
		
		sender.Dispose()
	)
	
	fn Notify =
	(
		NotifyIcon                 = dotnetobject "System.Windows.Forms.NotifyIcon"
		NotifyIcon.BalloonTipTitle = "3ds Max Notification"
		NotifyIcon.BalloonTipText  = "Task Completed!"
		NotifyIcon.Visible         = true
		
		/* Application Asterisk Error Exclamation Hand Information Question Shield Warning WinLogo */
		NotifyIcon.Icon = (dotnetclass "System.Drawing.SystemIcons").Asterisk
		
		dotnet.addeventhandler NotifyIcon "BalloonTipClicked" SwitchToMax
		dotnet.addeventhandler NotifyIcon "Click"             SwitchToMax
		
		NotifyIcon.ShowBalloonTip 0
	)
	
	try (destroydialog ::RO_TEST) catch()

	rollout RO_TEST "" width:242 height:72
	(
		label lb "A NOTIFICATION WILL BE SEND OUT IN: 5" pos:[12,24]
		timer clock "" interval:1000
		
		local counter = 5
		
		on clock tick do
		(
			counter -= 1
			if counter == 0 do
			(
				Notify()
				destroydialog RO_TEST
			)
			lb.text = "A NOTIFICATION WILL BE SEND OUT IN: " + (counter as string)
		)
	)
	
	createdialog RO_TEST
	
)

#27

windows.SendMessage hwnd WM_SYSCOMMAND SC_RESTORE 0