如何发送“Ctrl” c”在西库利?

发布于 2024-11-15 09:55:57 字数 198 浏览 2 评论 0原文

这感觉应该很简单,但我找不到有关如何执行此操作的文档:

我只希望 Sikuli 键入 Ctrl+C 将文本复制到剪贴板。

type(KEY_CTRL+'c') 不起作用,type(KEY_CTRL,'c') 也不起作用。

有什么建议吗?

This feels like it should be pretty easy but I can't find documentation on how to do this:

I just want Sikuli to type Ctrl+C to copy text to the clipboard.

type(KEY_CTRL+'c') doesn't work and neither does type(KEY_CTRL,'c').

Any suggestions?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(10

挽梦忆笙歌 2024-11-22 09:55:57

尝试使用 type("c",KEY_CTRL) 代替。

我编写了一个简单的脚本,在记事本中键入一行,双击它进行标记,然后再次按 ctrl+x ctrl+v 将其放入文档中。效果很好。

openApp("notepad.exe")

find("textfield.png" )
type("Some text")
doubleClick("theText.png")

type("x", KEY_CTRL)

click("theTextField.png" )
type("v",KEY_CTRL)

Try using type("c",KEY_CTRL) instead.

I wrote a simple script which types a line in notepad, double clicks it to mark it and then ctrl+x ctrl+v it into the document again. Works great.

openApp("notepad.exe")

find("textfield.png" )
type("Some text")
doubleClick("theText.png")

type("x", KEY_CTRL)

click("theTextField.png" )
type("v",KEY_CTRL)
拧巴小姐 2024-11-22 09:55:57

以下内容适用于 0.9 及更高版本的

type('x', KeyModifier.CTRL)

The following works in 0.9 and newer versions of

type('x', KeyModifier.CTRL)
七秒鱼° 2024-11-22 09:55:57

几乎所有修饰键和数字键盘键都定义了按键对象。无论如何,它应该看起来像这样

keyDown(Key.CTRL)
类型('c')
keyUp(Key.CTRL)

Key objects are defined for pretty much all the modifier keys and num pad keys. Anyways, it should look something like this

keyDown(Key.CTRL)
type('c')
keyUp(Key.CTRL)

喵星人汪星人 2024-11-22 09:55:57

正如其他人提到的,使用以下内容:

type('c', Key.CTRL) # Copy command

值得一提的一点 - 不要使用大写字符,即:

type('C', Key.CTRL) # Does not copy, avoid this

我还没有研究过 Sikuli 源代码,但我最好的猜测是它隐式地将其作为 Shift+C 发送,这会产生完全不同的命令。

As others have mentioned, use the following:

type('c', Key.CTRL) # Copy command

One point worth mentioning - do not use upper-case characters, i.e.:

type('C', Key.CTRL) # Does not copy, avoid this

I haven't looked into the Sikuli source code, but my best guess is that it implicitly sends this as Shift+C, which results in a different command entirely.

冷情 2024-11-22 09:55:57

type('x', Key.CTRL) 也有效。

type('x', Key.CTRL) also works.

人疚 2024-11-22 09:55:57

另外,请确保 NUM_LOCK 已关闭。如果 NUM_LOCK 处于打开状态,则可能会使 KeyModifier.CTRL 或 KeyModifier.SHIFT 的任何内容出现异常行为。

Also, make sure that NUM_LOCK is off. If NUM_LOCK is on, it can make anything with KeyModifier.CTRL or KeyModifier.SHIFT misbehave.

剧终人散尽 2024-11-22 09:55:57

您可以尝试下一个代码:

keyDown(Key.CTRL)
type("c")
keyUp(Key.CTRL)

You can try next code:

keyDown(Key.CTRL)
type("c")
keyUp(Key.CTRL)
画▽骨i 2024-11-22 09:55:57

我需要自动化 Flash 内容。以下代码对我有用。
作为自动化的一部分,我需要执行以下步骤:

  1. 输入用户名和密码
  2. 单击登录按钮
  3. 单击将导航到应用程序的按钮

我面临的挑战是关注没有占位符的用户名和密码。因此对焦很困难。所以我使用 CTRL 键来执行此操作。

    Pattern appLogo = new Pattern("C:\\images\\appLogo.png");
    StringSelection userNameText = new StringSelection("username");              
   Toolkit.getDefaultToolkit().getSystemClipboard().setContents(userNameText, null);//Copy the text into the memory   
        Screen s = new Screen(); 
            s.find(appLogo);
            s.click(appLogo);
            s.type(Key.TAB);//I had to enter tab twice to focus on user name textbox
            s.type(Key.TAB);
            s.type("V",KeyModifier.CTRL);

            StringSelection password = new StringSelection("password");               
            Toolkit.getDefaultToolkit().getSystemClipboard().setContents(password, null);
            s.type(Key.TAB);//I had to enter tab twice to focus on user name textbox
            s.type("V",KeyModifier.CTRL);

            Pattern loginButton =  new Pattern("C:\\images\\Login.png");
            s.find(loginButton);
            s.doubleClick(loginButton);

I had a requirement to automate a flash content. The following code worked for me.
These were the following steps I ahd to perform as a part of the automation:

  1. Enter Username and Password
  2. Click on Login Button
  3. Click on the button which will navigate to the application

The challenge I faced was to focus on the Username and password which had no placeholders . Hence the focusing was difficult. So I used the CTRL keys to do this .

    Pattern appLogo = new Pattern("C:\\images\\appLogo.png");
    StringSelection userNameText = new StringSelection("username");              
   Toolkit.getDefaultToolkit().getSystemClipboard().setContents(userNameText, null);//Copy the text into the memory   
        Screen s = new Screen(); 
            s.find(appLogo);
            s.click(appLogo);
            s.type(Key.TAB);//I had to enter tab twice to focus on user name textbox
            s.type(Key.TAB);
            s.type("V",KeyModifier.CTRL);

            StringSelection password = new StringSelection("password");               
            Toolkit.getDefaultToolkit().getSystemClipboard().setContents(password, null);
            s.type(Key.TAB);//I had to enter tab twice to focus on user name textbox
            s.type("V",KeyModifier.CTRL);

            Pattern loginButton =  new Pattern("C:\\images\\Login.png");
            s.find(loginButton);
            s.doubleClick(loginButton);
£噩梦荏苒 2024-11-22 09:55:57

这种情况就像我需要在完成测试后按键盘上的 E 键,如何将其添加到 Sikuli IDE 的脚本中。

The scenario is like i need to press say key E in my keyboard after finishing the test how to add this in the script in Sikuli IDE.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文