Skip to main content

SDK Quick Installation

Node.js, Python, and C# users can directly install via package managers without manually implementing clients:
  • Node.js: npm install iclick-auto
  • Python: pip install iclick-auto
  • C#: Install-Package iclick-auto
All these packages implement API calls, event listening, and MetaData binary stream parsing. Other Languages The following code examples may not be fully verified and are for reference and learning purposes only. Please ensure thorough testing and validation before using in production environments.

NodeJS Sample Script

How to find clicked UI controls

No-jailbreak scripts can locate controls using image search, color search, and OCR. The iClick console has built-in various color picker, image picker, and OCR development tools. The script example below demonstrates how to locate the browser on the desktop and access phones.farm.
In traditional Android RPA programming, getting the current activity is a crucial function. It’s used to determine which app or page the device is currently in. However, in jailbreak-free systems, there are no UI node manipulation methods, so naturally, there’s no getActivity function. In iOS instant-cast automation programming, simulating getActivity is essential. It provides the script with nearly 99% fault tolerance and can easily resolve annoying pop-up interference from some apps. Let’s take a simplified version of the video posting script from a certain short video platform as an example.
  • Find the TK icon on your desktop and click to enter.
  • Use saveMediaFile to transfer videos from your computer to your phone
  • Wait for the page to load and click the publish button.
  • Waiting for the album button to be clicked
  • Select the file and proceed to the next step.
  • Use sendText to input and submit content
  • Wait for the video to finish publishing and then exit the script.
The above process might only require a few dozen lines of code to implement, but the problem isn’t that simple. First, starting from opening the app, aside from the initial authorization pop-up for the photo album and microphone (which only appears once), there are about 10 other business-related pop-ups (with a 30% probability of appearing, and each appearing on a different page). Each of these pop-ups is modal, which will hinder your next action. Simulating getActivity would perfectly solve this problem.

How to simulate getActivity to resolve pop-up windows?

The significance of simulating getActivity is that the page is determined first, and then the operation is performed. Let’s take the TK example above as an example and put it into practice.
The code above simulated getActivity and solved the pop-up issue. Now we’ll write the “posting script” code.
The code above is for reference only; many dependency codes have been removed due to space limitations. Referring to the getActivity code above and the actual “post content” script code, it first determines the current page and resolves pop-ups before each operation. Based on this code model, even on older devices like the iPhone 6 where occasional app crashes due to device lag won’t affect the task’s operation and it can continue to run.

Practical role of OCR in automation

OCR is generally used in conjunction with image and color recognition in scenarios where specific logic needs to be distinguished before performing operations. It returns the text and coordinates of a specified area. iClick’s default OCR uses the device’s GPU for recognition, which does not consume host machine performance. However, it is unavailable or unsuitable in some scenarios. For scenarios requiring the use of PaddleOcr, the iClick console integrates a one-click PaddleOcr installation function, which can be found in iClick -> Settings -> Development.