Skip to content

Script

PixPin embeds a simple script engine based on JavaScript syntax, which can be used to write simple scripts to use PixPin's functions.

Call Path

Shortcut / Action

You can set scripts in the "Shortcut / Action" page in the configuration and call them via shortcuts or the tray menu.

Startup Command (Windows Only)

Execute the script by entering pixpin.exe -r "script content" or pixpin.exe -f "script file" in the command line.

TIP

When executing a script via the startup command, you need to start a PixPin instance first, and the script will be executed in the already started instance.

Built-in Objects

pixpin

The pixpin object is the core object of PixPin, providing some common functions.


  • pixpin.screenShotAndEdit()

    • Open the screenshot interface.
  • pixpin.screenShot(AfterShotAction: ShotAction)

    • Open the screenshot interface and set the action to be executed after the user selects the screenshot area. Refer to the definition of ShotAction for supported actions.
    • Example: pixpin.screenShot(ShotAction.Copy) Manually screenshot and copy.
  • pixpin.directScreenShot(shotRect: rect, shotAction: ShotAction)

    • Direct screenshot (shotRect: screenshot area, shotAction: action after screenshot).
    • Example: pixpin.directScreenShot(pixpin.genRect(100, 100, 500, 500), ShotAction.Copy) Screenshot the area at 100,100 with a width and height of 500 and copy.
  • pixpin.gifShotPause()

    • Pause/Resume GIF recording.
    • Return value true: Success, false: Failure (Current state is not GIF recording).
  • pixpin.setScreenShotRect(x: int, y: int, width: int, height: int)

    • Set the screenshot area.
    • Return value true: Success, false: Failure (Currently not in the screenshot interface).
  • pixpin.setScreenShotRectRadius(ratio: number)

    • Set the corner radius of the screenshot area.
    • Return value true: Success, false: Failure (Currently not in the screenshot interface).
  • pixpin.openCustomScreenShot()

    • Open the custom screenshot interface.
  • pixpin.longScreenShot(area: rect)

    • Open the scrolling screenshot interface (area: scrolling screenshot area, can be generated via interfaces returning rect type like pixpin.genRect).
    • Example: pixpin.longScreenShot(pixpin.genRect(100, 100, 500, 500)) Scrolling screenshot the area at 100,100 with a width and height of 500.
  • pixpin.openLongScreenShot(x: int, y: int, width: int, height: int)

    • Open the scrolling screenshot interface (x, y, width, height: scrolling screenshot area).
  • pixpin.gifScreenShot(area: rect)

    • Open the GIF screenshot interface (area: GIF screenshot area, can be generated via interfaces returning rect type like pixpin.genRect).
    • Example: pixpin.gifScreenShot(pixpin.genRect(100, 100, 500, 500)) GIF screenshot the area at 100,100 with a width and height of 500.
  • pixpin.openGifScreenShot(x: int, y: int, width: int, height: int)

    • Open the GIF screenshot interface (x, y, width, height: GIF screenshot area).
  • pixpin.genRectUnderCursor(width: int, height: int)

    • Generate a rectangular area centered on the mouse position.
    • Example: pixpin.genRectUnderCursor(100, 100) Generate a rectangular area centered on the mouse position with a width and height of 100.
  • pixpin.genRect(x: int, y: int, width: int, height: int)

    • Generate a rectangular area.
  • pixpin.getSpRect(type: int)

    • Get a special rectangular area.
    • Parameter values:
      • PixConst.SpRectScreenUnderMouse : The screen area where the mouse is located.
      • PixConst.SpRectAllScreen : All screen areas.
      • PixConst.SpRectWindowUnderMouse : The window area where the mouse is located.
      • PixConst.SpRectLastShotRect : The area of the last screenshot.

  • pixpin.pinFromCilpBoard()

    • Get data from the clipboard and pin it.
  • pixpin.destoryAllPin()

    • Destroy all pins.
  • pixpin.saveAllPinImageTo(path: string)

    • Save all pins on the screen to the specified path.
    • Example: pixpin.saveAllPinImageTo("C:/Users/xxx/Desktop") Save all pins to the desktop.
    • Note that in Windows, the path needs to use / or \\ as a separator.
  • pixpin.saveAllPinImageWithDialog()

    • Save all pins on the screen, popping up a save dialog to select the save path.
  • pixpin.restoreLastClosedPin()

    • Restore the last closed pin.
    • Return value true: Success, false: Failure.
  • pixpin.trigMousePenetration()

    • Set/Cancel mouse through for the pin at the mouse position.
  • pixpin.closeAllPin()

    • Close all pins.
  • pixpin.setAllPinToRoiMode()

    • Set all pins to thumbnail mode.
  • pixpin.unsetAllPinToRoiMode()

    • Unset all pins from thumbnail mode.
  • pixpin.hideOrShowAllPin()

    • Hide/Show all pins.
  • pixpin.isAllPinHide()

    • Return value true: All pins are hidden, false: Some pins are shown.
  • pixpin.openConfigurationWindow()

    • Open the configuration window.

Other

  • pixpin.switchPinGroup()

    • Open the window to switch pin groups.
  • pixpin.disableShortcuts(checked: bool)

    • Disable shortcuts (checked: true disable, false enable).
  • pixpin.isDisableShortcuts()

    • Return value true: Shortcuts are disabled, false: Shortcuts are not disabled.
  • pixpin.runSystem(cmd: string)

    • Execute a system command.
    • Example: pixpin.runSystem("calc") Open Calculator.
  • pixpin.runSystemSync(cmd: string)

    • Execute a system command and wait for completion to return the result.

    • Example: pixpin.runSystemSync("calc") Open Calculator.

    • Return value:

      json
      {
          "code" : Command return value,
          "output" : Command normal output,
          "error" : Command error output,
      }
      {
          "code" : Command return value,
          "output" : Command normal output,
          "error" : Command error output,
      }

ShotAction

Define the action after screenshot.

  • ShotAction.Copy

    • Copy screenshot to clipboard.
  • ShotAction.Pin

    • Pin.
  • ShotAction.LongShot

    • Scrolling screenshot.
  • ShotAction.GifShot

    • GIF screenshot.
  • ShotAction.CopyOcrText

    • Copy text in screenshot to clipboard.
  • ShotAction.Save

    • Save screenshot.
  • ShotAction.QuickSave

    • Quick save screenshot.
  • ShotAction.Translate

    • Translate text in screenshot (Requires setting translation API Key or membership).
  • ShotAction.Close

    • Close screenshot.
  • ShotAction.OcrTable

    • Convert text in screenshot to table (Membership available).