PDA

View Full Version : Command exactly ONE module number



John Perkins
04-16-2006, 12:33 AM
Ok, this is a bit of a hack and someone may find a better way, but I figured out how to send commands to exactly the right module.

The trick is to open it yourself and hold onto it.


AddMenuItem("My DDR", code(
MyDDR=Launch("VideoEditor_DDR")
)
)

AddMenuItem("Close My DDR", code(

MyDDR:Close()
)
)

Add these menu items to a module. (probably not a DDR)
Open a few DDR's the normal way.
Open exactly one using your new menu item and move it to the side so that you know which one it was.
Open a few more the normal way.
Now use the Close My DDR menu item.
Only your own DDR is closed ;)

I'm sure that someone else will come up with a better example and hopefully better uses.

Be very careful with that variable. If you close the module, that variable points to an invalid address and you can actually crash VT by sending commands to a pointer to an invalid address.

If someone has a better idea of how to deal with this, please, chime in. We need a good community project :thumbsup:

John Perkins
04-16-2006, 01:13 AM
AH HA!!!!!:rock:

Here it is, it is possible!!!

99% of this code is the pause, not selecting the module. Place this in your module of choice (a DDR might be confusing)


AddMenuItem("Pause DDR1", code(
SetFocusToWindow( "VideoEditor_DDR" , 1 )
FindModule( VideoEditor_DDR ) : {
if( GetPause() )
{
SetPause(false)
if (GetSpeed()==0)
{
if (GetPosition() >= (GetLength() - 1)) SetSpeedAndPosition(1,0)
else SetSpeed(1)
}
else SetSpeed(GetSpeed())
}
else if (GetSpeed()==0) SetSpeed(1)
else SetSpeed(0)
}
)

)

AddMenuItem("Pause DDR2", code(
SetFocusToWindow( "VideoEditor_DDR" , 2 )
FindModule( VideoEditor_DDR ) : {
if( GetPause() )
{
SetPause(false)
if (GetSpeed()==0)
{
if (GetPosition() >= (GetLength() - 1)) SetSpeedAndPosition(1,0)
else SetSpeed(1)
}
else SetSpeed(GetSpeed())
}
else if (GetSpeed()==0) SetSpeed(1)
else SetSpeed(0)
}
)

)

Open a bunch of DDR's and put video in each.
Then toggle pause with the menu items you added.
It will toggle pause on the correct DDR!

You can get even more control by using commands like IsModuleNumberAvailable(char Name, int ModuleNumber) and GetHighestModuleNumber(char Name)

What is happening is that findmodule will point you to which ever module of that type has had focus last.

Just don't let much time elapse between setting focus and finding the module, because a mouse click may unfocus your module.

The other gotcha is that I haven't figured out how to return focus to the original module so that keyboard shortcuts will be sent to the correct module.

radams
04-16-2006, 04:53 AM
Oh YEAH!!!!!!!!!!!!!!!!!!!!!

Thanks John....this is sweet !!!!!

Cheers,