Class App

java.lang.Object
org.sikuli.script.App

public class App
extends Object
App implements features to manage (open, switch to, close) applications. on the system we are running on and to access their assets like windows
TAKE CARE: function behavior differs depending on the running system (cosult the docs for more info)
  • Field Details

  • Constructor Details

  • Method Details

    • isWindow

      public boolean isWindow()
    • start

      public static Region start​(App.Type appType)
    • waitForWindow

      public Region waitForWindow()
    • waitForWindow

      public Region waitForWindow​(int seconds)
    • openLink

      public static boolean openLink​(String url)
    • pause

      public static void pause​(int time)
    • pause

      public static void pause​(float time)
    • log

      public static void log​(String msg, Object... args)
    • logOn

      public static void logOn()
    • logOff

      public static void logOff()
    • reset

      public void reset()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toStringShort

      public String toStringShort()
    • getApps

      public static List<App> getApps()
    • getApps

      public static List<App> getApps​(String name)
    • listApps

      public static void listApps()
    • listApps

      public static void listApps​(String name)
    • getToken

      public String getToken()
    • setToken

      public void setToken​(String appToken)
    • setUsing

      public App setUsing​(String options)
    • setNameGiven

      public void setNameGiven​(String nameGiven)
    • getNameGiven

      public String getNameGiven()
    • getOptions

      public String getOptions()
    • getName

      public String getName()
    • setName

      public void setName​(String name)
    • getExec

      public String getExec()
    • setExec

      public void setExec​(String exec)
    • getTitle

      public String getTitle()
    • getTitle

      public String getTitle​(int windowNumber)
    • getWindowTitle

      public String getWindowTitle()
    • setWindow

      public void setWindow​(String appWindow)
    • setPID

      public void setPID​(int appPID)
    • setPID

      public void setPID​(String appPID)
    • getPID

      public int getPID()
    • setWorkDir

      public boolean setWorkDir()
    • setWorkDir

      public boolean setWorkDir​(String workDirPath)
    • getWorkDir

      public String getWorkDir()
    • isValid

      public boolean isValid()
    • isRunning

      public boolean isRunning()
    • isRunning

      public boolean isRunning​(int maxTime)
    • hasWindow

      public boolean hasWindow()
    • open

      public static App open​(String appName, int waitTime)
      tries to open an app using the given name and waits waitTime for being ready If the app is already open, it is brought to foreground
      Parameters:
      appName - name - something that could be used on commandline to start the app
      waitTime - to wait for app to open (secs)
      Returns:
      the App instance
    • open

      public static App open​(String appName)
      tries to open an app using the given name and waits 1 sec for being ready If the app is already open, it is brought to foreground
      Parameters:
      appName - name - something that could be used on commandline to start the app
      Returns:
      the App instance
    • open

      public boolean open()
      tries to open the app defined by this App instance
      do not wait for the app to get running
      Returns:
      this or null on failure
    • open

      public boolean open​(int waitTime)
      tries to open the app defined by this App instance
      and waits until app is running
      Parameters:
      waitTime - max waittime until running
      Returns:
      this or null on failure
    • close

      public static boolean close​(String appName)
      tries to identify a running app with the given name and then tries to close it
      Parameters:
      appName - name
      Returns:
      0 for success -1 otherwise
    • isClosing

      public boolean isClosing()
    • close

      public boolean close()
      tries to close the app defined by this App instance, waits max 10 seconds for the app to no longer be running
      Returns:
      this or null on failure
    • close

      public boolean close​(int waitTime)
      tries to close the app defined by this App instance, waits max given seconds for the app to no longer be running
      Parameters:
      waitTime - to wait for app to close (secs)
      Returns:
      this or null on failure
    • closeByKey

      public int closeByKey()
    • closeByKey

      public int closeByKey​(int waitTime)
    • setFocused

      public void setFocused​(boolean state)
    • hasFocus

      public boolean hasFocus()
    • focus

      public static App focus​(String title)
      tries to identify a running app with name or (part of) window title bringing its topmost window to front
      Parameters:
      title - name
      Returns:
      an App instance - is invalid and not useable if not found as running
    • focus

      public static App focus​(String title, int index)
      tries to identify a running app with name or (part of) window title bringing its window with given index to front
      Parameters:
      index - of the window among the found windows
      title - name
      Returns:
      an App instance - is invalid and not useable if not found as running
    • focus

      public boolean focus()
      tries to make it the foreground application bringing its frontmost window to front
      Returns:
      the App instance
    • window

      public Region window()
      evaluates the region currently occupied by the topmost window of this App instance. The region might not be fully visible, not visible at all or invalid with respect to the current monitor configuration (outside any screen)
      Returns:
      the region
    • window

      public Region window​(int winNum)
      evaluates the region currently occupied by the window with the given number of this App instance. The region might not be fully visible, not visible at all or invalid with respect to the current monitor configuration (outside any screen)
      Parameters:
      winNum - window
      Returns:
      the region
    • focusedWindow

      public static Region focusedWindow()
      evaluates the region currently occupied by the systemwide frontmost window (usually the one that has focus for mouse and keyboard actions)
      Returns:
      the region
    • getWindows

      public List<Region> getWindows()
    • run

      public static int run​(String cmd)
      the given text is parsed into a String[] suitable for issuing a Runtime.getRuntime().exec(args). quoting is preserved/obeyed. the first item must be an executable valid for the running system.
      After completion, the following information is available:
      App.lastRunResult: a string containing the complete result according to the docs of the run() command
      App.lastRunStdout: a string containing only the output lines that went to stdout
      App.lastRunStderr: a string containing only the output lines that went to stderr
      App.lastRunReturnCode: the value, that is returnd as returncode
      Parameters:
      cmd - the command to run starting with an executable item
      Returns:
      the final returncode of the command execution
    • getClipboard

      public static String getClipboard()
      evaluates the current textual content of the system clipboard
      Returns:
      the textual content or empty string if not possible
    • setClipboard

      public static void setClipboard​(String text)
      sets the current textual content of the system clipboard to the given text
      Parameters:
      text - text