PITY-
PITY-

Reputation: 39

Sending Text - Is this possible? and how can this be done

I'm new to autohotkey

I'm trying to just make shortcuts for html and css but I keep getting "the action is not recognized" I want know what I'm doing wrong

I say

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
setworkingdir,%A_scriptdir%; Ensures a consistent starting directory.



::nav:: 
Send ul {
  list-style-type: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background-color: #333;
}

li {
  float: left;
}

li a {
  display: block;
  color: white;
  text-align: center;
  padding: 14px 16px;
  text-decoration: none;
}

li a:hover:not(.active) {
  background-color: #111;
}

.active {
  background-color: #04AA6D;
}
</style>
</head>
<body>

<ul>
  <li><a href="#home">Home</a></li>
  <li><a href="#news">News</a></li>
  <li><a href="#contact">Contact</a></li>
  <li style="float:right"><a class="active" href="#about">About</a></li>
</ul>
return 

I'm assuming it's because of like he symbols and stuff that are sensitive. I tried putting everything in {} cause that's how the hashtags worked. I'm just confused.

Upvotes: 0

Views: 129

Answers (1)

Relax
Relax

Reputation: 10636

To send such a long text to an editor it's best to use the clipboard to copy and paste from the AHK script:

::nav::                    ; hotstring
ClipSaved := ClipboardAll  ; save the entire clipboard to the variable ClipSaved
clipboard := ""            ; empty the clipboard (start off empty to allow ClipWait to detect when the text has arrived)
clipboard =                ; copy this text:
(
ul {
  list-style-type: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background-color: #333;
}

li {
  float: left;
}

li a {
  display: block;
  color: white;
  text-align: center;
  padding: 14px 16px;
  text-decoration: none;
}

li a:hover:not(.active) {
  background-color: #111;
}

.active {
  background-color: #04AA6D;
}
</style>
</head>
<body>

<ul>
  <li><a href="#home">Home</a></li>
  <li><a href="#news">News</a></li>
  <li><a href="#contact">Contact</a></li>
  <li style="float:right"><a class="active" href="#about">About</a></li>
</ul>
)
ClipWait, 1                   ; wait for the clipboard to contain data. 
If (!ErrorLevel)              ; If NOT ErrorLevel clipwait found data on the clipboard
    Send, ^v                  ; paste the text
Sleep, 300                    ; don't change clipboard while pasting! (Sleep > 0)
clipboard := ClipSaved        ; restore original clipboard
VarSetCapacity(ClipSaved, 0)  ; free the memory
return

Upvotes: 1

Related Questions