AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

duplicate line
Goto page 1, 2  Next
 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
azure



Joined: 07 Jun 2007
Posts: 694

PostPosted: Sun Jul 01, 2007 2:22 am    Post subject: duplicate line Reply with quote

hello

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

is it possible to do it globally?

thanks
Back to top
View user's profile Send private message
Conquer



Joined: 27 Jun 2006
Posts: 385
Location: Canada

PostPosted: Sun Jul 01, 2007 4:20 am    Post subject: Reply with quote

globally?

Well heres some code to produce the same effect, if thats what you're after:
Code:

^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
Back to top
View user's profile Send private message
azure



Joined: 07 Jun 2007
Posts: 694

PostPosted: Sun Jul 01, 2007 4:53 pm    Post subject: Reply with quote

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!
Back to top
View user's profile Send private message
polyethene



Joined: 11 Aug 2004
Posts: 5248
Location: UK

PostPosted: Sun Jul 01, 2007 5:18 pm    Post subject: Reply with quote

azure wrote:
but as you can see, it doesnt repaste the !
Put {Raw} before the %Clipboard% part in Send.
_________________
GitHubScriptsIronAHK Contact by email not private message.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
svi



Joined: 09 Oct 2006
Posts: 236
Location: Finland

PostPosted: Sun Jul 01, 2007 5:22 pm    Post subject: Reply with quote

azure wrote:
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:
Code:
Send {End}{Enter}
SendRaw %Clipboard%


azure wrote:
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 Smile
_________________
Pekka Vartto
Back to top
View user's profile Send private message
azure



Joined: 07 Jun 2007
Posts: 694

PostPosted: Sun Jul 01, 2007 5:23 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
Sukarn



Joined: 16 Jun 2007
Posts: 35

PostPosted: Sun Jul 01, 2007 5:38 pm    Post subject: Reply with quote

azure wrote:

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


use IfWinActive?
Back to top
View user's profile Send private message
Alexander



Joined: 01 Jul 2007
Posts: 17

PostPosted: Sun Jul 01, 2007 6:56 pm    Post subject: Reply with quote

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...
Back to top
View user's profile Send private message
YMP



Joined: 23 Dec 2006
Posts: 418
Location: Russia

PostPosted: Mon Jul 02, 2007 4:34 am    Post subject: Reply with quote

azure wrote:

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.
Back to top
View user's profile Send private message
azure



Joined: 07 Jun 2007
Posts: 694

PostPosted: Mon Jul 02, 2007 5:22 am    Post subject: Reply with quote

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

is there any workaround?
Back to top
View user's profile Send private message
Tarch



Joined: 23 Jun 2007
Posts: 87

PostPosted: Mon Jul 02, 2007 7:22 am    Post subject: Reply with quote

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! Shocked Smile
Back to top
View user's profile Send private message
Tarch



Joined: 23 Jun 2007
Posts: 87

PostPosted: Mon Jul 02, 2007 7:36 am    Post subject: Reply with quote

Btw,
look here

Bye! Shocked Smile
Back to top
View user's profile Send private message
YMP



Joined: 23 Dec 2006
Posts: 418
Location: Russia

PostPosted: Mon Jul 02, 2007 7:51 am    Post subject: Reply with quote

azure wrote:
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.
Code:

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):
Code:

F11::
  SetFormat, Integer, H
  WinGet, WinID,, A
  ThreadID:=DllCall("GetWindowThreadProcessId", "UInt", WinID, "UInt", 0)
  InputLocaleID:=DllCall("GetKeyboardLayout", "UInt", ThreadID)
  MsgBox, %InputLocaleID%
Return
Back to top
View user's profile Send private message
svi



Joined: 09 Oct 2006
Posts: 236
Location: Finland

PostPosted: Mon Jul 02, 2007 9:21 am    Post subject: Reply with quote

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

Using
Code:
Send {End}{Enter}^v
you don't need to use raw and also Greek chars gets copied like normally Smile
_________________
Pekka Vartto
Back to top
View user's profile Send private message
azure



Joined: 07 Jun 2007
Posts: 694

PostPosted: Mon Jul 02, 2007 9:43 am    Post subject: Reply with quote

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

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


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?
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group