求教 Topic is solved

遇到了问题?请先进行搜索(中文和英文),然后在此提问

Moderators: arcticir, tmplinshi

Ryan

求教  Topic is solved

Post by Ryan » 13 May 2020, 03:39

请教各位大佬,怎样实现逐个击键来触发呢?例如按下A,松开,再按下B,才触发;或者^A松开,再按下B,才触发。

例如下面这个脚本,目的是选中文字后,按下前置快捷键,松开,再按不同的数字,来实现大写或者小写。

但是不能运行,请问有写对吗?

Code: Select all

~CapsLock & C::
#If (A_PRIORHOTKEY = "~CapsLock & C" AND A_TIMESINCEPRIORHOTKEY < 2000)
{
    :*:1::
    :*:2::
    :*:3::
        case_convert() {
            hs := A_ThisHotkey
            Clipboard = 
            Send ^C
            ClipWait
            if (hs == ":*:1") {
                StringUpper, Clipboard, Clipboard
            }
            else if (hs == ":*:2") {
                StringLower, Clipboard, Clipboard
            }
            else if (hs == ":*:3") {
                StringUpper, Clipboard, Clipboard, T
            }
            Send ^V
        }
    Return
}
#If

garry
Posts: 2412
Joined: 22 Dec 2013, 12:50

Re: 求教

Post by garry » 14 May 2020, 04:31

send2notepad

Code: Select all

;- example : use CAPSLOCK+C and then use in 2 second > 1 or 2 or 3 
#persistent
clipboard=
pr=notepad.exe
sc=ahk_exe notepad.exe
IfWinNotExist,%sc%
  Run, %pr%,,,pid1    ;- at first run open notepad
return
;-------------------------------
esc::exitapp  ; exit this script
;-----------------------------
;~Space::
~CapsLock & C::
;#If (A_PriorHotkey="~Space" && A_TimeSincePriorHotkey<2000)  ;- test with space
#If (A_PRIORHOTKEY = "~CapsLock & C" AND A_TIMESINCEPRIORHOTKEY < 2000)
{
Return
~1::
~2::
~3::
hs := SubStr(A_ThisHotKey, 2)
            Clipboard = 
            Send,^c
            ClipWait,2,1
            if (hs="1") {
                StringUpper, Clipboard, Clipboard
            }
            else if (hs="2") {
                StringLower, Clipboard, Clipboard
            }
            else if (hs="3") {
                StringUpper, Clipboard, Clipboard, T
            }
;msgbox, 262208, ,%clipboard%,2
 IfWinNotActive ,%sc%,,WinActivate,%sc%
    WinWaitActive,%sc%
 sleep,200
 ;ControlSend,,{text}%clipboard%`n,%sc%                ;- example : instead of ^v controlsend to notepad
 send,^v`n                                           ;- paste
sleep,500
clipboard=
return
}
#if
return

Post Reply

Return to “请求帮助”