Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

duplicate line


  • Please log in to reply
22 replies to this topic
azure
  • Members
  • 1216 posts
  • Last active: Mar 18 2015 09:06 AM
  • Joined: 07 Jun 2007
hello

in my text editor, the hotkey ctrl+y duplicates the current line

is it possible to do it globally?

thanks

Conquer
  • Members
  • 385 posts
  • Last active: Jan 10 2013 02:14 AM
  • Joined: 27 Jun 2006
globally?

Well heres some code to produce the same effect, if thats what you're after:
^y::
SetKeyDelay, -1
Temp := ClipboardAll
Clipboard =
Send {End}+{home}^c
ClipWait, 2
Send {End}{Enter}%Clipboard%
Clipboard := Temp
return
Untested but I'm sure it'll work fine

azure
  • Members
  • 1216 posts
  • Last active: Mar 18 2015 09:06 AM
  • Joined: 07 Jun 2007
thanks, it works good!
thanks, it works good
thanks, it works good

but as you can see, it doesnt repaste the !, dunno why
also, it doesnt work when the cursor is at the begining of the line

any fixes?

PS: is it possible the script to recognize whether there is space for new line or not and only then work?

I mean, clicking ctrl+y in the address bar sends an ENTER that makes the browser visit the webpage

it should only work 1) when the cursor is vertical (text) and 2) only when it is possible to write multiple lines in the edit control

thanks!

polyethene
  • Members
  • 5519 posts
  • Last active: May 17 2015 06:39 AM
  • Joined: 26 Oct 2012

but as you can see, it doesnt repaste the !

Put {Raw} before the %Clipboard% part in Send.

autohotkey.com/net Site Manager

 

Contact me by email (polyethene at autohotkey.net) or message tidbit


svi
  • Members
  • 237 posts
  • Last active: Mar 09 2015 06:34 PM
  • Joined: 09 Oct 2006

but as you can see, it doesnt repaste the !, dunno why

It's because ! is interpretted as Alt (as + is Shift or ^ is Ctrl).
So use SendRaw:
Send {End}{Enter}
SendRaw %Clipboard%

also, it doesnt work when the cursor is at the begining of the line

In Notepad, Notepad++ or WordPad no problems ...

Edit:
Titan
was little faster :)
Pekka Vartto

azure
  • Members
  • 1216 posts
  • Last active: Mar 18 2015 09:06 AM
  • Joined: 07 Jun 2007
thanks

can you tell me please why it doesnt work in greek? all the scripts that copy and paste text, dont work well

εςφξεςφ εςιφξες
åòöîåòö åòéöîåò ; this is supposed to be the duplicate line of the above

also, can you tell me please how to make it not to work in specific windows

Sukarn
  • Members
  • 35 posts
  • Last active: Aug 16 2007 06:08 PM
  • Joined: 16 Jun 2007

also, can you tell me please how to make it not to work in specific windows


use IfWinActive?

Alexander
  • Members
  • 17 posts
  • Last active: Jul 03 2007 01:52 AM
  • Joined: 01 Jul 2007
I've tried to tweaked the script a little and replaced the send of the enter key by a linefeed... But it still gets recognised as if you pressed enter in the IE and Firefox behavior...

YMP
  • Members
  • 424 posts
  • Last active: Apr 05 2012 01:18 AM
  • Joined: 23 Dec 2006

can you tell me please why it doesnt work in greek? all the scripts that copy and paste text, dont work well


Switch the window to Greek before copying. If it helps, then it's the problem of converting from ANSI to Unicode.

Some programs, when you paste text in them, require the text from the clipboard to be in Unicode. If the text is in ANSI, Windows automatically transcodes it. In case the window where you copied the text was in Greek, the Greek codepage will be used and the Greek letters will be coded correctly. If the window was in English, Windows uses the English codepage, and the national characters are lost.

azure
  • Members
  • 1216 posts
  • Last active: Mar 18 2015 09:06 AM
  • Joined: 07 Jun 2007
yes, switching language before copying works, but its waste of time to do it each time

is there any workaround?

Tarch
  • Members
  • 87 posts
  • Last active: Mar 24 2009 12:29 AM
  • Joined: 23 Jun 2007
Hi,
you could use a send command to switch the language because ALT-SHIFT (in the italian version, it could be different, because some hotkeys are different between versions) is the default command to switch the language. Obviously there are some problems because this depends from the language you have set and from how many languages do you use. I don't know if there is a command to switch or a function in some dll.

Hope it helps a bit!

Bye! :shock: :)

Tarch
  • Members
  • 87 posts
  • Last active: Mar 24 2009 12:29 AM
  • Joined: 23 Jun 2007
Btw,
look here

Bye! :shock: :)

YMP
  • Members
  • 424 posts
  • Last active: Apr 05 2012 01:18 AM
  • Joined: 23 Dec 2006

yes, switching language before copying works, but its waste of time to do it each time


There's no need to do it manually. You can switch the language by sending the WM_INPUTLANGCHANGEREQUEST message to the window. Check if the window is in English, if so, switch it to Greek, copy (or cut), and switch back to English.
F11::
  Eng=0x4090409
  Greek=0x4080408
  WinGet, WinID,, A
  ThreadID:=DllCall("GetWindowThreadProcessId", "UInt", WinID, "UInt", 0)
  InputLocaleID:=DllCall("GetKeyboardLayout", "UInt", ThreadID)
  if(InputLocaleID=Eng)
  {
    SendMessage, 0x50,, Greek,, A
    Send, ^{vk43}                      ; Ctrl-C
    SendMessage, 0x50,, Eng,, A
  }
  else
    Send, ^{vk43}
Return
The code above presumes that the input locale ID for Greek is 0x4080408 and the virtual key code of C is 0x43. If not so, correct them. To find out the input locale ID, use this (the active window should be in Greek):
F11::
  SetFormat, Integer, H
  WinGet, WinID,, A
  ThreadID:=DllCall("GetWindowThreadProcessId", "UInt", WinID, "UInt", 0)
  InputLocaleID:=DllCall("GetKeyboardLayout", "UInt", ThreadID)
  MsgBox, %InputLocaleID%
Return


svi
  • Members
  • 237 posts
  • Last active: Mar 09 2015 06:34 PM
  • Joined: 09 Oct 2006
I didn't first notice it, but now I wonder why Conquer used Clipboard instead of normal Paste key combination Ctrl+V?

Using
Send {End}{Enter}^v
you don't need to use raw and also Greek chars gets copied like normally :)
Pekka Vartto

azure
  • Members
  • 1216 posts
  • Last active: Mar 18 2015 09:06 AM
  • Joined: 07 Jun 2007

I didn't first notice it, but now I wonder why Conquer used Clipboard instead of normal Paste key combination Ctrl+V?

Using

Send {End}{Enter}^v
you don't need to use raw and also Greek chars gets copied like normally :)


this code

^+y::
SetKeyDelay, -1
Temp := ClipboardAll
Clipboard =
Send {End}+{home}^c
ClipWait, 2
Send {End}{Enter}^v
Clipboard := Temp
return

pastes:

Send {End}{Enter}^v
Send {End}{Enter}^v
etc, not the current line

do I miss something?