Extensions :  K-Meleon Forum
All about K-Meleon extensions. 
Selected text
Posted by: Alex.Tarantul
Date: December 21, 2009 09:18PM

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?

My blog about K-Meleon
http://kmeleon-ru.blogspot.com/

Options: ReplyQuote
Re: Selected text
Posted by: siria
Date: December 21, 2009 09:57PM
Options: ReplyQuote
Re: Selected text
Posted by: JamesD
Date: December 22, 2009 08:24AM

@ Alex

Can you be more specific about "automatic" copying? Macros require some event or user action to run.

Options: ReplyQuote
Re: Selected text
Posted by: Alex.Tarantul
Date: December 22, 2009 03:10PM

@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.

Options: ReplyQuote
Re: Selected text
Posted by: JamesD
Date: December 22, 2009 07:03PM

The macro language has events http://kmeleon.sourceforge.net/wiki/MacroLanguage2#events, but button release is not included.

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.

Options: ReplyQuote
Re: Selected text
Posted by: siria
Date: December 22, 2009 08:03PM

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??

Options: ReplyQuote
Re: Selected text
Posted by: JamesD
Date: December 22, 2009 09:09PM

@ siria

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.

Options: ReplyQuote
Re: Selected text
Posted by: Alex.Tarantul
Date: December 23, 2009 02:47PM

May be it is possible with some java script or something else?

Options: ReplyQuote
Re: Selected text
Posted by: disrupted
Date: December 23, 2009 05:31PM

hi alex
download this:
http://kmext.sourceforge.net/files/autoclipcopy.7z

special thanks to pwy@ ahk forums for the original source
http://www.autohotkey.com/forum/topic5439.html

# K-Meleon Macros (http://kmeleon.sourceforge.net/wiki/index.php?id=MacroLanguage)

# ---------auto copy selected text-------

$_tool_path=getfolder(RootFolder)."\\Tools";

autoclipcopy{
exec($_tool_path."\\autoclipcopy\\autoclipcopy.exe start");
}

autoclipexit{
exec($_tool_path."\\autoclipcopy\\autoclipcopy.exe ");
}
# --------------------------------------------
$OnInit=$OnInit."autoclipcopy;";
$OnQuit=$OnQuit."autoclipexit;";
$macroModules=$macroModules."autoclipcopy;";



;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


Options: ReplyQuote
Re: Selected text
Posted by: Alex.Tarantul
Date: December 24, 2009 12:53AM

@disrupted
Thanks! I will try it now grinning smiley

Options: ReplyQuote
Re: Selected text
Posted by: Alex.Tarantul
Date: December 24, 2009 01:20AM

So, on my system that macro works like strange search engine on open pages... I dont know wthat does it matter... sad smiley 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.

Options: ReplyQuote
Re: Selected text
Posted by: siria
Date: December 24, 2009 01:34AM

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??

Options: ReplyQuote
Re: Selected text
Posted by: Alex.Tarantul
Date: December 24, 2009 01:42AM

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

Options: ReplyQuote
Re: Selected text
Posted by: disrupted
Date: December 24, 2009 03:03AM

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

Options: ReplyQuote
Re: Selected text
Posted by: siria
Date: December 24, 2009 03:25AM

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!

Options: ReplyQuote
Re: Selected text
Posted by: Alex.Tarantul
Date: December 24, 2009 03:03PM

ОБъясню по-русски. Переводчик гугл переведёт для вас smiling smiley
Мне нужно, чтобы БЕЗ нажатия правой кнопки мыши произошло только копирование выделенного текста в буфер. Это первое. После этого - да, нажатие БУДЕТ. Это будет нажатие в контекстном меню. Это будет второе действие. Я с этим согласен. Как это сделать я знаю, мне в ЭТОМ помощь не нужна. Я прошу помощи в выяснении первого - вопроса об автоматическом копировании выделенного текста в буфер.
Кстати, возник ещё вопрос - возможно ли открытие контекстного меню не по нажатию правой кнопки мыши, а автоматически после выделения текста?



Edited 1 time(s). Last edit at 12/24/2009 03:05PM by Alex.Tarantul.

Options: ReplyQuote
Re: Selected text
Posted by: disrupted
Date: December 24, 2009 04:08PM

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

thanks for explaining in russian smiling smiley

Options: ReplyQuote
Re: Selected text
Posted by: disrupted
Date: December 24, 2009 05:57PM

please test this:
http://kmext.sourceforge.net/files/autoclipcopy-plus.7z

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)

Options: ReplyQuote
Re: Selected text
Posted by: siria
Date: December 24, 2009 06:04PM

Quote

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.

Options: ReplyQuote
Re: Selected text
Posted by: Alex.Tarantul
Date: December 24, 2009 09:46PM

Quote
disrupted
are you using a laptop? cause i can understand with a touchpad it can be tiring to select and rightclick
Personally I do not use a laptop, but those colleagues who has a laptop, asked to help them with this question

Options: ReplyQuote
Re: Selected text
Posted by: Alex.Tarantul
Date: December 24, 2009 09:57PM

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?

Options: ReplyQuote
Re: Selected text
Posted by: siria
Date: December 24, 2009 10:18PM

Just call your new macro!
Instead of programming it to insert the clipboard, tell it to use the selected text variable.

Options: ReplyQuote
Re: Selected text
Posted by: disrupted
Date: December 24, 2009 10:30PM

i'm flummoxed now but if they need to auto-open the context menu without clicking the right mouse button; then this one should do it:
http://kmext.sourceforge.net/files/autoclipcopy-plus.7z

Options: ReplyQuote
Re: Selected text
Posted by: desga2
Date: December 24, 2009 11:13PM

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.

K-Meleon in Spanish



Edited 2 time(s). Last edit at 12/24/2009 11:20PM by desga2.

Options: ReplyQuote
Re: Selected text
Posted by: Alex.Tarantul
Date: December 25, 2009 01:21AM

@desga2
Thanks! I will try it tonight...

Options: ReplyQuote
Re: Selected text
Posted by: siria
Date: December 25, 2009 02:06AM

Good Luck! Is it your first macro? smiling smiley

Options: ReplyQuote
Re: Selected text
Posted by: Alex.Tarantul
Date: December 28, 2009 02:34PM

I will tell so: it will be my first public macro. I generally like to create themes (skins) more and to do Russian locales for extensions and macroes grinning smiley

Options: ReplyQuote


K-Meleon forum is powered by Phorum.