MoI discussion forum
MoI discussion forum

Full Version: 一个想法(an idea)

Show messages: All  1  2-5

From: Michael Gibson
21 Jun   [#2] In reply to [#1]
Hi SUIYAN,

It is possible to set the title="" property on command buttons with script like this:

code:
function SetButtonTitle( button )
{
	button.title = 'the title';
}

var panels = moi.ui.getUIPanels();

for ( var i = 0; i < panels.length; ++i )
{
	var panel = panels.item(i);
	var buttons = panel.document.getElementsByTagName( 'moi:CommandButton' );

	for ( var j = 0; j < buttons.length; ++j )
		SetButtonTitle( buttons[j] );
}


But the part that may be tricky is that any buttons on popup menus, dialog windows, or command sets will only be accessible after the menu/dialog/whatever is displayed.

- Michael
From: Michael Gibson
21 Jun   [#3] In reply to [#1]
and the shortcut keys can be accessed by script like this: (Moi v4+ required):

code:
var shortcuts = moi.shortcutKeys.getShortcuts();

for ( var i = 0; i < shortcuts.length; ++i )
{
     var shortcut = shortcuts.item(i);
     
      var key = shortcut.key;
      var command = shortcut.command;
     
      moi.ui.alert( key + ' ' + command );
}

From: 大道刀 (SUIYAN)
21 Jun   [#4] In reply to [#3]
HI Michael
抱歉,我完全不懂代码,所以我不知道这两段代码如何使用,昨天我一直尝试使用AI(豆包的免费版本)编写这两段代码的功能脚本,结果是无效的脚本。所以,我该如何使用这两段代码?是编写独立的脚本或者添加到某个文件中,让代码发挥作用。(Sorry, I don't understand code at all, so I don't know how to use these two pieces of code. Yesterday, I kept trying to use AI (the free version of Doubao) to write functional scripts for these two pieces of code, but the scripts were invalid. So, how should I use these two pieces of code? Should I write separate scripts or add them to a certain file to make the code work.)
From: Michael Gibson
21 Jun   [#5] In reply to [#4]
Hi SUIYAN,

re:
> Yesterday, I kept trying to use AI (the free version of Doubao) to write functional scripts
> for these two pieces of code, but the scripts were invalid.

Yes I've heard from others that tried to make MOI scripts using AI and it tends to generate just non-functional garbage code. I suspect there is not enough training data available for it to work very well.

For the first one showing how to set the title property you could put that code into a .js file, then (using MOI v4 or higher) put that .js file into the Moi appdata startup folder. When MOI is launched any .js files in that folder are loaded and run.

Another way to run it which should work in V3 is to add script: to the start of it and do a Ctrl+C to copy it to the clipboard. Then inside MoI type the Tab key to put keyboard focus into the XYZ input control, then Ctrl+V and Enter will run that code, setting the title="" attribute on every <moi:CommandButton> in the currently loaded UI.

- Michael

Show messages: All  1  2-5