Help with sending an items from clipboard then sending keystrokes
-
- Posts: 3
- Joined: 01 Feb 2023, 10:20
Help with sending an items from clipboard then sending keystrokes
Searched for the solution for days but cant figure out how to do what i want altough im sure its super simple.
What i want the code do is this:
send tab 11 times
loop as many times as many lines are on the clipboard
(send Space
paste clipboard item #1
send tab 4 times
)
^e::
send {Tab 11},
Loop x
{send {space},
paste clipboard item #1
send {tab 4}
}
Heres an example:
text1
text2
text3
text4
text5
I want to be able to copy text1...text5 then when i hit my hotkey i want it to send space then insert text1, then send tab four times then send space then paste text2
The goal would be that it loops the above actions as many times as many lines are on the clipboard.
What i want the code do is this:
send tab 11 times
loop as many times as many lines are on the clipboard
(send Space
paste clipboard item #1
send tab 4 times
)
^e::
send {Tab 11},
Loop x
{send {space},
paste clipboard item #1
send {tab 4}
}
Heres an example:
text1
text2
text3
text4
text5
I want to be able to copy text1...text5 then when i hit my hotkey i want it to send space then insert text1, then send tab four times then send space then paste text2
The goal would be that it loops the above actions as many times as many lines are on the clipboard.
Re: Help with sending an items from clipboard then sending keystrokes
Welcome to this AutoHotkey forum!
Code: Select all
#Requires AutoHotkey v2.0
A_Clipboard := "
(
text1
text2
text3
text4
text5
)"
^e:: {
Send '{Tab 11}'
Loop Parse A_Clipboard, '`n', '`r'
SendText ' ' A_LoopField '`t`t`t`t'
}
-
- Posts: 3
- Joined: 01 Feb 2023, 10:20
Re: Help with sending an items from clipboard then sending keystrokes
mikeyww wrote: ↑01 Feb 2023, 20:19Welcome to this AutoHotkey forum!
Code: Select all
#Requires AutoHotkey v2.0 A_Clipboard := " ( text1 text2 text3 text4 text5 )" ^e:: { Send '{Tab 11}' Loop Parse A_Clipboard, '`n', '`r' SendText ' ' A_LoopField '`t`t`t`t' }
Thank you very much for your reply mikeyww!
When i tried to run the code it did not paste what i copied. Tried to add the tab and space press(es) i need but now im getting error when trying to run it from 2.02.
Here is the code:
Code: Select all
^e::
Send '{Tab 11}' ; This does not have to be looped, just has to be executed once when i press the hotkey
Loop (Send '{Space}' ; this is the part till the end i want to loop.
Parse A_Clipboard, '`n', '`r'
SendText ' ' A_LoopField '`t`t`t`t'
Send '{Tab 4}')
What is the issue with this code now?
[Mod edit: Added [code][/code] tags. Please use them yourself when posting code.]
Re: Help with sending an items from clipboard then sending keystrokes
There are several issues in that few lines of code. It’s basically a mess to be honest. You can’t make up your own syntax. You can’t put the Send function on the same line as the loop. Parse doesn’t make sense on a line of its own. Indenting doesn’t group blocks of code and neither do parentheses. You don’t have braces to start and end your hotkey function as is required.
Don’t deviate from what mikeyww posted without understanding why, using the AHK documentation as a guide. Definitely don’t write code that has no basis from the documentation or examples you’ve seen.
Don’t deviate from what mikeyww posted without understanding why, using the AHK documentation as a guide. Definitely don’t write code that has no basis from the documentation or examples you’ve seen.
Re: Help with sending an items from clipboard then sending keystrokes
Yeah, I agree with boiler.
I would back up here, too, to see if the posted script works. That tells you whether you have a working starting point.
My output is below.
The v1 version is below.
I would back up here, too, to see if the posted script works. That tells you whether you have a working starting point.
So you copied and pasted the complete (all lines) and exact script, and ran it, right, with no additional code? And it did not paste anything, such as into Notepad, right? So what actually happened?When i tried to run the code it did not paste what i copied.
My output is below.
Code: Select all
text1 text2 text3 text4 text5
Code: Select all
#Requires AutoHotkey v1.1.33
Clipboard := "
(
text1
text2
text3
text4
text5
)"
^e::
SendInput {Tab 11}
Loop Parse, Clipboard, "`n", "`r"
SendInput % "{Text} " A_LoopField "`t`t`t`t"
Return
Re: Help with sending an items from clipboard then sending keystrokes
The interesting thing is that when I look at the comments in fenyodoboz’ code and the code itself to understand what was trying to be fixed, mikeyww’s code already did exactly those things.
-
- Posts: 3
- Joined: 01 Feb 2023, 10:20
Re: Help with sending an items from clipboard then sending keystrokes
Thank you very much for the help from both of you, I just tried the code in v1 and it seems like it does what I would like it to do, couldnt test it properly unfortunately because of lack of time.