CopyCollector

Post your working scripts, libraries and tools for AHK v1.1 and older
User avatar
haichen
Posts: 631
Joined: 09 Feb 2014, 08:24

CopyCollector

30 Jun 2015, 12:30

CopyCollector seems to be deleted due to the forum databaseerror.
So here is a another try.

Its a more advanced version. Now it works in Excel and you can determine a delimiter between the textsnippets.


In short: CopyCollector puts copied text into a buffer just by clicking the appskey in one window. by changing the window the same key try to insert the text:

Image.

Code: Select all


#SingleInstance ignore
SetTitleMatchMode, 2

copyAWindow:="a window with forms"


help =
(
CopyCollector collect marked text with the appskey.
by changing the window the same appskey will try to insert the whole collected snippets.
it works in most windows par example in Excel or firefox.

You can give him a special window where it works a little bit different.
In the CopyAWindow it acts like Ctrl-A when selecting Text. This is very useful foer copying from form.
You only need to put the caret into the form (simply click) and then use the appskey to collect the content.

In the Taskbar you can set a delimiter between the textsnippets
)


Tiptext = 
(
multiple copy of marked text in one window
and insert the whole bunch in another window.
)	

menutitle:="CopyCollector HK:Appskey"
Menu, tray,add,  info
Menu, tray,Disable,  info
Menu, tray,Rename, info , %menutitle%
Menu, tray, add  
Menu, Tray, Tip, %Tiptext%
Menu, tray, add, help
Menu, tray, add  
Menu, tray,add,  delimiter
Menu, tray,Disable,  delimiter
Menu, tray, add
Menu, tray, add, space
Menu, tray, add, paragraph
Menu, tray, Check, paragraph
Menu, tray, add, colon
Menu, tray, add, Semicolon
Menu, tray, add  
Menu, tray, add, Exit
Menu, tray, NoStandard


separator:="`n"
Appskey::CopyCollection(copyAWindow,separator)


return

CopyCollection(copyAWindow,separator)
{
	; copies selectect text to a var as long as you remain in the same window.
	; if you change the window the function tries to insert the collected textsnippets.
	static oldID:=0 , Collection :=""
	id:=WinExist("A")
	if ((id <> oldID) and oldID)
	{
		Clipboard:=""
		; ----
		;only insert the text - nothing will be replaced
		send ^c
		sleep,10
		if (Clipboard<>"")
		{
			Collection:=""
			oldID:=0
			id:=""
			Clipboard:=""
			return
		}
		;----
		if (A_ThisMenuItem<>"space")
			collection:=trim(collection)
		
		Clipboard:=SubStr(collection,1, StrLen(collection)-1)
		
		send ^v
		sleep, 10
		Collection:=""
		oldID:=0
		id:=""
		Clipboard:=""
		return
	}
	if WinActive("ahk_class XLMAIN")
	{
		send  ^c
		clipwait,10
		Clipboard:=trimplus(Clipboard)
	}
	else If (WinActive(copyAWindow) and (copyAWindow<>""))
	{
		send ^c{Right}
		if (Clipboard="")
			send ^a^c{Right}
	}
	else
		send ^c{Right}
	ClipWait ,2
	Collection .= trim(Clipboard) . separator
	sleep, 10
	Clipboard:=""
	oldID:=id
	id:=""
	return
}





help:
Msgbox, %help%
return

Exit:
exitapp


paragraph:
	separator:="`n" 
	Menu, tray, Check, paragraph
	Menu, tray, Uncheck, colon
	Menu, tray, Uncheck, space
	Menu, tray, Uncheck, semicolon
return

Space:
	separator:=A_Space
	Menu, tray, Uncheck, paragraph
	Menu, tray, Uncheck, colon
	Menu, tray, Check, space
	Menu, tray, Uncheck, semicolon
return

colon:
	separator:="`, "
	Menu, tray, Uncheck, paragraph
	Menu, tray, Check, colon
	Menu, tray, Uncheck, space
	Menu, tray, Uncheck, semicolon
return

semicolon:
	separator:="`; "
	Menu, tray, Uncheck, paragraph
	Menu, tray, Uncheck, colon
	Menu, tray, Uncheck, space
	Menu, tray, Check, semicolon
return

info:
return

delimiter:
return


TrimPlus(Text,NoTrim ="")
{
	p:=",;:."
	s:="`t,`n,`r,`v,`f,  "
	
	Loop,Parse,NoTrim
	{
		p:=strReplace(p,A_LoopField)
		s:=strReplace(s,A_LoopField)
	}
	
	Loop,Parse,p
		Text:=strReplace(Text,A_LoopField,A_LoopField . A_Space)
	
	Loop,Parse,s,`,
	{
		empty:=A_LoopField
		Loop
			Text:=strReplace(Text,empty,A_Space,OutputVarCount)
		until !OutputVarCount
	}
	
	Loop,Parse,p
		Text:=strReplace(Text,A_Space . A_LoopField,A_LoopField)
	
	Text:= trim(Text)
	return Text
}

;SendMessage, 0xB1,p1 ,p2 ,, ahk_id %hEdit%  ;setsel
User avatar
joedf
Posts: 8972
Joined: 29 Sep 2013, 17:08
Location: Canada
Contact:

Re: CopyCollector

30 Jun 2015, 15:02

nice :)
and sorry about the db error :p
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
haichenatwork

Re: CopyCollector

01 Jul 2015, 01:19

nice :)
Thanks! :D
and sorry about the db error :p
shit happens. The db is the "bad guy".

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: No registered users and 122 guests