SendEvent ^ {ins}不会将内容复制到剪贴板 [英] SendEvent ^{ins} isn't copying content to the clipboard

查看:73
本文介绍了SendEvent ^ {ins}不会将内容复制到剪贴板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

!c::
    file_name = footnote.ini                             
    restore_original_clipBoard := clipboard
    clipboard =
    KeyWait, Alt                
    KeyWait, c                                           ;small c
    BlockInput, on
    SendEvent, ^{ins}                                   ;^c doesn't work
    ClipWait, 2                                     ; Wait for the clipboard to contain text.
    if ErrorLevel
    {
        MsgBox Failed to save the selection: %clipboard%
        exit
    }
    BlockInput, off
    save_selection := clipboard 

问题::尽管做出了选择,但Sendevent ^ {ins}并未将其保存到剪贴板.有时,在将选择内容复制到剪贴板之前,我必须重复几次热键alt + c. KeyWait应该确保我只处理^ {ins},而没有任何其他键.我在这里做什么错了?


更新 我试图强制将选择内容复制到剪贴板的一种方法是使用while循环.我在帖子中找到了它:

无限循环将^ {ins}的连续重发合并在其内部.由于某些原因,我的选择未被识别为选择.虽然它处于无限循环中,但我尝试重新选择文本.然后,它立即识别出它,并将我的选择复制到剪贴板.可惜!由于选择如此之快,因此选择不完整. 这个问题并不总是那样.有时,它会优先识别选择!因此,有时它会将我的选择复制到剪贴板中.如果没有,则重新发送^ {ins}似乎不起作用.我不想让用户重新选择他的选择.那有可能吗?

根据我的经验,每当无法可靠地识别击键时,都是由于系统或目标程序无法跟上这些击键的发送速度./p>

对于SendEvent,您可以尝试类似SetKeyDelay, 1000, 1000的操作,看看是否可以改善.另一种选择是按照间歇性睡眠调用发送明确的上下键,如此答案所述.

!c::
    file_name = footnote.ini                             
    restore_original_clipBoard := clipboard
    clipboard =
    KeyWait, Alt                
    KeyWait, c                                           ;small c
    BlockInput, on
    SendEvent, ^{ins}                                   ;^c doesn't work
    ClipWait, 2                                     ; Wait for the clipboard to contain text.
    if ErrorLevel
    {
        MsgBox Failed to save the selection: %clipboard%
        exit
    }
    BlockInput, off
    save_selection := clipboard 

Problem: Despite a selection being made, Sendevent ^{ins} does not save it to the clipboard. Sometimes I have to repeat my hotkey, alt + c several times before the selection is being copied to the clipboard. The KeyWait should ensure me that only ^{ins} is being processed without any additional keys. What am I doing wrong here?


UPDATE One of the ways I tried to force copy a selection to the clipboard was by using a while loop. I got it to work through the post: Looping clipboard and errorlevel evaluation not working as expected

PROBLEM When I make a selection and press alt + c it sometimes gets stuck in the infinite loop that I implemented. But as you can see from that code:

clipboard := ""
while( StrLen(clipboard) < 1 )
{
    Send, ^{ins}
    Sleep, 50
}
MsgBox % ClipBoard

The infinite loop incorporates within itself a continues resending of ^{ins}. For some reason, my selection is not being recognized as a selection. Whilst it is in that infinite loop, I try to reselect the text. It then recognizes it instantly and copies my selection to the clipboard. But alas! The selection is incomplete because it goes so quick. This problem is not always like that. Sometimes it recognizes the selection first spot on! So sometimes it copies my selection to my clipboard sometimes not. When it does not, then a resending of a ^{ins} does not seem to work. I do not want to the user to reselect his selection. Is that possible to do?

解决方案

From my experience whenever keystrokes are not recognized reliably it's due to either the system or the targeted program not keeping up with the speed at which those keys are sent.

For SendEvent you could try something like SetKeyDelay, 1000, 1000 and see if this improves things. The other option would be to send explicit down and up keys with intermittent sleep calls as outlined in this answer.

这篇关于SendEvent ^ {ins}不会将内容复制到剪贴板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