Autocopy selected text and auto paste in word

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: Autocopy selected text and auto paste in word

23 Feb 2018, 06:34

Code: Select all

No := 0

p::
   Send, ^c
   No++
   FileAppend, % No . " - " . ClipBoard . "`n", MyNotes.txt
   Return

Esc:: ExitApp
User avatar
Nwb
Posts: 444
Joined: 29 Nov 2016, 08:56

Re: Autocopy selected text and auto paste in word

23 Feb 2018, 06:44

BoBo wrote:

Code: Select all

No := 0

p::
   Send, ^c
   No++
   FileAppend, % No . " - " . ClipBoard . "`n", MyNotes.txt
   Return

Esc:: ExitApp
Nice didn't know about fileappend. Btw do you know why controlsend did not work? Didn't work for me either what am I missing?
I am your average ahk newbie. Just.. a tat more cute. ;)
djasi78
Posts: 27
Joined: 23 Feb 2018, 00:28

Re: Autocopy selected text and auto paste in word

23 Feb 2018, 06:52

Thank you @BoBo

Can this be used to create something like this ?

1
2
3
3.1
3.2
4
4.1
4.2
User avatar
Nwb
Posts: 444
Joined: 29 Nov 2016, 08:56

Re: Autocopy selected text and auto paste in word

23 Feb 2018, 07:21

djasi78 wrote:Thank you @BoBo

Can this be used to create something like this ?

1
2
3
3.1
3.2
4
4.1
4.2
Lemme try.
I am your average ahk newbie. Just.. a tat more cute. ;)
Guest

Re: Autocopy selected text and auto paste in word

23 Feb 2018, 07:22

Because you don't use number it doesn't write it :-)

Code: Select all

Number = 0
line:="`n`n-------`n`n" ; new line (2x) ------ new line (2x) - adjust to your preference "`n`n" will be empty line between notes

p:: 
Send, ^v
Number++
FileAppend, %number%. %clipboard% %line%, MyNotes.txt ; also inserts . after number
return
esc:: ExitApp
User avatar
Nwb
Posts: 444
Joined: 29 Nov 2016, 08:56

Re: Autocopy selected text and auto paste in word

23 Feb 2018, 08:03

djasi78 wrote:Thank you @BoBo

Can this be used to create something like this ?

1
2
3
3.1
3.2
4
4.1
4.2
Was tricky but here's what I came up with! Would love to see if there was a better method to do this. :)

Code: Select all

No := 0
Reset := 0

p::
   No := No - Reset
   Reset := 0

   Send, ^c
   No++
   d:= floor(No)
   FileAppend, % d . " - " . ClipBoard . "`n", MyNotes.txt
   Return

^p::
SetFormat, Float, 0.1
   Reset += 0.1
   No += 0.1 
      FileAppend, % No . " - " . ClipBoard . "`n", MyNotes.txt
   Return


Esc:: ExitApp
Click 'p' to make a new numbered line (example: 1,2,3)
Click 'Ctrl+p' to make a sub-numbered line (example: 1.1,1.2,1.3)

Just remember that you cannot have more than nine sub-numbered lines in this script and you should be fine. ;)

Let me know if there was any complications!
Last edited by Nwb on 23 Feb 2018, 10:47, edited 2 times in total.
I am your average ahk newbie. Just.. a tat more cute. ;)
djasi78
Posts: 27
Joined: 23 Feb 2018, 00:28

Re: Autocopy selected text and auto paste in word

23 Feb 2018, 09:14

For 1.1 , 2.1 , .... It only shows prompt that 1.1/2.1 .. is created but it does not paste it in txt file.

Overall functionality is perfect.

Thank you.
djasi78
Posts: 27
Joined: 23 Feb 2018, 00:28

Re: Autocopy selected text and auto paste in word

23 Feb 2018, 10:01


Working !! :bravo:

But it does not number the new text :crazy:

Thank you.
User avatar
Nwb
Posts: 444
Joined: 29 Nov 2016, 08:56

Re: Autocopy selected text and auto paste in word

23 Feb 2018, 10:44

djasi78 wrote:For 1.1 , 2.1 , .... It only shows prompt that 1.1/2.1 .. is created but it does not paste it in txt file.

Overall functionality is perfect.

Thank you.
Oh oops! I left it at msgbox haha my bad try now.
I am your average ahk newbie. Just.. a tat more cute. ;)
djasi78
Posts: 27
Joined: 23 Feb 2018, 00:28

Re: Autocopy selected text and auto paste in word

23 Feb 2018, 10:53

Awesome , almost perfect.

All i need is to create , more than 10 sub headings . Anyway to do it ?

Thank you.
User avatar
Nwb
Posts: 444
Joined: 29 Nov 2016, 08:56

Re: Autocopy selected text and auto paste in word

23 Feb 2018, 11:49

djasi78 wrote:Awesome , almost perfect.

All i need is to create , more than 10 sub headings . Anyway to do it ?

Thank you.
Sure but it will be 1.01, 1.02, 1.03... 1.10,1.11.. etc. will that be alright? I know it's possible to change 01 to 1 but I'm not sure about that.

Anyways here is script for as mentioned:

Code: Select all

No := 0
Reset := 0

p::
   No := No - Reset
   Reset := 0

   Send, ^c
   No++
   d:= floor(No)
   FileAppend, % d . " - " . ClipBoard . "`n", MyNotes.txt
   Return

