Callback when SME is open and closed

I've got the callback for when SME is open from MSX help and I've tried to reverse engineer it to work when it's closed.

I've never used dialogmonitorops or UIAccessor before so any help would be appreciated.

Code I've got so far:

clearlistener()
DialogMonitorOPS.unRegisterNotification id:#mxs_test_open
DialogMonitorOPS.unRegisterNotification id:#mxs_test_closed
 
 
fn SlateCallbackOpen = (
	clearlistener()
	h = dialogmonitorops.getwindowhandle() -- get current popup window
 
	if UIAccessor.GetWindowText h == "Slate Material Editor" then (
		print "Slate Material Editor is opened"
		print (UIAccessor.GetWindowClassName h)
		print (UIAccessor.GetWindowText h)
	)
	true
)
 
fn SlateCallbackClosed = (
	clearlistener()
	h = dialogmonitorops.getwindowhandle() -- get current popup window
 
	if UIAccessor.GetWindowText h != "Slate Material Editor" then (
		print "Slate Material Editor is closed"
		print (UIAccessor.GetWindowClassName h)
		print (UIAccessor.GetWindowText h)		
	)
	true
)
 
-- register dialog monitor callback notificition
dialogmonitorops.registernotification SlateCallbackOpen id:#mxs_test_open
dialogmonitorops.registernotification SlateCallbackClosed id:#mxs_test_closed
 
-- enable dialog monitor
dialogmonitorops.enabled = true

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
3dwannab's picture

Got this example now from the

Got this example now from the help file also..

(
sme.Open() --Open the SME
theParent = windows.getChildHWND 0 "Slate Material Editor" --get the HWND of the SME
rollout sme_toolbox_rollout "SME Toolbox"
(
	button btn_nextMap "UP One Level" width:150
	on btn_nextMap pressed do
	(
		theObj = sme.GetMtlInParamEditor() --get the node from the parameter panel
		if theObj != undefined do --if there is a valid node, get its dependents
		(
			local theDeps = for m in refs.dependents theObj where isKindOf m TextureMap or isKindOf m Material collect m
			if theDeps.count > 0 do sme.SetMtlInParamEditor theDeps[1]	--if there were any, select the first one	
		)
	)
)
createDialog sme_toolbox_rollout parent:theParent[1] --create a dialog as child of the SME
)

But still no moving with SME yet..

pixamoon's picture
3dwannab's picture

I think I've got a headache

I think I've got a headache looking at this stuff.. I might ask over on some of the other MXS forums :)

pixamoon's picture

`

I'm looking now into WindowShopper by Rotem Shiffman

it read messages of windows in real time and it uses "WndProc"

I'll try to get some function to read windows move only

pixamoon's picture

`

oki,

here is it a small script to create callback for external window

it only prints out SME position but you will see general idea how it works

it's based on Window Shopper by Rotem Shiffman:
http://www.monotoneminimal.com/free-tools

take a look in attachment

remember to declare callback as global and release handle when you close your script

global msgSnooper
try(msgSnooper.releaseHandle())catch()

when callback is a global variable you can stop it also when script crash -> msgSnooper.releaseHandle()

ha, and also... with this callback messages you can read when SME is opened or closed :)

AttachmentSize
help_-_callback_-_get_window_position.ms 8.29 KB
help_-_callback_-_get_window_position_-_open-close.ms 8.38 KB

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.