Adding html around clipboard, and position cursor

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
shortbeard
Posts: 1
Joined: 17 Oct 2018, 15:01

Adding html around clipboard, and position cursor

17 Oct 2018, 15:44

hey guys I'm trying to recreate some scripts I made on my mac, & I was hoping someone could give me a hand.
my scripts went something like this (kind of in AHK format...

Code: Select all

:c*:--sc::"<span class=' " . %cursor% . "  '>"  . %clipboard% . "<span>"
and I have lots of variants to that with divs, and other html elements etc...
I just want the current item on the clipboard, as I select it and cut it, to be wrapped in that element
User avatar
TheDewd
Posts: 1510
Joined: 19 Dec 2013, 11:16
Location: USA

Re: Adding html around clipboard, and position cursor

17 Oct 2018, 16:02

Code: Select all

#SingleInstance, Force

Cursor := "Something"

SpanText := "<span class=""" Cursor """>" Clipboard "<span>"

:c*:--sc::
	SendInput, % SpanText
return
I guess I don't understand about the position, but this is how you insert variables into a string using AutoHotkey.
Last edited by TheDewd on 17 Oct 2018, 16:14, edited 1 time in total.
list
Posts: 222
Joined: 26 Mar 2014, 14:03
Contact:

Re: Adding html around clipboard, and position cursor

17 Oct 2018, 16:04

Why would you manually cut it? You can have ahk do it for you

Code: Select all

:c*:--sc::
; if you don't have any selected it will use the clipboard contents as you already have it, 
; but it will depend on your editor, some editors copy the 
Send ^c ; or Send ^x entire line if you haven't selected it so ymmv
Send, <span class=''>%clipboard%</span>
Return
The %cursor% is going to be a bit tricky as you need to figure out how many {left}s you have to send.

You could look at Lintalist which would do most of the heavy lifting for you https://autohotkey.com/boards/viewtopic.php?f=6&t=3378 - the above example would be the following snippet 'code'
<span class='^|'>[[selected]]</span>
^| marks the caret position after pasting the text

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Chunjee and 296 guests