Link to home
Start Free TrialLog in
Avatar of Luis Diaz
Luis DiazFlag for Colombia

asked on

Autohotkey: style code v2

Hello experts,

The following script allows me to send style code based on a selection:


!^c:: ;code
Send, ^x
Send, [Code]
Sleep, 50
ClipWait,1
If (ErrorLevel=1)
{
  MsgBox,4144,Error, No text appearing after one second
  Return
}
Send, ^v
Sleep, 50
Send, {End}
Sleep, 50

Send, [/Code]
Return


Instead of selecting and go to initial position I thought that the best is to simplify it as following through using directly by the clipboard:


!^c:: ;code
Send, ^c
Sleep, 50
ClipWait,1
If (ErrorLevel=1)
{
  MsgBox,4144,Error, No text appearing after one second
  Return
}
ClipboardVar:=Clipboard
Clipboard:="[Code]" . ClipboardVar . "[/Code]"
Sleep, 50
MsgBox,4160,Success,Your clipboard has been properly copied.
Return


Prior to adding to my AutoHotKey file could you please let me know your advice on the script structure and if I can go ahead by adding this on my AutoHotKey file.

Thank you very much for your help.
Avatar of Bill Prew
Bill Prew

Luis,

I reformatted your original question a bit to hopefully make it more readable.  There is no way that I know of to "nest" [code]…[/code] blocks inside each other, so for this question I think just bolding the "code" in the question may be more useful.  I hope this helps, but check and make sure I didn't change the original intent of your question.


»bp
Avatar of Luis Diaz

ASKER

Hello Bill,
Thank you for this help. The intend of the question hasn't changed. Just for my knowledge, how did you add the line prior the bold of the block?
SOLUTION
Avatar of Bill Prew
Bill Prew

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Noted, thank you very much for your feedback.
You're very welcome!