Trying to figure out a way to make 3dsmax jump to front of windows focus. I’ve tried using this user32 method but it doesn’t seem to work. Any ideas? run this script, jump to another windows application, wait 15 seconds… max should come back to focus?
(
fn CreateUser32Assembly =
(
src = "using System;"
src += "using System.Runtime.InteropServices;"
src += "class User32"
src += "{"
src += "[DllImport(\"User32.dll\")]"
src += "public static extern bool SetForegroundWindow(IntPtr hWnd);"
src += "[DllImport(\"User32.dll\", SetLastError=true)]"
src += "public static extern IntPtr SetActiveWindow(IntPtr hWnd);"
src += "[DllImport(\"User32.dll\")]"
src += "public static extern IntPtr GetActiveWindow();"
src += "}"
provider = dotnetobject "Microsoft.CSharp.CSharpCodeProvider"
params = dotnetobject "System.CodeDom.Compiler.CompilerParameters"
params.GenerateInMemory = true
result = provider.CompileAssemblyFromSource params #(src)
result.CompiledAssembly.CreateInstance "User32"
)
user32assembly
fn SetActiveWindowHWND hWnd=
(
if user32assembly == undefined do user32assembly = CreateUser32Assembly()
return (user32assembly.SetActiveWindow hWnd)
)
try (destroydialog ::RO_TEST) catch()
rollout RO_TEST "" width:176 height:72
(
local maxHWND = windows.getMAXHWND()
on RO_TEST open do
(
sleep 15
SetActiveWindowHWND maxHWND
)
)
createdialog RO_TEST
)