Identifying Space Between Data to Copy

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Vaklev
Posts: 47
Joined: 04 Mar 2019, 13:58
Contact:

Identifying Space Between Data to Copy

Post by Vaklev » 31 May 2019, 12:20

Hi guys, I am trying to automate a function at my job, basically I have to populate people's names and addresses, copy and paste into corresponding fields in a form, but some clients have 3 names, some have 6, I was thinking I could create a script that would copy the entire content into clipboard, identify where there is a space, for example (Ivan Georgiev Petrov), would it be possible to have a script identify that the first Name would be Ivan, copy that into a field, go back and then identify the first space between "Petov Georgiev", then I can have it copied and pasted then i would go back identify the 2nd space for the last name "Petrov".

If you guys have any other/better ideas please let me know, also what would the code be to identify a space in between content copied into clipboard?

I also have the address on the next line, and country on 3rd line looks like this:

Ivan Georgiev Petrov
Sofia 118 Rakovski Street
BG

Right now I have image recognition picking up the country, but since the names and addresses always change per client it's hard to have my script automate it so I am manually populating but I want to automate it entirely.

Please help!

User avatar
Hellbent
Posts: 2109
Joined: 23 Sep 2017, 13:34

Re: Identifying Space Between Data to Copy

Post by Hellbent » 31 May 2019, 12:54

A bit outside my wheelhouse but this might help.

Code: Select all

*Numpad4::
	Clipboard:="Ivan Georgiev Petrov"
	Clipwait
	Names:=StrSplit(Clipboard,A_Space)  ;<-------------------
	
	;sample 1
	msgbox,% "Number of names: " Names.Length() "`nName 1: " Names[1]
	
	
	;sample 2
	temp:=""
	for,k,v in Names
		temp.="Name " k ": " Names[k] "`n"
	msgbox,% "Number of names: " Names.Length() "`n" temp
	
	;sample 3
	;~ for,k,v in Names
		;~ Send,% (k < Names.Length())?(Names[k] "{Tab}"):(Names[k])
		
	return
I don't know how you would want to use the names so I can't offer much on that. The last sample could be if the names went into a form that had the controls one tab press apart.

Vaklev
Posts: 47
Joined: 04 Mar 2019, 13:58
Contact:

Re: Identifying Space Between Data to Copy

Post by Vaklev » 31 May 2019, 13:04

I'm having a hard time understanding the above, don't worry about the code for copying and pasting into corresponding field I got that covered, what im trying to solve is this:

