You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何将Sikuli脚本转为独立可执行文件(.exe/.jar)跨系统运行

Hey there! Let's walk through how to package your SikuliX script (the .sikuli file) along with the SikuliX environment into a .jar or .exe so it can run smoothly on other systems. I'll break this down step by step for both formats, and also note some key things to watch out for with your sample script.

First, let's restate your sample code in a more readable format (since SikuliX uses a Python-like syntax, line breaks help clarity):

type(Key.WIN)
type("Internet Explorer"+Key.ENTER)
click(Pattern("1517398787539.png").targetOffset(-41,1))
exit()
type('A', Key.CTRL)
type(Key.DELETE)
type("www.google.com"+Key.ENTER)
exit()
打包成 .jar 文件

This is the simpler route, and the generated jar will work on any system with a compatible Java Runtime Environment (JRE):

  • First, make sure you have the full SikuliX IDE installed (it includes all necessary runtime components).
  • Open your .sikuli project in the SikuliX IDE.
  • Go to the top menu: File -> Export as Jar.
  • In the export window, configure these options:
    • Select your .sikuli folder as the main script source.
    • Check the Include SikuliX Runtime box—this is critical, as it packages all the SikuliX libraries needed to run the script, so the end user doesn't need to install SikuliX themselves.
    • Choose an output path and name for your jar file.
    • Double-check that any images your script uses (like 1517398787539.png in your sample) are inside the .sikuli folder—SikuliX will automatically include them in the jar.
  • Click Export and wait for the process to finish.
  • To run the jar, the end user can either double-click it (if their system is set up to run jars with Java) or use the command: java -jar your-script-name.jar
打包成 .exe 文件

SikuliX doesn't have a built-in way to make exes, but we can use a third-party tool called Launch4j to wrap our jar into a Windows executable. Here's how:

  1. First, follow the steps above to create a jar file that includes the SikuliX Runtime.
  2. Grab Launch4j (you can use the portable version if you don't want to install it).
  3. Open Launch4j and configure these tabs:
    • Basic: Set your desired output exe file path/name, select your jar file in the "Jar" field, and set the "Main class" to org.sikuli.script.Runner (this is the entry point for SikuliX scripts).
    • JRE: Specify the minimum JRE version (SikuliX typically requires Java 8 or newer). If you want the exe to run without the end user having Java installed, check "Bundle JRE" and select a local JRE folder—this will add the JRE to the exe package (note: this makes the file size larger).
    • Icons (optional): You can set a custom icon for your exe here to make it look more polished.
  4. Click Build wrapper to generate the exe file.
  5. The resulting exe can be run directly on Windows systems—no need for the user to install SikuliX, and if you bundled the JRE, no Java installation is required either.

Important Notes

  • Test on target systems: Always test your jar/exe on a system that doesn't have SikuliX installed to make sure everything works, especially image recognition (since screen resolutions or UI elements might differ).
  • Avoid absolute paths: Your sample uses a relative path for the image (1517398787539.png)—keep it that way! Absolute paths will break on other systems because the file structure will be different.
  • Permissions: If your script does system-level actions (like opening IE), the user might need to run the exe/jar as an administrator to avoid issues.

内容的提问来源于stack exchange,提问作者Jerome Arockiam

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 06:37:17