API

Event

You can define some callback functions in advance as needed, and Wise Tools will actively call them when the event occurs.

onPluginEnter(callback)

  • callbackFunction

When 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)

  • callbackFunction

When user close the plugin, Wise Tools will actively call this method.

    
        wt.onPluginOut(() => {
            console.log('onPluginOut')
        })
    

Function

hideMainWindow()

  • Return: Boolean

Hide the Wise Toys main window.

    
      wt.hideMainWindow()
    

showMainWindow()

  • Return: Boolean

Display the Wise Toys main window.

    
      wt.showMainWindow()
    

outPlugin()

  • Return: Boolean

Close the plugin window.

    
      wt.outPlugin()
    

hideCurrentPlugin()

  • Return: Boolean

Hide current plugin window.

    
      wt.hideCurrentPlugin()
    

showCurrentPlugin()

  • Return: Boolean

Display 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

  • Return: Boolean

Copy 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')
    
L O A D I N G