AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

ALL DONE Loops, Select file, fill form Done including Excel

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Columbine



Joined: 10 Nov 2009
Posts: 9
Location: Australia

PostPosted: Wed Nov 11, 2009 12:10 am    Post subject: ALL DONE Loops, Select file, fill form Done including Excel Reply with quote

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
View user's profile Send private message
Leef_me



Joined: 08 Apr 2009
Posts: 5336
Location: San Diego, California

PostPosted: Wed Nov 11, 2009 12:53 am    Post subject: Re: Loops, Select file, fill form Reply with quote

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/FileSelectFile.htm
http://www.autohotkey.com/docs/commands/FileSelectFolder.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/ControlSetText.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/LoopReadFile.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
Back to top
View user's profile Send private message
TLM



Joined: 21 Aug 2006
Posts: 2926
Location: The Shell

PostPosted: Wed Nov 11, 2009 1:02 am    Post subject: Reply with quote

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
View user's profile Send private message
Columbine



Joined: 10 Nov 2009
Posts: 9
Location: Australia

PostPosted: Wed Nov 11, 2009 1:45 am    Post subject: Reply with quote

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
View user's profile Send private message
Columbine



Joined: 10 Nov 2009
Posts: 9
Location: Australia

PostPosted: Thu Nov 12, 2009 6:12 am    Post subject: Thanks now to excel Reply with quote

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
View user's profile Send private message
doyle



Joined: 14 Nov 2007
Posts: 325
Location: London, England

PostPosted: Thu Nov 12, 2009 8:21 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
TLM



Joined: 21 Aug 2006
Posts: 2926
Location: The Shell

PostPosted: Thu Nov 12, 2009 11:52 am    Post subject: Re: Thanks now to excel Reply with quote

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

Wink
_________________
paradigm.shift:=(•_•)┌П┐RTFM||^.*∞
Back to top
View user's profile Send private message
Columbine



Joined: 10 Nov 2009
Posts: 9
Location: Australia

PostPosted: Thu Nov 12, 2009 1:58 pm    Post subject: Excel Reply with quote

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
View user's profile Send private message
Columbine



Joined: 10 Nov 2009
Posts: 9
Location: Australia

PostPosted: Thu Nov 12, 2009 2:00 pm    Post subject: Re: Thanks now to excel Reply with quote

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
Wink


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
View user's profile Send private message
sinkfaze



Joined: 18 Mar 2008
Posts: 5043
Location: the tunnel(?=light)

PostPosted: Thu Nov 12, 2009 2:16 pm    Post subject: Re: Excel Reply with quote

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 Embarassed (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
View user's profile Send private message Send e-mail
Columbine



Joined: 10 Nov 2009
Posts: 9
Location: Australia

PostPosted: Thu Nov 12, 2009 2:39 pm    Post subject: Reply with quote

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
View user's profile Send private message
Columbine



Joined: 10 Nov 2009
Posts: 9
Location: Australia

PostPosted: Wed Nov 25, 2009 7:12 am    Post subject: All done and thanks. Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group