스크립트를 백그라운드에서 실행하고 CTRL + 1과 같은 바로 가기 키를 누르면 현재 활성 텍스트 필드에 변수의 내용을 "붙여 넣기"합니다. 지금까지 가지고있는 코드 :powershell 스크립트 기능에 바로 가기 키 지정
function Send($key)
{
$wsh.SendKeys($key)
}
$wsh = New-Object -ComObject WScript.Shell
$c1 = "Text to be sent #1"
$c2 = "Text to be sent #2"
$c3 = "Text to be sent #3"
$c4 = "Text to be sent #4"
$c0 = "Text to be sent #5"
switch ($check)
{
1 {Send($c1)}
2 {Send($c2)}
3 {Send($c3)}
4 {Send($c4)}
0 {Send($c0)}
default {Sleep(1)}
}
검색해 보았는데 아무런 해결책이 없습니다. 필자는 similair 기능을 가진 AutoIt 스크립트를 사용하고 있습니다. 필자는이 글을 쓰지 않았지만 불행히도 저자를 모릅니다.
#include <Misc.au3>
Func _SendEx($ss, $warn = "")
Local $iT = TimerInit()
While _IsPressed("10") Or _IsPressed("11") Or _IsPressed("12")
If $warn <> "" And TimerDiff($iT) > 1000 Then
MsgBox(262144, "Avertissement", $warn)
EndIf
Sleep(50)
WEnd
Send($ss)
EndFunc;==>_SendEx
HotKeySet ("^1", "c1")
HotKeySet ("^2", "c2")
HotKeySet ("^3", "c3")
HotKeySet ("^4", "c4")
HotKeySet ("^0", "c0")
While True
Sleep (10000)
WEnd
Func c1()
_SendEx ("text 1")
EndFunc
Func c2()
_SendEx ("text 2")
EndFunc
Func c3()
_SendEx ("text 3")
EndFunc
Func c4()
_SendEx ("text 4")
EndFunc
Func c0()
_SendEx ("text 0")
EndFunc
저는이 기능을 단축키로 지정하는 방법을 powershell에서 재현하고 싶습니다.