AutoHotkey Community

It is currently May 26th, 2012, 11:52 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 12 posts ] 
Author Message
PostPosted: November 11th, 2009, 1:10 am 
Offline

Joined: November 11th, 2009, 12:53 am
Posts: 9
Location: Australia
Hi,
I am trying to run a statistics program hundreds of times (close to 1000) hence I'd like to automate the process.
I can record most of the process using script writer except three things.
1. in the statistics program you have to choose a file to work on from a browser window. i would like to automate it so that you might choose the first file from the browser and then the next time the loop runs it chooses the next file (I have numbered the files 1Filename, 2Filename, 22Filename). Until no more files left - some folders have 80 and some have 120 files in it.

2. Once chosen I would like to copy the filename (without extenstion) i.e. 1Filename into a box the stats program has set asside for Naming that run of the program.

3.Then I need to fill out another box, with a number, that number is contained within the file selected previously, i.e. 1Filename. The number is contained with the line that begins with "/* N" and is the 5 and 6th character.

I can then continue with automated mouse clicks to the end of the loop.

Thank you in advance for any help!

Columbine


Last edited by Columbine on November 25th, 2009, 8:12 am, edited 2 times in total.

Report this post
Top
 Profile  
Reply with quote  
PostPosted: November 11th, 2009, 1:53 am 
Online

Joined: April 8th, 2009, 7:49 pm
Posts: 6068
Location: San Diego, California
Here are links to the commands that do what you want to accomplish.
Quote:
1. in the statistics program you have to choose a file to work on from a browser window. i would like to automate it so that you might choose the first file from the browser and then the next time the loop runs it chooses the next file (I have numbered the files 1Filename, 2Filename, 22Filename). Until no more files left - some folders have 80 and some have 120 files in it.
http://www.autohotkey.com/docs/commands ... ctFile.htm
http://www.autohotkey.com/docs/commands ... Folder.htm
http://www.autohotkey.com/docs/commands/LoopFile.htm

Quote:
2. Once chosen I would like to copy the filename (without extenstion) i.e. 1Filename into a box the stats program has set asside for Naming that run of the program.
http://www.autohotkey.com/docs/commands/SplitPath.htm
http://www.autohotkey.com/docs/commands ... etText.htm

Quote:
3.Then I need to fill out another box, with a number, that number is contained within the file selected previously, i.e. 1Filename. The number is contained with the line that begins with "/* N" and is the 5 and 6th character.
http://www.autohotkey.com/docs/commands ... adFile.htm
http://www.autohotkey.com/docs/commands/IfInString.htm
http://www.autohotkey.com/docs/commands/StringMid.htm

Quote:
I can then continue with automated mouse clicks to the end of the loop.

Thank you in advance for any help!

Columbine


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 11th, 2009, 2:02 am 
Offline

Joined: August 21st, 2006, 7:07 pm
Posts: 2925
Location: The Shell
In a nutshell:
- For the reading of incrementing file names, use a FilePattern Loop.
- You can retrieve and use Split Path to get the file name by itself into a variable.
- Use ControlSetText to insert the name into the 'box(es)'.
- You can (cautiously) use an a_index for the current file name number or use InStr(), or RegExReplace()to extrapolate the number character from the filename.
- If you need to read into the file, I suggest a nested FileReadLine.

hth

_________________
Imageparadigm.shift:=(•_•)┌П┐RTFM||^.*∞


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 11th, 2009, 2:45 am 
Offline

Joined: November 11th, 2009, 12:53 am
Posts: 9
Location: Australia
TLM and Leef_me,

Thank you, these were the commands I had found, but it's so great to have them confirmed. Being new to AHK I'm struggling a little with exactly how they should be written into my script (not understanding all the language). I'll have a bit of a go and see how I fare.

Thanks again.

_________________
Learning on the fly


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Thanks now to excel
PostPosted: November 12th, 2009, 7:12 am 
Offline

Joined: November 11th, 2009, 12:53 am
Posts: 9
Location: Australia
Thanks again,

I was able to create a once through, one problem I'm encountering is that the Stats program doesn't like me using the FileSelectFile to input into it's edit box. It must be doing something in the background with it. (It writes into a dbf file too.

So I am unable to tell the AHK program to loop.

But automating everything except file choice has been time saving.

