Using Autohotkey, Id like to concatenate the variable1, the clipboard contents, and variable2.
For example, if:
- variable1 =
https://example.com/somepage.php?command=details&reservationId=
- clipboard contents =
12345
- variable2 =
&url=%2Fsomepage.php%3submit%3DSEARCH%26submit
The expected result would be:
https://example.com/somepage.php?command=details&reservationId=12345&url=%2Fsomepage.php%3submit%3DSEARCH%26submit
The two methods shown below simply output 12345
What am I doing wrong?
Attempt 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
Attempt 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
Update (same results):
::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
Working Solution
This is how I finally got it working. However, Blauhirn's method in the selected answer is much simpler to use.
::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