ui-commands.ts•18.3 kB
// UI and Floating Window Commands - 界面和悬浮窗命令
// UI Control Creation Commands - UI控件创建命令
export const UIControlCommands = {
// UI.NewLayout - 创建布局
newLayout: {
name: 'mqscript_ui_newlayout',
description: 'Create a new UI layout',
inputSchema: {
type: 'object' as const,
properties: {
orientation: {
type: 'string',
description: 'Layout orientation: vertical or horizontal',
enum: ['vertical', 'horizontal'],
default: 'vertical'
}
},
required: []
},
handler: async (args: { orientation?: string }) => {
const { orientation = 'vertical' } = args;
const script = `UI.NewLayout("${orientation}")`;
return {
content: [
{
type: 'text',
text: `Generated MQScript create layout command:\n\`\`\`\n${script}\n\`\`\`\n\nThis creates a new ${orientation} layout.`
}
]
};
}
},
// UI.NewRow - 布局另起一行
newRow: {
name: 'mqscript_ui_newrow',
description: 'Start a new row in layout',
inputSchema: {
type: 'object' as const,
properties: {},
required: []
},
handler: async () => {
const script = `UI.NewRow()`;
return {
content: [
{
type: 'text',
text: `Generated MQScript new row command:\n\`\`\`\n${script}\n\`\`\`\n\nThis starts a new row in the current layout.`
}
]
};
}
},
// UI.AddTextView - 创建文字框控件
addTextView: {
name: 'mqscript_ui_addtextview',
description: 'Add a text view control',
inputSchema: {
type: 'object' as const,
properties: {
id: {
type: 'string',
description: 'Control ID'
},
text: {
type: 'string',
description: 'Display text',
default: 'Text View'
}
},
required: ['id']
},
handler: async (args: { id: string; text?: string }) => {
const { id, text = 'Text View' } = args;
const script = `UI.AddTextView("${id}", "${text}")`;
return {
content: [
{
type: 'text',
text: `Generated MQScript add text view command:\n\`\`\`\n${script}\n\`\`\`\n\nThis adds a text view with ID "${id}" and text "${text}".`
}
]
};
}
},
// UI.AddEditText - 创建输入框控件
addEditText: {
name: 'mqscript_ui_addedittext',
description: 'Add an edit text control',
inputSchema: {
type: 'object' as const,
properties: {
id: {
type: 'string',
description: 'Control ID'
},
defaultText: {
type: 'string',
description: 'Default text in input field',
default: ''
},
hint: {
type: 'string',
description: 'Hint text',
default: ''
}
},
required: ['id']
},
handler: async (args: { id: string; defaultText?: string; hint?: string }) => {
const { id, defaultText = '', hint = '' } = args;
const script = `UI.AddEditText("${id}", "${defaultText}", "${hint}")`;
return {
content: [
{
type: 'text',
text: `Generated MQScript add edit text command:\n\`\`\`\n${script}\n\`\`\`\n\nThis adds an edit text with ID "${id}".`
}
]
};
}
},
// UI.AddButton - 创建按钮控件
addButton: {
name: 'mqscript_ui_addbutton',
description: 'Add a button control',
inputSchema: {
type: 'object' as const,
properties: {
id: {
type: 'string',
description: 'Control ID'
},
text: {
type: 'string',
description: 'Button text',
default: 'Button'
}
},
required: ['id']
},
handler: async (args: { id: string; text?: string }) => {
const { id, text = 'Button' } = args;
const script = `UI.AddButton("${id}", "${text}")`;
return {
content: [
{
type: 'text',
text: `Generated MQScript add button command:\n\`\`\`\n${script}\n\`\`\`\n\nThis adds a button with ID "${id}" and text "${text}".`
}
]
};
}
},
// UI.AddCheckBox - 创建复选框控件
addCheckBox: {
name: 'mqscript_ui_addcheckbox',
description: 'Add a checkbox control',
inputSchema: {
type: 'object' as const,
properties: {
id: {
type: 'string',
description: 'Control ID'
},
text: {
type: 'string',
description: 'Checkbox label text',
default: 'Checkbox'
},
checked: {
type: 'boolean',
description: 'Initial checked state',
default: false
}
},
required: ['id']
},
handler: async (args: { id: string; text?: string; checked?: boolean }) => {
const { id, text = 'Checkbox', checked = false } = args;
const script = `UI.AddCheckBox("${id}", "${text}", ${checked})`;
return {
content: [
{
type: 'text',
text: `Generated MQScript add checkbox command:\n\`\`\`\n${script}\n\`\`\`\n\nThis adds a checkbox with ID "${id}", text "${text}", and initial state ${checked}.`
}
]
};
}
},
// UI.Show - 显示UI
showUI: {
name: 'mqscript_ui_show',
description: 'Show the UI dialog',
inputSchema: {
type: 'object' as const,
properties: {
title: {
type: 'string',
description: 'Dialog title',
default: 'Dialog'
}
},
required: []
},
handler: async (args: { title?: string }) => {
const { title = 'Dialog' } = args;
const script = `UI.Show("${title}")`;
return {
content: [
{
type: 'text',
text: `Generated MQScript show UI command:\n\`\`\`\n${script}\n\`\`\`\n\nThis shows the UI dialog with title "${title}".`
}
]
};
}
}
};
// UI Property Commands - UI属性设置命令
export const UIPropertyCommands = {
// UI.SetText - 设置控件文本
setText: {
name: 'mqscript_ui_settext',
description: 'Set text of a UI control',
inputSchema: {
type: 'object' as const,
properties: {
id: {
type: 'string',
description: 'Control ID'
},
text: {
type: 'string',
description: 'New text content'
}
},
required: ['id', 'text']
},
handler: async (args: { id: string; text: string }) => {
const { id, text } = args;
const script = `UI.SetText("${id}", "${text}")`;
return {
content: [
{
type: 'text',
text: `Generated MQScript set text command:\n\`\`\`\n${script}\n\`\`\`\n\nThis sets the text of control "${id}" to "${text}".`
}
]
};
}
},
// UI.GetText - 获取控件文本
getText: {
name: 'mqscript_ui_gettext',
description: 'Get text from a UI control',
inputSchema: {
type: 'object' as const,
properties: {
id: {
type: 'string',
description: 'Control ID'
},
resultVariable: {
type: 'string',
description: 'Variable name to store result',
default: 'text'
}
},
required: ['id']
},
handler: async (args: { id: string; resultVariable?: string }) => {
const { id, resultVariable = 'text' } = args;
const script = `${resultVariable} = UI.GetText("${id}")`;
return {
content: [
{
type: 'text',
text: `Generated MQScript get text command:\n\`\`\`\n${script}\n\`\`\`\n\nThis gets the text from control "${id}" and stores it in variable "${resultVariable}".`
}
]
};
}
},
// UI.SetEnabled - 设置控件启用状态
setEnabled: {
name: 'mqscript_ui_setenabled',
description: 'Set enabled state of a UI control',
inputSchema: {
type: 'object' as const,
properties: {
id: {
type: 'string',
description: 'Control ID'
},
enabled: {
type: 'boolean',
description: 'Enable state'
}
},
required: ['id', 'enabled']
},
handler: async (args: { id: string; enabled: boolean }) => {
const { id, enabled } = args;
const script = `UI.SetEnabled("${id}", ${enabled})`;
return {
content: [
{
type: 'text',
text: `Generated MQScript set enabled command:\n\`\`\`\n${script}\n\`\`\`\n\nThis sets control "${id}" enabled state to ${enabled}.`
}
]
};
}
},
// UI.SetVisible - 设置控件可见性
setVisible: {
name: 'mqscript_ui_setvisible',
description: 'Set visibility of a UI control',
inputSchema: {
type: 'object' as const,
properties: {
id: {
type: 'string',
description: 'Control ID'
},
visible: {
type: 'boolean',
description: 'Visible state'
}
},
required: ['id', 'visible']
},
handler: async (args: { id: string; visible: boolean }) => {
const { id, visible } = args;
const script = `UI.SetVisible("${id}", ${visible})`;
return {
content: [
{
type: 'text',
text: `Generated MQScript set visible command:\n\`\`\`\n${script}\n\`\`\`\n\nThis sets control "${id}" visibility to ${visible}.`
}
]
};
}
}
};
// Floating Window Commands - 悬浮窗命令
export const FloatingWindowCommands = {
// FW.Create - 创建悬浮窗
create: {
name: 'mqscript_fw_create',
description: 'Create a floating window',
inputSchema: {
type: 'object' as const,
properties: {
id: {
type: 'string',
description: 'Floating window ID'
},
x: {
type: 'number',
description: 'X position',
default: 100
},
y: {
type: 'number',
description: 'Y position',
default: 100
},
width: {
type: 'number',
description: 'Width',
default: 200
},
height: {
type: 'number',
description: 'Height',
default: 100
}
},
required: ['id']
},
handler: async (args: { id: string; x?: number; y?: number; width?: number; height?: number }) => {
const { id, x = 100, y = 100, width = 200, height = 100 } = args;
const script = `FW.Create("${id}", ${x}, ${y}, ${width}, ${height})`;
return {
content: [
{
type: 'text',
text: `Generated MQScript create floating window command:\n\`\`\`\n${script}\n\`\`\`\n\nThis creates floating window "${id}" at position (${x}, ${y}) with size ${width}x${height}.`
}
]
};
}
},
// FW.AddTextView - 添加文字框到悬浮窗
addTextView: {
name: 'mqscript_fw_addtextview',
description: 'Add text view to floating window',
inputSchema: {
type: 'object' as const,
properties: {
windowId: {
type: 'string',
description: 'Floating window ID'
},
controlId: {
type: 'string',
description: 'Control ID'
},
text: {
type: 'string',
description: 'Display text',
default: 'Text'
},
x: {
type: 'number',
description: 'X position in window',
default: 10
},
y: {
type: 'number',
description: 'Y position in window',
default: 10
},
width: {
type: 'number',
description: 'Width',
default: 100
},
height: {
type: 'number',
description: 'Height',
default: 30
}
},
required: ['windowId', 'controlId']
},
handler: async (args: { windowId: string; controlId: string; text?: string; x?: number; y?: number; width?: number; height?: number }) => {
const { windowId, controlId, text = 'Text', x = 10, y = 10, width = 100, height = 30 } = args;
const script = `FW.AddTextView("${windowId}", "${controlId}", "${text}", ${x}, ${y}, ${width}, ${height})`;
return {
content: [
{
type: 'text',
text: `Generated MQScript add text view to floating window:\n\`\`\`\n${script}\n\`\`\`\n\nThis adds text view "${controlId}" with text "${text}" to floating window "${windowId}".`
}
]
};
}
},
// FW.AddButton - 添加按钮到悬浮窗
addButton: {
name: 'mqscript_fw_addbutton',
description: 'Add button to floating window',
inputSchema: {
type: 'object' as const,
properties: {
windowId: {
type: 'string',
description: 'Floating window ID'
},
controlId: {
type: 'string',
description: 'Control ID'
},
text: {
type: 'string',
description: 'Button text',
default: 'Button'
},
x: {
type: 'number',
description: 'X position in window',
default: 10
},
y: {
type: 'number',
description: 'Y position in window',
default: 10
},
width: {
type: 'number',
description: 'Width',
default: 80
},
height: {
type: 'number',
description: 'Height',
default: 40
}
},
required: ['windowId', 'controlId']
},
handler: async (args: { windowId: string; controlId: string; text?: string; x?: number; y?: number; width?: number; height?: number }) => {
const { windowId, controlId, text = 'Button', x = 10, y = 10, width = 80, height = 40 } = args;
const script = `FW.AddButton("${windowId}", "${controlId}", "${text}", ${x}, ${y}, ${width}, ${height})`;
return {
content: [
{
type: 'text',
text: `Generated MQScript add button to floating window:\n\`\`\`\n${script}\n\`\`\`\n\nThis adds button "${controlId}" with text "${text}" to floating window "${windowId}".`
}
]
};
}
},
// FW.Show - 显示悬浮窗
show: {
name: 'mqscript_fw_show',
description: 'Show floating window',
inputSchema: {
type: 'object' as const,
properties: {
id: {
type: 'string',
description: 'Floating window ID'
}
},
required: ['id']
},
handler: async (args: { id: string }) => {
const { id } = args;
const script = `FW.Show("${id}")`;
return {
content: [
{
type: 'text',
text: `Generated MQScript show floating window command:\n\`\`\`\n${script}\n\`\`\`\n\nThis shows floating window "${id}".`
}
]
};
}
},
// FW.Hide - 隐藏悬浮窗
hide: {
name: 'mqscript_fw_hide',
description: 'Hide floating window',
inputSchema: {
type: 'object' as const,
properties: {
id: {
type: 'string',
description: 'Floating window ID'
}
},
required: ['id']
},
handler: async (args: { id: string }) => {
const { id } = args;
const script = `FW.Hide("${id}")`;
return {
content: [
{
type: 'text',
text: `Generated MQScript hide floating window command:\n\`\`\`\n${script}\n\`\`\`\n\nThis hides floating window "${id}".`
}
]
};
}
},
// FW.SetText - 设置悬浮窗控件文本
setText: {
name: 'mqscript_fw_settext',
description: 'Set text of floating window control',
inputSchema: {
type: 'object' as const,
properties: {
windowId: {
type: 'string',
description: 'Floating window ID'
},
controlId: {
type: 'string',
description: 'Control ID'
},
text: {
type: 'string',
description: 'New text content'
}
},
required: ['windowId', 'controlId', 'text']
},
handler: async (args: { windowId: string; controlId: string; text: string }) => {
const { windowId, controlId, text } = args;
const script = `FW.SetText("${windowId}", "${controlId}", "${text}")`;
return {
content: [
{
type: 'text',
text: `Generated MQScript set floating window text command:\n\`\`\`\n${script}\n\`\`\`\n\nThis sets text of control "${controlId}" in window "${windowId}" to "${text}".`
}
]
};
}
},
// FW.OnClick - 设置悬浮窗按钮点击事件
onClick: {
name: 'mqscript_fw_onclick',
description: 'Set click event handler for floating window button',
inputSchema: {
type: 'object' as const,
properties: {
windowId: {
type: 'string',
description: 'Floating window ID'
},
controlId: {
type: 'string',
description: 'Button control ID'
},
handlerCode: {
type: 'string',
description: 'Event handler code',
default: '// Button click handler'
}
},
required: ['windowId', 'controlId']
},
handler: async (args: { windowId: string; controlId: string; handlerCode?: string }) => {
const { windowId, controlId, handlerCode = '// Button click handler' } = args;
const script = `Sub ${windowId}_${controlId}_Click()\n ${handlerCode}\nEnd Sub\nFW.OnClick("${windowId}", "${controlId}", "${windowId}_${controlId}_Click")`;
return {
content: [
{
type: 'text',
text: `Generated MQScript floating window click event:\n\`\`\`\n${script}\n\`\`\`\n\nThis sets click handler for button "${controlId}" in window "${windowId}".`
}
]
};
}
}
};