| View previous topic :: View next topic |
| Author |
Message |
Columbine
Joined: 10 Nov 2009 Posts: 9 Location: Australia
|
Posted: Wed Nov 11, 2009 12:10 am Post subject: ALL DONE Loops, Select file, fill form Done including Excel |
|
|
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 Wed Nov 25, 2009 7:12 am; edited 2 times in total |
|
| Back to top |
|
 |
Leef_me
Joined: 08 Apr 2009 Posts: 5336 Location: San Diego, California
|
|
| Back to top |
|
 |
TLM
Joined: 21 Aug 2006 Posts: 2926 Location: The Shell
|
Posted: Wed Nov 11, 2009 1:02 am Post subject: |
|
|
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 _________________
paradigm.shift:=(•_•)┌П┐RTFM||^.*∞ |
|
| Back to top |
|
 |
Columbine
Joined: 10 Nov 2009 Posts: 9 Location: Australia
|
Posted: Wed Nov 11, 2009 1:45 am Post subject: |
|
|
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 |
|
| Back to top |
|
 |
Columbine
Joined: 10 Nov 2009 Posts: 9 Location: Australia
|
Posted: Thu Nov 12, 2009 6:12 am Post subject: Thanks now to excel |
|
|
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 |
|
| Back to top |
|
 |
doyle
Joined: 14 Nov 2007 Posts: 325 Location: London, England
|
Posted: Thu Nov 12, 2009 8:21 am Post subject: |
|
|
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. |
|
| Back to top |
|
 |
TLM
Joined: 21 Aug 2006 Posts: 2926 Location: The Shell
|
Posted: Thu Nov 12, 2009 11:52 am Post subject: Re: Thanks now to excel |
|
|
| 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
 _________________
paradigm.shift:=(•_•)┌П┐RTFM||^.*∞ |
|
| Back to top |
|
 |
Columbine
Joined: 10 Nov 2009 Posts: 9 Location: Australia
|
Posted: Thu Nov 12, 2009 1:58 pm Post subject: Excel |
|
|
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 |
|
| Back to top |
|
 |
Columbine
Joined: 10 Nov 2009 Posts: 9 Location: Australia
|
Posted: Thu Nov 12, 2009 2:00 pm Post subject: Re: Thanks now to excel |
|
|
| 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 |
|
| Back to top |
|
 |
sinkfaze
Joined: 18 Mar 2008 Posts: 5043 Location: the tunnel(?=light)
|
Posted: Thu Nov 12, 2009 2:16 pm Post subject: Re: Excel |
|
|
| 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 (thanks Columbine) _________________ Try Quick Search for Autohotkey or see the tutorial for newbies.
Last edited by sinkfaze on Thu Nov 12, 2009 2:43 pm; edited 1 time in total |
|
| Back to top |
|
 |
Columbine
Joined: 10 Nov 2009 Posts: 9 Location: Australia
|
Posted: Thu Nov 12, 2009 2:39 pm Post subject: |
|
|
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 |
|
| Back to top |
|
 |
Columbine
Joined: 10 Nov 2009 Posts: 9 Location: Australia
|
Posted: Wed Nov 25, 2009 7:12 am Post subject: All done and thanks. |
|
|
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 |
|
| Back to top |
|
 |
|