Skip to content

Testing PC games on the Windows platform

Please refer to this link for how to use Airtest IDE in general.

Please refer to this link for detailed API Documentation.

Airtest already supports testing applications on the Windows platform, but when it comes to PC games that requrie DirectInput devices, the methods we provided before cannot simulate keyboard/mouse events effectively. Therefore, we have added several new APIs to help manage testing those PC games.

  1. key_press(key), key_release(key)

    Some PC games using DirectInput devices respond only to keyboard scancodes, not virtual key codes sent by the keyevent() method that Airtest uses. We have provided new APIs to help resolve this issue. key_press(key) and key_release(key), which send keyboard scancodes, simulate key press and key release events, respectively. We have separated a key event into a key press event and a key release event so that users can perform other actions in between these two commands, which can be more accurate than passing a duration parameter to keyevent().

    Below is an example of how to use these two methods: win = device() win.key_press('W') ...// some operations win.key_release('W') Please refer to our documentation to see available key options supported by these two methods.


  2. mouse_move(pos), mouse_down(button), and mouse_up(button)

    In some 3D games, players move the mouse to control the camera and press the left mouse button to perfrom actions like shooting. We have encapsulated some logics bebind our previously-used APIs into three new methods, mouse_move(pos), mouse_down(button), and mouse_up(button). Please refer to our documentation for further details.

    Note that in some games the exact value of the pos paramter in mouse_move(pos) can be rather strict, e.g., in a first person shooting game. Users might need to determine the value of this parameter through constant testing.

    Similarly, users need to acquire the device before using methods to simulate mouse events. ``` import win32api

    win = device() x, y = win32api.GetCursorPos() win.mouse_move((x+10, y+10)) win.mouse_down('right') ... // some operations win.mouse_up('right') ```


  1. Users might encounter problems when using Airtest IDE to connect to the game window. You can choose to use either the unembedded mode or the desktop mode to get around the problem.

    To use the unembedded mode, check the corresponding check box under Settings.



    To use the desktop mode, click on the right-most button under "Connection".


  2. Under the desktop mode, it is highly likely that when executing a script, Airtest IDE finds a matched image in the script itself, not in the game. To get around this issue, you can right-click in the script editor and toggle between the image mode and the code mode.


  3. When writing scripts, users might have problems moving the cursor out of the game window. You can hold down the Alt key and press the Tab key to toggle between windows.