【发布时间】:2015-01-26 14:48:13
【问题描述】:
当我按下 Ctrl + 1、Ctrl + 2 等时,我的 AutoIt 脚本会粘贴字符串。
Func copyPasta1()
Send($texts[1], 1)
EndFunc
Func copyPasta2()
Send($texts[2], 1)
EndFunc
...
HotKeySet("^" & $keys_arr[2], "copyPasta" & ($i - 1))
有时 Ctrl 键会被锁定,因此整个系统的行为就像我连续按下 Ctrl 一样。按 Ctrl 即可解决。
我尝试改用 Shift,但随后 Shift 被锁定。有人对此有解决方案吗?我的脚本:
#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
#include <FileConstants.au3>
#include <Array.au3>
#include <Math.au3>
HotKeySet("^q", "end")
Func end()
SplashTextOn("", "Programm wird beendet", 200, 40, -1, -1, 1, "", 10, 600)
Sleep(1000)
SplashOff()
Exit
EndFunc
Func copyPasta1()
Send($texts[1], 1)
EndFunc
Func copyPasta2()
Send($texts[2], 1)
EndFunc
Func copyPasta3()
Send($texts[3], 1)
EndFunc
Func copyPasta4()
Send($texts[4], 1)
EndFunc
Func copyPasta5()
Send($texts[5], 1)
EndFunc
Func copyPasta6()
Send($texts[6], 1)
EndFunc
Func copyPasta7()
Send($texts[7], 1)
EndFunc
Func copyPasta8()
Send($texts[8], 1)
EndFunc
Func copyPasta9()
Send($texts[9], 1)
EndFunc
; read config File
Local $hFileOpen = FileOpen(@WorkingDir & "\config.cfg", $FO_READ)
If $hFileOpen = -1 Then
MsgBox(1, "", "Keine config Datei gefunden.")
Exit
EndIf
Global $texts[12]
$sFileRead = FileRead($hFileOpen)
FileClose($hFileOpen)
$arr1 = StringSplit($sFileRead, "#TASTE:", 1)
For $i = 2 To _Min($arr1[0], 10)
$arr2 = StringSplit($arr1[$i], "#SATZ:", 1)
If $arr2[0] == 2 Then
$keys_arr = StringSplit($arr2[1], '"', 1)
$texts_arr = StringSplit($arr2[2], '"', 1)
If $keys_arr[0] == 3 And $texts_arr[0] == 3 Then
HotKeySet("^" & $keys_arr[2], "copyPasta" & ($i - 1))
$texts[$i - 1] = $texts_arr[2]
EndIf
EndIf
Next
SplashTextOn("", "Programm gestartet", 200, 40, -1, -1, 1, "", 10, 600)
Sleep(1000)
SplashOff()
While 1
Sleep(1000)
WEnd
Exit
【问题讨论】:
-
发送 Send("{CAPSLOCK off}") 作为第二个命令怎么样?
-
@Xenobiologist 没有帮助。大写锁定未激活,它与 shift 键完全一样,将被永久按下,但没有大写锁定。
-
检查以确保您没有在控制面板项目 > 轻松访问中心 > 使键盘更易于使用下打开粘滞键