使用Autohotkey,Id喜欢连接variable1,剪贴板内容和variable2。
例如,如果:
https://example.com/somepage.php?command=details&reservationId=
12345
&url=%2Fsomepage.php%3submit%3DSEARCH%26submit
预期结果将是:
https://example.com/somepage.php?command=details&reservationId=12345&url=%2Fsomepage.php%3submit%3DSEARCH%26submit
下面显示的两种方法只输出 12345
我做错了什么?
尝试1:
::hd-eurl::
ClipSaved := ClipboardAll ; get clipboard
variable1:= "https://example.com/somepage.php?command=details&reservationId="
variable2:= "&url=%2Fsomepage.php%3submit%3DSEARCH%26submit"
ClipNew = %variable1% . ClipSaved . %variable2%
clipboard = ClipNew
ClipWait
Send, ^v
clipboard := ClipSaved ; restore original clipboard
return
尝试2:
::hd-eurl::
Send ^c
ClipSaved := ClipboardAll ; get clipboard
variable1= https://example.com/somepage.php?command=details&reservationId=
variable2= &url=`%2Fsomepage.php`%3submit`%3DSEARCH`%26submit
ClipNew = variable1 . ClipSaved . variable2
clipboard = ClipNew
ClipWait
Send, ^v
clipboard := ClipSaved ; restore original clipboard
return
更新(结果相同):
::hd-eurl::
ClipSaved := ClipboardAll ; get clipboard
variable1:= "https://example.com/somepage.php?command=details&reservationId="
variable2:= "&url=%2Fsomepage.php%3submit%3DSEARCH%26submit"
ClipNew := variable1 . ClipSaved . variable2
clipboard := ClipNew
ClipWait
Send, ^v
clipboard := ClipSaved ; restore original clipboard
return
工作解决方案
这就是我最终让它发挥作用的方式。但是,Blauhirn在所选答案中的方法使用起来要简单得多。
::hd-eurl::
ClipSaved := ClipboardAll ; store clipboard backup
variable1:= "https://example.com/somepage.php?command=details&reservationId="
variable2= %ClipBoard%
ClipBoard =
variable3:= "&url=%2Fsomepage.php%3submit%3DSEARCH%26submit"
variable4:= variable1 . variable2 . variable3
Clipboard:= variable4
ClipWait
Send, ^v
Clipboard := ClipSaved ; restore original clipboard
return
答案 0 :(得分:2)
您的clipSaved
变量包含clipboardAll
。 Documentation说:
已分配ClipboardAll的变量采用二进制格式,因此在使用MsgBox或类似内容时显示为乱码。
分配到clipboard
时,您必须使用clipNew
,例如
ClipNew := variable1 . clipboard . variable2
除此之外,我建议你根本不修改clipboard
的内容,因为这是最复杂的方法。如果你想发送一些内容,只需使用字符串上的send command而不是调用 CTRL + V :
::hd-eurl::
variable1:= "https://example.com/somepage.php?command=details&reservationId="
variable2:= "&url=%2Fsomepage.php%3submit%3DSEARCH%26submit"
send % variable1 clipboard variable2
return
答案 1 :(得分:1)
正确的语法是
ClipNew := variable1 . ClipSaved . variable2
或
ClipNew = %variable1%%ClipSaved%%variable2%
也修改此行
clipboard := ClipNew