简体   繁体   English

使用 JavaScript 即时输入键盘

[英]Instantly type in keyboard using JavaScript

I'm currently developing a RPA application.我目前正在开发 RPA 应用程序。 I need to type a text in keyboard, but I need this process to be executed instantly (as if it were a copy and paste).我需要在键盘上键入文本,但我需要立即执行此过程(就像复制和粘贴一样)。

I've tried Nut.js and Robotjs but both of these have a delay between one key and another even if I configure the delay to 0ms or 1ms.我已经尝试过 Nut.js 和 Robotjs,但即使我将延迟配置为 0 毫秒或 1 毫秒,这两者在一个键和另一个键之间都有延迟。

Someone know another automation library to make this process of typing immediate?有人知道另一个自动化库可以使这个输入过程立即进行吗? Or should I try Python?或者我应该试试 Python?

You could use the pyperclip library to first copy text using the pyperclip.copy() function and then use PyAutoGui library to paste the text.您可以使用pyperclip库首先使用pyperclip.copy() function 复制文本,然后使用PyAutoGui库粘贴文本。 The pyperclip doesn't have a built-in function to paste but using both of these we can make it work. pyperclip 没有内置的 function 可以粘贴,但是使用这两个我们可以让它工作。

Example:例子:

import pyperclip
import pyautogui

#copy text to clipboard
text = "Testing the copy and paste"
pyperclip.copy(text)

#paste text from clipboard
pyautogui.hotkey('ctrl', 'v')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM