一个想法(an idea)

Next
 From:  大道刀 (SUIYAN)
12027.1 
HI EveryOne

将moi.ini文件中的快捷键映射于相对应的工具按钮的鼠标停靠文字(Map the shortcut keys in the moi.ini file to the corresponding tool button mouse-over text),我掌握的方法用<moi:CommandButton title="shortcut key",但这样当快捷键发生修改时,鼠标停靠文字无法动态更新。能否通过脚本或代码,直接将moi.ini文件中快捷键的部分直接显示为鼠标停靠文字?
(The method I have mastered uses "<moi:CommandButton title="shortcut key"", but when the shortcut key is modified, the mouse hover text cannot be dynamically updated. Is it possible to use a script or code to directly display the shortcut key from the moi.ini file in the mouse hover text of the corresponding tool button?)
最好适用于v3+谢谢(Best for v3+ ,Thanks)

EDITED: 21 Jun by SUIYAN

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
12027.2 In reply to 12027.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
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
12027.3 In reply to 12027.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 );
}
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  大道刀 (SUIYAN)
12027.4 In reply to 12027.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.)
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
 From:  Michael Gibson
12027.5 In reply to 12027.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
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged
 

Reply to All Reply to All