AutoHotkey Community

It is currently May 27th, 2012, 4:22 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: February 23rd, 2010, 7:13 pm 
Offline

Joined: February 22nd, 2010, 10:07 pm
Posts: 1
Hi all, i'm quite surprised i can't find a script to automatize the scripting itself. I'm not a pro-coder but i play with html and i would like a script helping me doing something like the following (i'll show some example).

I have this text (in Notepad++ or in the browser)
Code:
http://site.com/this/is/an/example


I would like to highlight it, pressing a hotkey and having something like
Code:
<a href="http://site.com/this/is/an/example" target="_blank">http://site.com/this/is/an/example</a>

or
Code:
<a href="http://site.com/this/is/an/example" target="_blank">CLICK HERE</a>


I *guess* it can be done someway, but i don't have a clue :(


Any help would be really appreciated, as it could save me a lot of time. Thanks in advance


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 23rd, 2010, 8:07 pm 
Offline

Joined: April 8th, 2009, 7:49 pm
Posts: 6073
Location: San Diego, California
>>I *guess* it can be done someway, but i don't have a clue

:?: Have you read and performed the examples in the tutorial ?
http://www.autohotkey.com/docs/Tutorial.htm

>>Any help would be really appreciated, as it could save me a lot of time.

:arrow: try this demo,
place this code in an Ahk file and run it, if you see the message you did that correctly.
Open an empty file in Notepad++ and hit F1, then watch.

study the links to make sense of the script and modify it for your needs
Code:
Msgbox ,,,Hotkey F1 installed,2
return
F1::
Send This is a test.`nThis is only a test.
sleep, 1000
send ^a ; select all text
send ^x ; cut the text
sleep, 1000
send ^v ; paste the text
sleep, 1000
send ^x ; cut the text
sleep, 1000
send ^v ; paste the text
msgbox End of demo. `nPress OK to exit.
exitapp ; <---- add a semicolon to this line to keep the script loaded
return


http://www.autohotkey.com/docs/Hotkeys.htm
http://www.autohotkey.com/docs/commands/Send.htm
http://www.autohotkey.com/docs/commands/Sleep.htm
http://www.autohotkey.com/docs/commands/Return.htm
http://www.autohotkey.com/docs/misc/Clipboard.htm
http://www.autohotkey.com/docs/Variables.htm (from the top until Built-in Variables)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 24th, 2010, 2:24 am 
Ok, thanks for your help, my first example just worked perfectly with
Code:
send ^x
send <a href="^v" TARGET="_blank">^v</a>


But now i'm experiencing another trouble, because i wante to try to use it also for BBCODE.

Example
Code:
send ^x
send [QUOTE][CENTER][b][URL="^v"]Check ~ here[/URL][/b][/CENTER][/QUOTE]

Raturns me
Code:
'QUOTEì'CENTERì'bì'URL+°return°ìcheck ç here'ùURLì'ùbì'ùCENTERì'ùQUOTEì


How can i avoid this?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 24th, 2010, 4:20 am 
Offline

Joined: February 17th, 2008, 7:09 am
Posts: 536
Anonymous wrote:
Ok, thanks for your help, my first example just worked perfectly with
Code:
send ^x
send <a href="^v" TARGET="_blank">^v</a>


But now i'm experiencing another trouble, because i wante to try to use it also for BBCODE.

Example
Code:
send ^x
send [QUOTE][CENTER][b][URL="^v"]Check ~ here[/URL][/b][/CENTER][/QUOTE]

Raturns me
Code:
'QUOTEì'CENTERì'bì'URL+°return°ìcheck ç here'ùURLì'ùbì'ùCENTERì'ùQUOTEì


How can i avoid this?


I don't see the unwanted output on my test. It's possible a key is being held that shouldn't (Like control). However you can do a copy/replace formatting instead to make sure it works.

Code:
;just my selection for testing
#c::

txt = [QUOTE][CENTER][b][URL="replace"]Check ~ here[/URL][/b][/CENTER][/QUOTE]

;copy and wait till clipboard is ready
clipboard =
send ^x
clipwait

;replace the word 'replace' with the clipboard contents.
stringreplace, txt, txt, replace, %clipboard%, All

;clear clipboard again and wait til it's ready
clipboard =
clipboard := txt
clipwait

;paste final output.
send ^v


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], Mickers, rbrtryn and 64 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group