AutoHotkey Community

It is currently May 25th, 2012, 9:59 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 23 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: duplicate line
PostPosted: July 1st, 2007, 3:22 am 
Offline

Joined: June 7th, 2007, 1:33 pm
Posts: 1018
hello

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

is it possible to do it globally?

thanks


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 1st, 2007, 5:20 am 
Offline

Joined: June 27th, 2006, 2:38 pm
Posts: 385
Location: Canada
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 1st, 2007, 5:53 pm 
Offline

Joined: June 7th, 2007, 1:33 pm
Posts: 1018
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!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 1st, 2007, 6:18 pm 
Offline
User avatar

Joined: August 11th, 2004, 1:47 am
Posts: 5346
Location: UK
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 1st, 2007, 6:22 pm 
Offline

Joined: October 9th, 2006, 8:19 pm
Posts: 236
Location: Finland
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 :)

_________________
Pekka Vartto


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 1st, 2007, 6:23 pm 
Offline

Joined: June 7th, 2007, 1:33 pm
Posts: 1018
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 1st, 2007, 6:38 pm 
Offline

Joined: June 16th, 2007, 6:43 pm
Posts: 35
azure wrote:
also, can you tell me please how to make it not to work in specific windows


use IfWinActive?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 1st, 2007, 7:56 pm 
Offline

Joined: July 1st, 2007, 6:25 pm
Posts: 17
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...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 2nd, 2007, 5:34 am 
Offline

Joined: December 23rd, 2006, 6:02 pm
Posts: 424
Location: Russia
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 2nd, 2007, 6:22 am 
Offline

Joined: June 7th, 2007, 1:33 pm
Posts: 1018
yes, switching language before copying works, but its waste of time to do it each time

is there any workaround?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 2nd, 2007, 8:22 am 
Offline

Joined: June 23rd, 2007, 12:23 pm
Posts: 87
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: :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 2nd, 2007, 8:36 am 
Offline

Joined: June 23rd, 2007, 12:23 pm
Posts: 87
Btw,
look here

Bye! :shock: :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 2nd, 2007, 8:51 am 
Offline

Joined: December 23rd, 2006, 6:02 pm
Posts: 424
Location: Russia
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 2nd, 2007, 10:21 am 
Offline

Joined: October 9th, 2006, 8:19 pm
Posts: 236
Location: Finland
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 :)

_________________
Pekka Vartto


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 2nd, 2007, 10:43 am 
Offline

Joined: June 7th, 2007, 1:33 pm
Posts: 1018
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 :)


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?


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 23 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: KenC, Klark92 and 69 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group