自动热键设置不起作用 [英] Autoit hotkeyset not working

查看:76
本文介绍了自动热键设置不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试制作一种简单的剪贴板控制器,在该控制器中,用户可以在使用热键(Ctrl + Shift + Q)时将多个项目复制到剪贴板,而不是在使用Ctrl + C时仅复制一个项目,并能够一次全部粘贴(Ctrl + Shift + W)或直接粘贴前10个项目中的任何一项(Ctrl + Shift + 1 ... 9),另一种选择是清除剪贴板(Ctrl + Shift +'-').

I'm trying to make some kind of simple clipboard controller , where the user could have several items copied to the clipboard when using a hotkey (Ctrl+Shift+Q) , instead of only one item when using Ctrl+C , and would be able to paste them all at once (Ctrl+Shift+W) , or paste any of the first 10 items directly (Ctrl+Shift+1...9), another option is to clear the clipboard (Ctrl+Shift+'-').

问题在于,它仅适用于几个复制和粘贴,但随后尝试进行复制操作时,什么也没有添加到缓冲区.我正在尝试找出原因,但找不到原因.

The problem is that it works fine just for several copy and pastes , but then trying to make a copy operation nothing is added to the buffer.. I'm trying to figure it out , but couldn't find a reason for this..

这是代码:

注意:问题应该出在我认为的addToClipboard()或getAll()

Note : the problem should be in the addToClipboard() or getAll() I believe

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <array.au3>


Global $clipBoard[50]=[""]
Global $counter = 0

HotKeySet("^+q","addToClipboard")
HotKeySet("^+-","emptyAll")
HotKeySet("^+w","getAll")
HotKeySet("^+1","get1")
HotKeySet("^+2","get2")
HotKeySet("^+3","get3")
HotKeySet("^+4","get4")
HotKeySet("^+5","get5")
HotKeySet("^+6","get6")
HotKeySet("^+7","get7")
HotKeySet("^+8","get8")
HotKeySet("^+9","get9")

$hGUI = GuiCreate("Clipboard Controller", 100, 100,Default,Default,$WS_SIZEBOX)
GUISetState()

Func addToClipboard()
    Send ("^c")
        $copied = ClipGet()
    $clipBoard[Mod($counter,50)] = $copied
    $counter +=1
EndFunc

Func getByIndex($i)

    $statement = $clipBoard[$i]
    ClipPut($statement)
    Send("^v")
EndFunc

Func getAll()

    $statement =""
    For $i In $clipBoard
            If $i <> "" Then
        $statement &= $i & @CRLF
        EndIf
    Next
    ClipPut($statement)
    Send("^v")
    EndFunc

Func emptyAll()

For $i=0 To 49
    $clipBoard[$i]=""
Next
ClipPut("")
EndFunc


Func get1()
getByIndex(0)
EndFunc

Func get2()
getByIndex(1)
EndFunc

Func get3()
getByIndex(2)
EndFunc

Func get4()
getByIndex(3)
EndFunc

Func get5()
getByIndex(4)
EndFunc

Func get6()
getByIndex(5)
EndFunc

Func get7()
getByIndex(6)
EndFunc

Func get8()
getByIndex(7)
EndFunc

Func get9()
getByIndex(8)
EndFunc

While 1
Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE
        Exit
    EndSwitch
WEnd

推荐答案

问题是一个古老的陷阱...

Problem is an old trap...

复制到剪贴板需要花费少量时间特别大的项目.发送后尝试入睡

It takes a small amount of time to copy to the clip board especially large items..try a sleep after the Send

Func addToClipboard()
Send ("^c")
sleep(1000) ; try different values
    $copied = ClipGet()
$clipBoard[Mod($counter,50)] = $copied
$counter +=1
EndFunc

无论如何,就像您的脚本..idea

anyway like your script..idea

这篇关于自动热键设置不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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