Hello, colleagues! It is necessary for me, that in a K-Meleon at text selection there was an automatic copying of the selected text in the exchange buffer. Prompt, how it to realise in a macro?
@JamesD
It is necessary for me that text copying in the buffer occurred automatically when I allocate the text. Now for copying in the buffer it is necessary to choose corresponding point of the contextual menu. I wish to do without it. Action on which it is possible to copy the allocated text - when I release the button of the mouse after text selection.
A specific "copy" function could be added to the context, right click, menu for selected text. A generic copy function is already there, as you noted. It would still require the user to preform the right click and choose an option.
Perhaps Autoit has a "button up" event, but I am not a expert in that system.
There must be ways that work without right-click menu, since the search-button works also for selected text without clicking anything more. Why not just use the global variable for selected text??
I did not mean that using the right click menu was required. That was just an example. It is just that some action is required to make the macro run. Either an event or some user action such as using the search button. I do not know of a way in the macro language to make the macro run just by selecting some text. However, just because I don't know of a way does not mean there is no possible way.
Edited 1 time(s). Last edit at 12/22/2009 09:10PM by JamesD.
;Auto copy clipboard
;thanks to pwy from autoitforums
; slightly modified for km by disrupted
;original code can be found there:http://www.autohotkey.com/forum/topic5439.html
#notrayicon
#SingleInstance force
if 0 < 1 ; The left side of a non-expression if-statement is always the name of a variable.
{
ExitApp
}
~Lshift::
TimeButtonDown = %A_TickCount%
; Wait for it to be released
Loop
{
Sleep 10
GetKeyState, LshiftState, Lshift, P
if LshiftState = U ; Button has been released.
break
elapsed = %A_TickCount%
elapsed -= %TimeButtonDown%
if elapsed > 200 ; Button was held down long enough
{
x0 = A_CaretX
y0 = A_CaretY
Loop
{
Sleep 20 ; yield time to others
GetKeyState keystate, Lshift
IfEqual keystate, U, {
x0 = A_CaretX
y0 = A_CaretY
break
}
}
if (x-x0 > 5 or x-x0 < -5 or y-y0 > 5 or y-y0 < -5)
{ ; Caret has moved
clip0 := ClipBoardAll ; save old clipboard
;ClipBoard =
Send ^c ; selection -> clipboard
ClipWait 1, 1 ; restore clipboard if no data
IfEqual ClipBoard,, SetEnv ClipBoard, %clip0%
}
return
}
}
~LButton::
TimeButtonDown = %A_TickCount%
; Wait for it to be released
Loop
{
Sleep 10
GetKeyState, LButtonState, LButton, P
if LButtonState = U ; Button has been released.
break
elapsed = %A_TickCount%
elapsed -= %TimeButtonDown%
if elapsed > 200 ; Button was held down too long, so assume it's not a double-click.
{
MouseGetPos x0, y0 ; save start mouse position
Loop
{
Sleep 20 ; yield time to others
GetKeyState keystate, LButton
IfEqual keystate, U, {
MouseGetPos x, y ; position when button released
break
}
}
if (x-x0 > 5 or x-x0 < -5 or y-y0 > 5 or y-y0 < -5)
{ ; mouse has moved
clip0 := ClipBoardAll ; save old clipboard
;ClipBoard =
Send ^c ; selection -> clipboard
ClipWait 1, 1 ; restore clipboard if no data
IfEqual ClipBoard,, SetEnv ClipBoard, %clip0%
}
return
}
}
; Otherwise, button was released quickly enough. Wait to see if it's a double-click:
TimeButtonUp = %A_TickCount%
Loop
{
Sleep 10
GetKeyState, LButtonState, LButton, P
if LButtonState = D ; Button has been pressed down again.
break
elapsed = %A_TickCount%
elapsed -= %TimeButtonUp%
if elapsed > 350 ; No click has occurred within the allowed time, so assume it's not a double-click.
{
;MouseClick, Left
return
}
}
; Since above didn't return, it's a double-click:
Sleep, 100
Send, ^c
return
So, on my system that macro works like strange search engine on open pages... I dont know wthat does it matter... And it dont copy text what I need, but it copy letter "c" and highlight it and search it on page...
Edited 1 time(s). Last edit at 12/24/2009 01:21AM by Alex.Tarantul.
It would certainly be very helpful, if you would tell what you really want to do? You select some text with the mouse and want it to be copied into the clipboard - and then? What do you do with that text in the clipboard??
I already explained: it is necessary for me that the text was copied WITHOUT click by the right button of the mouse under the contextual menu. Further it is necessary to take already copied text from the buffer (I will make it by an elementary macro) and to transfer in URL as one of parametres
yes, that is how it works.. selecting a text gets automtically copied in the clipboard but you won't know until you go somewhere and right click and paste the clipboard contents.
please see this video:
http://www.youtube.com/watch?v=tNG3n2X72qg
i think that's what you want or you want an extra command to be executed after auto-copying
also make sure the extension was installed properly in kmeleon folder and to make sure, check in the taskmanager you should have an "autoclipcopy.exe" process running with k-meleon
Quote Alex.Tarantul
I already explained: it is necessary for me that the text was copied WITHOUT click by the right button of the mouse under the contextual menu. Further it is necessary to take already copied text from the buffer (I will make it by an elementary macro) and to transfer in URL as one of parametres
So you want to create a new URL in the adress bar and the selected text shall be a part of it, perhaps somewhere in the middle or the end? But what do you want to do with it then, nothing? Or do you want to open the new URL? But how do you want to open it without clicking anything, no context menu, and no button?? You need a macro command, and this needs a way to be called!
ОБъясню по-русски. Переводчик гугл переведёт для вас
Мне нужно, чтобы БЕЗ нажатия правой кнопки мыши произошло только копирование выделенного текста в буфер. Это первое. После этого - да, нажатие БУДЕТ. Это будет нажатие в контекстном меню. Это будет второе действие. Я с этим согласен. Как это сделать я знаю, мне в ЭТОМ помощь не нужна. Я прошу помощи в выяснении первого - вопроса об автоматическом копировании выделенного текста в буфер.
Кстати, возник ещё вопрос - возможно ли открытие контекстного меню не по нажатию правой кнопки мыши, а автоматически после выделения текста?
Edited 1 time(s). Last edit at 12/24/2009 03:05PM by Alex.Tarantul.
are you using a laptop? cause i can understand with a touchpad it can be tiring to select and rightclick
i now have it working as you want but will need to do some tests to ensure no glitches and the macro has to be modified. your extension should be ready in about 1 hour
doubleclicking text will copy+context menu
moving the caret> selecting multiple words will copy+ context menu
one click>copy but will not pop the context menu to avoid bringing up the context menu in urlbar or inside the page when not needed
there's a slight delay in opening the contextmenu after selecting to avoid a glitch
access menu: edit>configuration>activate autoclip to easily turn off or on (default installation setting is on)
After that - yes, press will. It will be pressing the shortcut menu.
Okay, so you do press something! Is that shortcut menu created by the new macro??
Sorry that I keep asking, I do so because I strongly suspect that you're confusing something: To use a selected text in a macro, it is NOT necessary to right-click or to put it into clipboard. It is automatically in a variable, and can be used without such complicated tricks.
Quote siria
To use a selected text in a macro, it is NOT necessary to right-click or to put it into clipboard. It is automatically in a variable, and can be used without such complicated tricks.
OK. One problem it is solved. But that will tell on the mentioned question: whether occurrence of the contextual menu without pressing of the right button of the mouse is possible? For example, right after text selection?
I only found one problem to do the Alex's macro want, how to call the macro? you need an event, an accelerate, a menu, a toolbar button or a mouse gesture to call the macro.
(In pseudocode)
# You have the URL of the web page:
$URL;
# You have selected text:
$SelectedText;
open($URL.$SelectedText);
Really you don't need copy it to the clipboard. But if this is a requisite you can use:
$_aux = getclipboard();
setclipboard($SelectedText);
open($URL.getclipboard());
setclipboard($_aux);
# To open a contextmenu "SelectedText" is an example menu name you can change it to some other menu name defined:
plugin(rebarmenu, "SelectedText");
I was thinking to do in JavaScript, but onselect event is only for text objects, and for Mozilla browsers you need a lot of JS code for copy to clipboard because this is considered a dangerous action.