I have a web page in chrome with a bunch of audio tracks. Each one has several pieces of information I need to copy and store as variables to be pasted back into a separate page.
So far, I have the first bit working... You can select one of the pieces of text for one of the audio tracks.. in this case I'm using the ISRC code. When I run the script, it will copy the ISCR code and store it as a variable (%isrc%). Then it will select all the text on the page and copy it to the clipboard, and then store this as another variable (%page%).
So far so good..
Now I want to parse the variable (%page%) to find the ISRC code, then from there I want to get the line which is 8 lines above the ISRC code, and store that as a variable (%TrackNumber%), and also the line which is 8 lines below the ISRC code, and save that as another variable (%TimeStamp%). Which ever ISRC I select, the track number is always 8 lines above the ISRC, and the timestamp is always 8 lines after it.
I have it working so it searches the variable (%page%), and finds the correct ISRC code, but I'm not sure how to then get it to find the text 8 lines above and below it and to store them as variables? This is the code I have so far..
Code: Select all
^+y::
Clipboard := ""
winactivate, ahk_exe chrome.exe
Send, ^c
ClipWait, 2
isrc := clipboard
msgbox ISRC: %isrc%
Clipboard := ""
winactivate, ahk_exe chrome.exe
sleep, 200
Send, {CTRLDOWN}ac{CTRLUP}
ClipWait, 2
page := clipboard
Loop , parse , page , `n
{
line := A_LoopField
if line contains %isrc% ; now the right line has been found, parse that line
{
StringGetPos, OutputVar, line, %A_Tab% , R ; find the first space from the right
outputvar += 1 ; to get rid of the A_Tab
StringTrimLeft, CODE, line, OutputVar ; trims everything but the isrc code
break ; we don't need to parse anything else
}
}
msgbox Found: "%CODE%"
return
ESC::ExitApp
01 ; this is the track number I want to save as variable %TrackNumber% (8 lines above the ISCR including blank lines)
Song Title ; I don't need this
Artist Name ; I don't need this
✎
Spotify link ; I don't need this
Primary ; I don't need this
GX4R52290977 ; this is the ISRC code
Good
View Luna Audio Report
Not Explicit
00:03:28 ; This is the time stamp I want to save as variable %TimeStamp% (8 lines below the ISCR including blank lines)
Edit - Upon further tests I've found that the other bits I need are not always 8 lines above or below, its sometimes 7 or 9.. so I may need to re-think.
Any help is very much appreciated, thanks in advance!