littledivy / autopilot-deno

:rocket: Cross-platform desktop automation module for Deno.
https://autopilot.mod.land
MIT License
492 stars 15 forks source link

Hotkey support #35

Closed 4ov closed 3 years ago

4ov commented 4 years ago

Is your feature request related to a problem? Please describe. I can't switch between two windows, switch language or doing anything using hotkeys.

Describe the solution you'd like add hotkey method like pyautogui hotkey('alt', 'tab').

littledivy commented 4 years ago

Yes I'm in favour of this 👍 - I'll play around some implementations. Feel free to open a PR

littledivy commented 4 years ago

You can also do something like -

await pilot.toggleKey("alt", true);
await pilot.toggleKey("tab", true);

await pilot.toggleKey("alt", false);
await pilot.toggleKey("tab", false);

Let me know if it works for you, it'll be nice to have a wrapper method around toggleKey

gadzan commented 3 years ago

May I know how to operate hot key like "Ctrl + C" ?

littledivy commented 3 years ago
await pilot.toggleKey("ctrl", true);
await pilot.toggleKey("c", true);

await pilot.toggleKey("ctrl", false);
await pilot.toggleKey("c", false);
littledivy commented 3 years ago

Closing, the above example should be used.

nnmrts commented 2 years ago

@littledivy await pilot.toggleKey("c", false); is not possible currently, because only specific keys are allowed with toggleKey.