You can define some callback functions in advance as needed, and Wise Tools will actively call them when the event occurs.
onPluginEnter(callback)
FunctionWhen the plugin is loaded successfully, Wise Tools will actively call this method (only called once in the life cycle), and all apis should be called after onPluginEnter.
wt.onPluginEnter(() => {
console.log('onPluginEnter')
})
onPluginOut(callback)
FunctionWhen user close the plugin, Wise Tools will actively call this method.
wt.onPluginOut(() => {
console.log('onPluginOut')
})
hideMainWindow()
BooleanHide the Wise Toys main window.
wt.hideMainWindow()
showMainWindow()
BooleanDisplay the Wise Toys main window.
wt.showMainWindow()
outPlugin()
BooleanClose the plugin window.
wt.outPlugin()
hideCurrentPlugin()
BooleanHide current plugin window.
wt.hideCurrentPlugin()
showCurrentPlugin()
BooleanDisplay current plugin window.
wt.showCurrentPlugin()
showOpenDialog(options)
options: Object
Consistent with the option of Electron API dialog.showOpenDialogSync (opens new window) .
Return: Array | Undefined
It returns an array of files selected by the user. If the user cancels the operation, return undefined.
A window pops up asking to select files.
wt.showOpenDialog({
filters:[{'name':'plugin.json',extensions:['json'] }],
properties:['openFile']
})
showSaveDialog(options)
options: Object
Consistent with the option of Electron API dialog.showSaveDialogSync (opens new window).
Return: Array | Undefined
It returns an array of files selected by the user. If the user cancels the operation, return undefined.
A window pops up asking to save the file.
wt.showSaveDialog({
title: 'location to save' ,
defaultPath: wt.getPath('downloads') ,
buttonLabel: 'save'
})
showMessageBox(options)
options: Object
Consistent with the option of Electron API dialog.showMessageBoxSync (opens new window)
Return: Integer
It returns the index of the clicked button.
Displays a message in a popped window.
wt.showMessageBox({
type: 'question' ,
buttons: ['cancel', 'shut down'],
title: 'warning',
message: 'Are you sure to turn off the computer?',
defaultId: 1
})
copyImage(file)
file: String
BooleanCopy files to the system clipboard.
// path
wt.copyImage('/path/to/img.png')
// base64
wt.copyImage('data:image/png;base64,xxxxxxxxx')
shellOpenPath(fullPath)
fullPath: String
Use the system default method to open the specified file.
wt.shellOpenPath('/path/to/file')
showNotification(body)
body: String
Display messages on system notification area.
wt.showNotification('Hello')