Getting dialog hWnd using matchpattern


#1

sorry its a really beginner’s question
when i open slate metrial editor and i type this
windows.getChildHWND 0 “slate material editor”

i get its hWnd

can i use the same formula but with only part of the dialog name ?

i tried this but with no luck

windows.getChildHWND 0 (“matchPattern pattern:“slate*””)
it gives this error

– Type error: Call needs function or class, got: “matchPattern pattern:”
– MAXScript callstack:
– thread data: threadID:1628


– [stack level: 0]
– In anonymous codeblock
– Locals:
– Externals:
– slate: Global:slate : undefined


– [stack level: 1]
– called from top-level


#2

Not really.
There could be multiple slate windows open if you have more than one max instance running.

  1. Use windows.getChildrenHWND 0 to collect only desktop windows of class NodeJoeMainWindow .
  2. Find the window that has its 6th value equal to current max hwnd. (.getChildrenHWND returns array of arrays, same as windows.getHWNDData)

that’s it
.

Check the mxs reference.
getChildHWND expects string as the second agrument, not bool as in your case


#3

i tried this
for child in (windows.getChildrenHWND 0) where (matchPattern child[5] pattern:“Slate*”) do
print “slate found”

but its so slow
not instant like the other formula


#4

it is no matter how fast your solution is, it isn’t correct in cases when there’s more than one instance of max running and also it won’t work for localized max instances (if it matters)
what’s your timings for windows.getChildrenHWND 0 and what timings you need?


#5

really thanks alot for replying and helping

can you please clarify more what do you mean by max instances

also i don’t know how to know the timing exactly
but by eye its around 1 second or 2 seconds


#6

i tried now opening two empty max new files and this formula

windows.getChildHWND 0 “slate material editor”

still works for both and giving me different hWnd on each file


#7

I mean that if you run multiple 3dsmax instances, not max scenes.
For example 20xx and 20xx at the same time and it doesn’t matter which versions you run

(
t1 = timestamp()
sme_windows = for w in windows.getChildrenHWND 0 where w[4] == "NodeJoeMainWindow " collect w
format "%sec\n" (((timestamp())-t1)/1000.0)
print sme_windows
)