I would like to create a tool, which when triggered, pastes some specific parts of code.
For example, when I press:
^!#d:: //the dijkstra algorithm gets pasted
^!#k:: //Kruskal's MST algorithm gets pasted
and so on.
When I try a simple "Send <code> ", ahk doesn't like it, because it gets confused by some keywords used in the pre-written algorithm, and doesn't work with it as a simple string.
Pasting parts of code with ahk?
Re: Pasting parts of code with ahk?
Welcome to this AutoHotkey forum!
I recommend:
1. Post your complete script
2. What happens when you run the script?
3. Exactly what should happen instead (be specific)?
To send text without interpreting special sequences, use text mode.
I recommend:
1. Post your complete script
2. What happens when you run the script?
3. Exactly what should happen instead (be specific)?
To send text without interpreting special sequences, use text mode.
Re: Pasting parts of code with ahk?
Try SendInput or SendRaw or Send {Text}?
^!#d::
SendInput {Text}, dijkstra algorithm
^!#d::
SendRaw, dijkstra algorithm
^!#d::
Send {Text}, dijkstra algorithm
^!#d::
SendInput {Text}, dijkstra algorithm
^!#d::
SendRaw, dijkstra algorithm
^!#d::
Send {Text}, dijkstra algorithm
Re: Pasting parts of code with ahk?
Try this (replace the <code> with the actual text/code that you want to be pasted):
Code: Select all
^!#d::
OldClipboard := ClipboardAll ;store the current clipboard data because it will soon be changed
Clipboard := "
(
<code>
)" ;put the text/code in the clipboard
Send, ^v ;paste whatever's currently in the clipboard
Clipboard := OldClipboard ;restore previous clipboard data
OldClipboard := "" ;no need to store the previous clipboard data anymore
return
^!#k::
OldClipboard := ClipboardAll ;store the current clipboard data because it will soon be changed
Clipboard := "
(
<code>
)"
Send, ^v ;paste whatever's currently in the clipboard
Clipboard := OldClipboard ;restore previous clipboard data
OldClipboard := "" ;no need to store the previous clipboard data anymore
return