Set MAXScript Listener window position

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

 
Thread Tools Search this Thread Display Modes
  5 Days Ago
Set MAXScript Listener window position

Hi all,
Is theMAXScript Listener window can be set to a position via maxscript?Something Like:
set listerner_window.pos=[0,0] ?Thanks for any help.
 
  5 Days Ago
Originally Posted by momo2012: Hi all,
Is theMAXScript Listener window can be set to a position via maxscript?Something Like:
set listerner_window.pos=[0,0] ?Thanks for any help.
Tested on Max 2014

(
 for child in (windows.getChildrenHWND 0 parent:#max) where (child[5] == "MAXScript Listener") do    
 (
  windPosAndSize = windows.getWindowPos child[1]
  windows.setWindowPos child[1] 0 0 windPosAndSize.w windPosAndSize.h true
 )
)
 
  4 Days Ago
Originally Posted by miauu: Tested on Max 2014

(
 for child in (windows.getChildrenHWND 0 parent:#max) where (child[5] == "MAXScript Listener") do    
 (
  windPosAndSize = windows.getWindowPos child[1]
  windows.setWindowPos child[1] 0 0 windPosAndSize.w windPosAndSize.h true
 )
)
Wow,works like a charm,thanks!Is there a lower version solution?3ds max2009~2013 does not support "windows.getWindowPos" and "windows.setWindowPos"
>> MAXScript FileIn Exception: -- Unknown property: "getWindowPos" in #Struct:windows(
 getHWNDData:<fn>; Public,
 getChildrenHWND:<fn>; Public,
 getDesktopHWND:<fn>; Public,
 sendMessage:<fn>; Public,
 getMAXHWND:<fn>; Public,
 processPostedMessages:<fn>; Public,
 addChild:<fn>; Public,
 getChildHWND:<fn>; Public,
 postMessage:<fn>; Public) <<

Last edited by momo2012 : 4 Days Ago at 10:57 PM.
 
  4 Days Ago

(
 function GetWinClass = 
 (
  source = ""
  source += "using System;\n"
  source += "using System.Runtime.InteropServices;\n"
  source += "public class Window\n"
  source += "{\n"
  source += " [DllImport(\"user32.dll\")]\n"
  source += " public static extern bool SetWindowPos(int hWnd, int hWndArg, int Left, int Top, int Width, int Height, int hWndFlags);\n"
  source += " [DllImport(\"user32.dll\")]\n"
  source += " static extern bool GetWindowRect(int hWnd, out POS rect);\n"
  source += " public struct POS\n"
  source += " {\n"
  source += "  public int Left;\n"
  source += "  public int Top;\n"
  source += "  public int Right;\n"
  source += "  public int Bottom;\n"
  source += " }\n"
  source += " public int[] GetWindowPosAndSize(int hWnd)\n"
  source += " {\n"
  source += "  POS rect;\n"
  source += "  if ( GetWindowRect(hWnd, out rect) )\n"
  source += "  {\n"
  source += "   return new int[] { rect.Left, rect.Top, rect.Right - rect.Left, rect.Bottom - rect.Top };\n"
  source += "  }\n"
  source += "  return null;\n"
  source += " }\n"
  source += "}\n"
  
  csharpProvider = dotnetobject "Microsoft.CSharp.CSharpCodeProvider"
  compilerParams = dotnetobject "System.CodeDom.Compiler.CompilerParameters"
  compilerParams.GenerateInMemory = on
  compilerResults = csharpProvider.CompileAssemblyFromSource compilerParams #(source)
  compilerResults.CompiledAssembly.CreateInstance "Window"
 )
 if miauuWindClass_efioj981 == undefined do global miauuWindClass_efioj981 = GetWinClass()
 
 maxVer = (maxVersion())[1]
 newPosX = 100
 newPosY = 200
 for child in (windows.getChildrenHWND 0 parent:#max) where (child[5] == "MAXScript Listener") do
 (
  if maxVer < 16000 then
  (
   dataArr = ::miauuWindClass_efioj981.GetWindowPosAndSize child[1]
   ::miauuWindClass_efioj981.SetWindowPos child[1] 0 newPosX newPosY dataArr[3] dataArr[4] 1
  )
  else
  (
   -- "3dsMax 2014+"
   windPosAndSize = windows.getWindowPos child[1]
   windows.setWindowPos child[1] newPosX newPosY windPosAndSize.w windPosAndSize.h true
  )
 )
)
 
  4 Days Ago
Originally Posted by miauu:

(
 function GetWinClass = 
 (
  source = ""
  source += "using System;\n"
  source += "using System.Runtime.InteropServices;\n"
  source += "public class Window\n"
  source += "{\n"
  source += " [DllImport(\"user32.dll\")]\n"
  source += " public static extern bool SetWindowPos(int hWnd, int hWndArg, int Left, int Top, int Width, int Height, int hWndFlags);\n"
  source += " [DllImport(\"user32.dll\")]\n"
  source += " static extern bool GetWindowRect(int hWnd, out POS rect);\n"
  source += " public struct POS\n"
  source += " {\n"
  source += "  public int Left;\n"
  source += "  public int Top;\n"
  source += "  public int Right;\n"
  source += "  public int Bottom;\n"
  source += " }\n"
  source += " public int[] GetWindowPosAndSize(int hWnd)\n"
  source += " {\n"
  source += "  POS rect;\n"
  source += "  if ( GetWindowRect(hWnd, out rect) )\n"
  source += "  {\n"
  source += "   return new int[] { rect.Left, rect.Top, rect.Right - rect.Left, rect.Bottom - rect.Top };\n"
  source += "  }\n"
  source += "  return null;\n"
  source += " }\n"
  source += "}\n"
  
  csharpProvider = dotnetobject "Microsoft.CSharp.CSharpCodeProvider"
  compilerParams = dotnetobject "System.CodeDom.Compiler.CompilerParameters"
  compilerParams.GenerateInMemory = on
  compilerResults = csharpProvider.CompileAssemblyFromSource compilerParams #(source)
  compilerResults.CompiledAssembly.CreateInstance "Window"
 )
 if miauuWindClass_efioj981 == undefined do global miauuWindClass_efioj981 = GetWinClass()
 
 maxVer = (maxVersion())[1]
 newPosX = 100
 newPosY = 200
 for child in (windows.getChildrenHWND 0 parent:#max) where (child[5] == "MAXScript Listener") do
 (
  if maxVer < 16000 then
  (
   dataArr = ::miauuWindClass_efioj981.GetWindowPosAndSize child[1]
   ::miauuWindClass_efioj981.SetWindowPos child[1] 0 newPosX newPosY dataArr[3] dataArr[4] 1
  )
  else
  (
   -- "3dsMax 2014+"
   windPosAndSize = windows.getWindowPos child[1]
   windows.setWindowPos child[1] newPosX newPosY windPosAndSize.w windPosAndSize.h true
  )
 )
)
Now,the "Full version" works !Thanks for great help!
 
reply share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 08:49 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.