AutoHotkey Community

It is currently May 27th, 2012, 11:49 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: August 12th, 2010, 3:43 pm 
Offline

Joined: February 9th, 2006, 8:01 pm
Posts: 117
I'm trying to read data out of a ticketing system that was unfortunately written rather poorly.

One of the lame things is that the system dynamically creates controls every time you open a new tab. So say, for example, we open a ticket in the system, and this ticket is for someone who lives at an appartment... the controls get dynamically controlled like this:

234123a1 Jim
234123a2 Jones
234123a3 156 West st
234123a4 Apt 12
234123a5 New York
234123a5 NY

and another customer that doesnt live in an appartment
234123a1 Jane
234123a2 Jones
234123a3 156 east st
234123a4 New York
234123a5 NY


The actual ticketing system is far more complicated than this relatively simple example and has hundreds of controls and dozens of tabs on each page. But this presents a real problem for me because I can never be sure which control has the address in it. Or even how many controls there are. The controls will also often have duplicate text in the lable field. For example there are 4 different "Street" text boxes on the same page (Billing address, Service Address, contact address, previous address) so it's not like I can search for the label and assume that the one with the label I want is correct.

Has anyone ever dealt with this sort of dynamic control naming before? And if so, how did you deal with it?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 12th, 2010, 4:21 pm 
Offline

Joined: May 27th, 2007, 9:41 am
Posts: 4999
How to get a Control's ClassNN by coordinates ?
http://www.autohotkey.com/forum/viewtop ... 4327#94327

_________________
AHK FAQ
TF : Text files & strings lib, TF Forum


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 12th, 2010, 4:27 pm 
Offline

Joined: February 29th, 2008, 8:36 pm
Posts: 901
Location: Vault 7
I've dealt with similar problems before. Try regular expressions to guess at what each value might be, then some more code to verify it. When you look at the data, you can figure out what field is which... right? So your goal will be to write a program to think like you think.

So let's say you are trying to figure out what state a given person lives in. I saw "New York" and, remembering that New York is a state, decided that the person lived in New York. So the way to solve this problem programatically is to keep a list of all the states possible and check each value to see if it is in that list. You can further refine things by adding extra logic for special conditions. Like what if there is a New York Road somewhere!? If two fields look like states, choose the one that matches more closely (the one without "Road" at the end is closer). You could also look for the one that matches with the 2 letter state code if available, though this could conflict with 2 letter names for people. For complex problems, you can easily end up with a long sequence of if/else statements. It is sorta like 20 questions.


As long as the labels are never wrong, you can use them first to get a shorter list of candidates. Will the street address at least always be labeled "street", even though other items might labeled "street" at the same time?

Hopefully that helps? If you need a better example, give me a specific problem (like "What state does this person live in") and I'll throw together some code to demo.


Last edited by Rapte_Of_Suzaku on August 12th, 2010, 4:30 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 12th, 2010, 4:28 pm 
Offline

Joined: February 9th, 2006, 8:01 pm
Posts: 117
hugov wrote:
How to get a Control's ClassNN by coordinates ?
http://www.autohotkey.com/forum/viewtop ... 4327#94327


Sorry that won't help. There are several controls with the same labels.
Also, some of their positions can change if the window is at all re sized. I've actually taken to having AHK resizing the window before executing its scripts.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 12th, 2010, 5:38 pm 
Offline

Joined: February 29th, 2008, 8:36 pm
Posts: 901
Location: Vault 7
Do you have a way to get the control values/labels already, or is that another part of the problem?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 12th, 2010, 8:10 pm 
Offline

Joined: February 9th, 2006, 8:01 pm
Posts: 117
Rapte_Of_Suzaku wrote:
Do you have a way to get the control values/labels already, or is that another part of the problem?


I mean, I can read them all with control spy, or any of the other utilities people have posted on here. Or I can just use controlget myself. But like I said, every time I open a different ticket the control names are totally new. Not even remotely similar to the last one.

If you have a control reading utility you think might provide me with more insight I'd be happy to try it out.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 12th, 2010, 9:00 pm 
Offline

Joined: February 29th, 2008, 8:36 pm
Posts: 901
Location: Vault 7
For just getting all the control info, try WinGet. It has a ControlList command, which will spit out a list of all controls for a given window (in z-order). You can then use ControlGetPos to order the controls correctly (assuming that the maker(s) of the ticketing system probably didn't consider the z-order of their controls).


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: BrandonHotkey, MSN [Bot] and 17 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