We have talk about how to use the basic click function in previous blog,
but sometimes we also want to achieve a long press or such as sliding behavior,
so in this section, let’s talk about the functions related to pressing! =͟͟͞͞( •̀д•́)

Functions

In Blackey Script, the commands related to touch events are listed as below:

Function Description
press(position) Press at a given position
move(position) Move to a given position
release(position) Leave at a given position
wheel(direction, position) Simulate wheel event at given position
direction = 0 means to wheel-up
direction = 1 means to wheel-down

Touch events

In Android, the Touch events are composed by Press => Move => … => Move => Leave
During sliding, the most events are Move event, and the moving distance is much longer.
While the click / long press event only takes few Move event.

In general speaking, these three instructions are rarely used directly to simulate the behavior of sliding,
Instead, use the record function (Rec. button) on the Editor Window to record the swipe action automatically.
Here is an example for “Screen Unlock”:

  1. Press Power Key (We will talk about the KeyCode in next chapter)
  2. Sliding the Unlock page. (By Press – Move – Release)
Android默認的長按時間是500 ms,如果不想用錄製的話也可以自行撰寫,稍微麻煩一些就是。

Once start recording, the mouse and keyboard event triggered in the Blackey MainWindow will be record into the Editor Window.
Remember to click the “Stop Rec.” once you finish recording.

You can still to modify the record script, just remember to calling release after calling press,
or your phone might thought my you are keep pressing on it.  (゚∀。)

Wheel events

The Wheel events will also be record.
The advantage to use recording is that you can pinpoint exactly where you want to scroll.

When wheel-up, the direction will record as 0; otherwise will record as 1.
Here is a record example about the Wheel events:

Wheel-down:

wheel(1, pos(0.635338, 0.544492));
msleep(102);
wheel(1, pos(0.635338, 0.544492));
msleep(221);
wheel(1, pos(0.635338, 0.544492));
msleep(1119);
wheel(1, pos(0.635338, 0.544492));

Wheel-up:

wheel(0, pos(0.635338, 0.544492));
wheel(0, pos(0.635338, 0.544492));
wheel(0, pos(0.635338, 0.544492));
msleep(1119);
wheel(0, pos(0.635338, 0.544492));