Next task - Extracting the info from the results (text files) and inputting into excel for analysis.

Anyone have a link to the topics I need to help me get text from a text file into Excel?

Thanks

_________________
Learning on the fly


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 12th, 2009, 9:21 am 
Offline

Joined: November 14th, 2007, 2:47 pm
Posts: 335
Location: London, England
Please post the FileSelectFile part of your code. (And anything around it.)

There is no reason why it shouldnt work.

AHK just stores the filepath as a variable, and doesnt open or operate on it in any way.


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Re: Thanks now to excel
PostPosted: November 12th, 2009, 12:52 pm 
Offline

Joined: August 21st, 2006, 7:07 pm
Posts: 2925
Location: The Shell
Columbine wrote:
Next task - Extracting the info from the results (text files) and inputting into excel for analysis.
Anyone have a link to the topics I need to help me get text from a text file into Excel?
Thanks

I was going to post a few links but then did a quick Google. Got tonnes of links. Do this @ the Googles:
excel site:www.autohotkey.com

;)

_________________
Imageparadigm.shift:=(•_•)┌П┐RTFM||^.*∞


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Excel
PostPosted: November 12th, 2009, 2:58 pm 
Offline

Joined: November 11th, 2009, 12:53 am
Posts: 9
Location: Australia
I'm pretty happy with what I've discovered so far, thanks to everyone. (great forum).

My sticking point now is:
Text File contains a line
"INPUT --- model={p(.) c(.) N(.) PIM};"

and
My script:
Code:
WinActivate, ahk_class Notepad
WinWait, ahk_class Notepad
Loop, Read, %File%,
If A_LoopReadLine contains Model=
ControlSend, XLDESK1, %A_LoopReadLine%, ahk_class XLMAIN
WinActivate, ahk_class XLMAIN
Send {tab}


And the output is INPUT --- model=

So it is missing some part of the line.

Question - Do I at the beginning of the file change all { brackets to something more 'readable' or is there some way to force the issue?

Thanks in advance,

_________________
Learning on the fly


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Re: Thanks now to excel
PostPosted: November 12th, 2009, 3:00 pm 
Offline

Joined: November 11th, 2009, 12:53 am
Posts: 9
Location: Australia
TLM wrote:
I was going to post a few links but then did a quick Google. Got tonnes of links. Do this @ the Googles:
excel site:www.autohotkey.com
;)


Thanks, I also found:
http://www.autohotkey.com/forum/viewtopic.php?t=418&highlight=paste+cell
which has some good tips.

_________________
Learning on the fly


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Re: Excel
PostPosted: November 12th, 2009, 3:16 pm 
Offline
User avatar

Joined: March 19th, 2008, 12:43 am
Posts: 5480
Location: the tunnel(?=light)
Columbine wrote:
Do I at the beginning of the file change all { brackets to something more 'readable' or is there some way to force the issue?


Slightly trickier than it looks...this might work:

Code:
Loop, Read, %File%,
If A_LoopReadLine contains Model=
{
  StringReplace, var, A_LoopReadLine, {, +[, All ; "Shift + [") = {
  StringReplace, var, var, }, +], All
  ControlSend, XLDESK1, %var%, ahk_class XLMAIN
}

WinActivate, ahk_class XLMAIN
Send {tab}


EDIT: Changed A_LoopField to A_LoopReadLine :oops: (thanks Columbine)

_________________
Image
Try Quick Search for Autohotkey or see the tutorial for newbies.


Last edited by sinkfaze on November 12th, 2009, 3:43 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 12th, 2009, 3:39 pm 
Offline

Joined: November 11th, 2009, 12:53 am
Posts: 9
Location: Australia
Sinkfaze,

Thanks for that! It works ( I had to change A_LoopField to A_LoopReadLine). But it works well.

My next task is to loop the main script I wrote.

Thanks again.

_________________
Learning on the fly


Report this post
Top
 Profile  
Reply with quote  
 Post subject: All done and thanks.
PostPosted: November 25th, 2009, 8:12 am 
Offline

Joined: November 11th, 2009, 12:53 am
Posts: 9
Location: Australia
To all who helped me with this query - I have created a few scripts and they are running well - I'll post them here shortly.

_________________
Learning on the fly


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: hyper_, Leef_me, patgenn123, Pulover, rbrtryn, tidbit, XstatyK and 19 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