Ivan Georgiev Petrov <------ (let's send the mouse here and start dragging it from right to left until it hits the first letter "v", then it will continue to drag until it encounters the space right after "P"

Code: Select all

Mousemove 50,100
Send {lbutton down} ; holds left click
MouseMove -100,0,10,r ; moves to the left
(need code here to stop at spacing between "Georgiev and Petrov")
Send {lbutton up} ; releases mouse
Send {lcontrol down}c{Lcontrol up} ; copies the last name "Petrov"
Then we need it to do the same thing, but ignore the first space and stop at the second and copy the content between the first and second spacing "Georgiev".
Last edited by Vaklev on 31 May 2019, 13:11, edited 1 time in total.
Les medecins choisissent viagrasansordonnancefr.com sans danger pour la sante

User avatar
Hellbent
Posts: 2109
Joined: 23 Sep 2017, 13:34

Re: Identifying Space Between Data to Copy

Post by Hellbent » 31 May 2019, 13:10

Are you sure you need to copy the names one at a time? Can't you copy them all at once and then sort them once they are copied?

Vaklev
Posts: 47
Joined: 04 Mar 2019, 13:58
Contact:

Re: Identifying Space Between Data to Copy

Post by Vaklev » 31 May 2019, 13:12

Hellbent wrote:
31 May 2019, 13:10
Are you sure you need to copy the names one at a time? Can't you copy them all at once and then sort them once they are copied?
Let's say we copy all 3 names to clipboard, is there a way to paste the content separately? In that case, we paste each one in seperate coordinates and bam problem solved! But Idk how to work with clipboard too well
Les medecins choisissent viagrasansordonnancefr.com sans danger pour la sante

User avatar
Hellbent
Posts: 2109
Joined: 23 Sep 2017, 13:34

Re: Identifying Space Between Data to Copy

Post by Hellbent » 31 May 2019, 13:33

There are so many ways you can do this.

Here is a simple example.

If it were me I'd do it a bit different than this, for example I might use more than one hotkey etc etc, but this should get the juices flowing.

The steps are, on the first press of this hotkey it is copying the names to the clipboard (this should really be in another hotkey, but w/e)
after the names are added, each additional press of the hotkey the separated names get pasted.
once the last name is done, the script beeps and is ready to start over again.

I can't stress enough that this is just for demo purposes.

Code: Select all

*Numpad4::
	if(!Remainig_Names){
		Clipboard:="Ivan Georgiev Petrov"  ;<--------------------- this could be where you have it send ^c to copy to your
										   ;clipboard and not hard coding it like i have in this example.
	Clipwait
	Names:=StrSplit(Clipboard,A_Space)  ;<------------------- split the names
	Remainig_Names:=Names.Length() ;<-------- store how many names you have
	Index:=1 ; Set a index var
	}
	else	{
		Clipboard:=Names[Index++]
		clipwait
		Send,^v
		(--Remainig_Names=0)?(PlaySound())
	}
	return
	
PlaySound(){
	loop,3
		SoundBeep,500
}
	

User avatar
Hellbent
Posts: 2109
Joined: 23 Sep 2017, 13:34

Re: Identifying Space Between Data to Copy

Post by Hellbent » 31 May 2019, 14:13

Try this script. It makes some assumptions about some things, but I think you will get the point.

This is a approach that you might be able to take, the details would be different, but the idea would be similar.

Steps.
1: run the script
2: copy one of the tests from the top of the script.
3: press Numpad1
4: repeat steps 2 and 3

Code: Select all

#SingleInstance,Force

/*
;test 1
-----------------------------------
Ivan Georgiev Petrov
Sofia 118 Rakovski Street
BG

;test 2
-----------------------------------
Bob Sam
123 some random place
Blah blah blah

;test 3
-----------------------------------
Hellbent
This place cold be worse st.
I don't know what info is on the 3rd line


*/


Gui,1:+AlwaysOnTop
Gui,1:Color,555555,444444
Gui,1:Font,cWhite s8 Bold,Arial


Loop, 3	{
	Gui,1:Add,Text,xm,Name %A_Index%:   
	Gui,1:Add,Edit,x+10 w200 r1 hwndNed%A_Index%
	Gui,1:Add,Text,xm,Address %A_Index%:   
	Gui,1:Add,Edit,x+10 w200 r1 hwndAed%A_Index%
	Gui,1:Add,Text,xm,Blah Blah %A_Index%:
	Gui,1:Add,Edit,x+10 w200 r1 hwndBed%A_Index%
	Gui,1:Add,Text,xm,_____________________________________________________________
}
Gui,1:Show,,Demo

return
GuiClose:
GuiContextMenu:
*ESC::
	ExitApp

Numpad1::
	Loop 3	{  ; this just clears the edits for each test case
		GuiControl,1:,% Ned%A_Index%,
		GuiControl,1:,% Aed%A_Index%,
		GuiControl,1:,% Bed%A_Index%,
	}
	info:=StrSplit(ClipBoard,"`n")
	Names:=StrSplit(Info[1],A_Space)
	For,k,v in Names	{
		GuiControl,1:,% Ned%k%,% Names[k]
		GuiControl,1:,% Aed%k%,% Info[2]
		GuiControl,1:,% Bed%k%,% Info[3]
	}
	return
	



Vaklev
Posts: 47
Joined: 04 Mar 2019, 13:58
Contact:

Re: Identifying Space Between Data to Copy

Post by Vaklev » 31 May 2019, 15:55

Hey man I just downed 5 pints on lunch with my buddy at work, but when I sober up I will definitely try and give my feed back lol thanks!
Les medecins choisissent viagrasansordonnancefr.com sans danger pour la sante

Post Reply

Return to “Ask for Help (v1)”