Script to surround selection with: %b

Discussion, questions and support.
Post Reply
User avatar
michaelbeijer
Posts: 14
Joined: Jan 31st, ’16, 17:51

Post by michaelbeijer » Jan 31st, ’16, 17:56

Does anyone know how I can get this script to work for surrounding any selection with the following text: %b

This works:

Code: Select all

#!b::		; surround selection with HTML bold codes <b> ... </b>
Send ^c
Sleep 100
clipboard = <b>%clipboard%</b>
Send ^v
return
But this does not:

Code: Select all

#!b::		; surround selection with HTML bold codes %b ... %b
Send ^c
Sleep 100
clipboard = [b]%b[/b]%clipboard%[b]%b[/b]
Send ^v
return
Basically, I want to be able to select a word, say "cat", click my shortcut and have it produce %bcat%b

Any help would be greatly appreciated!

Michael
​Michael Beijer
Dutch-English technical translator
Hastings, United Kingdom
Tel.: 447475771720
Email: [email protected]
Websites: https://beijer.uk/ & https://termhotel.com/
User avatar
Tom
Posts: 796
Joined: Nov 24th, ’15, 23:39

Post by Tom » Jan 31st, ’16, 18:08

Code: Select all

Send ^c
Sleep 100
clipboard := "%b" clipboard "%b"
; clipboard = `%b%clipboard%`%b  ;alternative
Send ^v
User avatar
michaelbeijer
Posts: 14
Joined: Jan 31st, ’16, 17:51

Post by michaelbeijer » Jan 31st, ’16, 18:13

Wow, that was fast. Thanks Tom, it works perfectly!

I recently discovered FastKeys, and am currently in the process of moving all of my loose AHK scripts into FastKeys for easier management, so I expect to ask quite a few questions here in the form in the coming weeks!

Michael
​Michael Beijer
Dutch-English technical translator
Hastings, United Kingdom
Tel.: 447475771720
Email: [email protected]
Websites: https://beijer.uk/ & https://termhotel.com/
Post Reply