Thanks very much guys, I'm almost there - but now have a couple of other questions..
I'll try to briefly explain what I'm trying to do and show the code I have so far...
I have a web page with a bunch of audio tracks - each one has an audio player and information regarding the track - like artist name, track title, etc etc.
I need to listen through the tracks, and put together a message with any problems I find. There are about 100 pre typed messages for the various problems, some just need the message, and some need track information added to the message. To further complicate things, sometimes the track info needs to be at the end of the message, and sometimes its in the middle, and also different problems need different bits of information included.
To save me having to keep going back and forth between pages, adding the message after every problem, I want to store all the problems and add them to the message at the end, after I've gone through all the tracks.
I had it working using arrays, so I had about 100 arrays, each time you find a problem, you select the track info and open a gui with a menu of all the problems - you select the right problem, and it adds the info to an array. Then at the end, it searches all the arrays - any that have info in them get added to the message.
It worked - kind of, but it was too slow and unreliable - especially when you have lots of problems.
So now I'm trying to do it with an ini file instead..
So I find a problem, select the track info, select the problem from the gui, and it FileAppends the info to a text file. A separate text file gets created for each problem type, so each time you add a problem, it gets added to its text file. At the same time, the messages for each problem get added to a comp ini file. At the end, it grabs the track info from the text files, and adds them to the comp ini file.. then the comp ini file gets converted to a new text file, which can then be added to the final message box.
Here's the code so far...
So this would be for one of the problems..
;This first bit copies the track info and stores the bits I need as variables:
Code: Select all
Gui, Destroy
sleep, 50
Clipboard := ""
winactivate, ahk_exe chrome.exe
^5
sleep,50
Send, ^c
ClipWait, 2
data1 := clipboard
arr1 := StrSplit(data1, "`n", "`r")
TrackNum := arr1[1]
RegexMatch(data1, "\b\w{5}\d{7}\b", code)
Ctime := arr1[arr1.MaxIndex()]
;Now a Msgbox shows the info to check its copied correctly. If it is, the track info is stored as variable %TrkInfo%, and then added to a text file. Also the message for this problem is added to the comp ini file, and the track info gets added also.
Code: Select all
MsgBox, 262145,Add Action? ,Audio Quality - Track %TrackNum% (%code%).
IfMsgbox cancel
Exit
TrkInfo = Track %TrackNum% (%code%)|
IniRead, Var1, %UAInipath%, AudioQualityAction, Message1
IniRead, Var2, %UAInipath%, AudioQualityAction, Message2
IniRead, Var3, %UAInipath%, AudioQualityAction, Info1
IniRead, Var4, %UAInipath%, AudioQualityAction, Message3
IniWrite, %Var1%, %UACompinipath%, AudioQualityAction, Message1
IniWrite, %Var2%, %UACompinipath%, AudioQualityAction, Message2
IniWrite, %Var3%, %UACompinipath%, AudioQualityAction, Info1
IniWrite, %Var4%, %UACompinipath%, AudioQualityAction, Message3
FileAppend, %TrkInfo%, AudioQuality.txt
FileRead, TrkInfo2, AudioQuality.txt
IniWrite, %TrkInfo2%, %UACompinipath%, AudioQualityAction, Info1
return
; Then at the end, I run this part of the script to add the keys from the comp ini file to a new text file:
Code: Select all
ini := StrReplace(UACompinipath, ".ahk", ".ini")
out = %A_ScriptDir%\out.txt
Loop, Read, %ini%, %out%
FileAppend, % (pos := Instr(A_LoopReadLine, "=")) ? SubStr(A_LoopReadLine, pos + 1) "`n`n" : ""
Run, %out%[/code]
:This is now almost working perfectly.. if I run a couple of problems, the text file I end up with looks like this:
[Codebox=text file=Untitled.txt]Unfortunately, the audio quality for this release is not to a high enough standard. Audio recordings must be mixed, mastered and recorded to a professional level. This includes all components of your track(s). Please upload your tracks again.
This is in reference to the following tracks:
Track 01 (GX4R52297054)|Track 02 (GX4R52297056)|Track 05 (GX4R52297065)|
-------------------------------------
Unfortunately, some of your audio files have failed to upload, meaning that the release has not yet been moderated. We apologise for any delay that this may have caused with your release, please check the files that are missing and re-upload them using our audio upload tool.
This is in reference to:
Track 03 (GX4R52297061)|Track 04 (GX4R52297064)|
All tracks must be uploaded as MP3’s at 320 kbps or FLAC at 1411kbps. Sample rate must be 44.1 khz.`n`nOnce you have uploaded the files again, please check your track numbering as this could now be incorrect.
[STILL AWAITING MODERATION]
-------------------------------------
So the last couple of things I need to figure out are, how can I add line breaks between the track inforamtion? I need them to be added to one key of the comp ini, so cant add the line breaks first, and also the line breaks dont work within the ini file... I've tried adding '|' after each bit of info, as this is where I want to split them ie, Track 01 (GX4R52297054)|Track 02 (GX4R52297056)|Track 05 (GX4R52297065)| should be
Track 01 (GX4R52297054)
Track 02 (GX4R52297056)
Track 05 (GX4R52297065)
I'm not too sure how to do that and have been trying all morning :/ Not sure if it should be done before it gets added to the final text file, or if I should loop parse the text file and do it at the end?
The other thing is, ideally I want the Track numbers in the final message to be in bold type. Before when I used the arrays, I could add the track info like; ^bTrack 01 (GX4R52297054)^b to make it bold.. but now this doesn't work as it adds the ^b into the text file rather than making it bold... is there a way to do that afterwards? Again i'm not sure if it should be done before it gets added to the final text file, or if it can be done at the end?
Sorry for such a long post!
[Mod edit: Changed code boxes with AHK code from .txt format to the default .ahk format.]