^p::
SetFormat, Float, 0.2
   Reset += 0.01
   No += 0.01 
      FileAppend, % No . " - " . ClipBoard . "`n", MyNotes.txt
   Return


Esc:: ExitApp
Last edited by Nwb on 23 Feb 2018, 12:20, edited 1 time in total.
I am your average ahk newbie. Just.. a tat more cute. ;)
djasi78
Posts: 27
Joined: 23 Feb 2018, 00:28

Re: Autocopy selected text and auto paste in word

23 Feb 2018, 12:05

It shows like this

1
2
3
4
5
5.0
5.0
5.0
5.0
User avatar
Nwb
Posts: 444
Joined: 29 Nov 2016, 08:56

Re: Autocopy selected text and auto paste in word

23 Feb 2018, 12:20

djasi78 wrote:It shows like this

1
2
3
4
5
5.0
5.0
5.0
5.0
Oops sorry I keep forgetting minute details haha. Should work now. Just as you wanted to this ti,e. :P
I am your average ahk newbie. Just.. a tat more cute. ;)
djasi78
Posts: 27
Joined: 23 Feb 2018, 00:28

Re: Autocopy selected text and auto paste in word

23 Feb 2018, 12:29

:clap: :clap: :clap: :shock: :shock: :clap: :clap: :clap:

Finally :dance: :dance:

Any possibility of using this , to use Microsoft Word ?

Code: Select all

https://github.com/ahkon/MS-Office-COM-Basics/blob/master/Examples/Word/Document_collect_clipboard_data.ahk
User avatar
FanaticGuru
Posts: 1906
Joined: 30 Sep 2013, 22:25

Re: Autocopy selected text and auto paste in word

23 Feb 2018, 14:49

djasi78 wrote:I want to use Microsoft Word for saving.
Here is an example using Microsoft Word.

Code: Select all

F12::
	if (Toggle = "")
	{
		wdApp := ComObjActive("Word.Application")
		wdApp.Selection.Range.ListFormat.ApplyOutlineNumberDefault
		Toggle := 0
	}
	Toggle := !Toggle
	MsgBox % Toggle ? "Clip to Word: ON" : "Clip to Word: OFF"
return

#if Toggle
/::
	Send ^c
	ClipWait, 1
	wdApp.Selection.TypeText(Clipboard "`n")
return

.::
	Send ^c
	ClipWait, 1
	wdApp.Selection.Paragraphs(1).Range.ListFormat.ListIndent
	wdApp.Selection.TypeText(Clipboard "`n")
return

,::
	Send ^c
	ClipWait, 1
	wdApp.Selection.Paragraphs(1).Range.ListFormat.ListOutdent
	wdApp.Selection.TypeText(Clipboard "`n")
return
#If
You have to start the script and MS Word has to be open.

Then you hit F12 to toggle the script ON.

Then you highlight something and hit / to copy something to Word at the current indent level.
. to copy increasing the indent (this is the ">" key without shift)
, to copy decreasing the indent (this is the "<" key without shift)

Tested hardly any, but seems to work.

FG
Hotkey Help - Help Dialog for Currently Running AHK Scripts
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
djasi78
Posts: 27
Joined: 23 Feb 2018, 00:28

Re: Autocopy selected text and auto paste in word

23 Feb 2018, 15:04

@FanaticGuru :o :o :o :o

Thanks a lot .

@nwb also thanks a lot.

working , exactly like i wished :dance:

:bravo: :dance: :bravo: :dance: :dance: :dance:
User avatar
FanaticGuru
Posts: 1906
Joined: 30 Sep 2013, 22:25

Re: Autocopy selected text and auto paste in word

23 Feb 2018, 16:05

After furture thought, not that it really matters but, the arrow keys are probably a better choice.

You can change the:
/::
.::
,::

to

Down::
Right::
Left::


Or whatever keys you like.

FG
Hotkey Help - Help Dialog for Currently Running AHK Scripts
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
djasi78
Posts: 27
Joined: 23 Feb 2018, 00:28

Re: Autocopy selected text and auto paste in word

24 Feb 2018, 06:04

I just came across that this script does not paste text from pdf

Thank you

Edit :

working just needed to use another PDF viewer

But i have another problem

If i copy

Code: Select all

The pharmacodynamics of cocaine involve the complex relationships of neurotransmitters (inhibiting monoamine uptake in rats with ratios of about: serotonin:dopamine = 2:3, serotonin:norepinephrine = 2:5).[59][10] The most extensively studied effect of cocaine on the central nervous system is the blockade of the dopamine transporter protein.
it will be pasted in word like this

a ) The pharmacodynamics of cocaine involve the complex relationships of neurotransmitters (inhibiting monoamine uptake in rats with ratios of about: serotonin:dopamine = 2:3,
b) serotonin:norepinephrine = 2:5).[59][10] The most extensively studied effect of cocaine on the central nervous system is the blockade of the dopamine transporter protein.
Last edited by djasi78 on 24 Feb 2018, 06:16, edited 1 time in total.
User avatar
Nwb
Posts: 444
Joined: 29 Nov 2016, 08:56

Re: Autocopy selected text and auto paste in word

24 Feb 2018, 06:16

djasi78 wrote:I just came across that this script does not paste text from pdf

Thank you
Yes because ctrl+c does not copy from pdfs.
I am your average ahk newbie. Just.. a tat more cute. ;)

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: mikeyww, mmflume and 158 guests