I recently tried something similar to this using FindText OCR. The concept seemed the same, but when I actually tried to implement it in TradingView I kept running into brick walls. They're pretty sophisticated and I'm sure they don't like any type of automation being done on their site. For example, in the script you'll see the need for different versions of the same number or month. Also the spacing was a challenge so I took care of that at the end with some formatting. I'm using Brave browser in dark mode. Working in Chrome in dark mode as well. If FindText is unable to detect something in the date/time it will show an asterisk (*) for the missing data. Whatever is missing, just take another captured version of it and add it to the list of text images.
Code: Select all
#requires autohotkey v2
#include <FindText>
q::
{
DateTimeText:="
(
|<'>*114$4.y8bs
|<'>*123$3.wYw
|<:>*126$3.0z0U
|<:>*143$2.zkwDy
|<:>*143$2.z3ks
|<1>*168$3.oKqqo
|<2>*150$5.2nbAtaA4
|<2>*161$4.1ivBYkU
|<2>*147$4.1Cn94kU
|<2>*158$4.7AmNBkU
|<2>*140$5.0HbCNXA4
|<3>*144$5.2nb8wskA
|<3>*138$4.1AmQt0U
|<3>*158$4.7AmQv1U
|<4>*139$6.ttlV990ttU
|<4>*161$4.m89Uvc
|<4>*162$4.vAca3iU
|<5>*162$4.1r1itUU
|<5>*144$4.1r1Al1U
|<6>*160$5.nAsGCQGA
|<6>*160$4.Wr1aNUU
|<7>*146$5.1nCQnaQw
|<7>*143$4.3AaFArU
|<7>*141$5.1naAtbCQ
|<8>*189$5.WEoMiQuA
|<8>*170$4.1a06NUU
|<9>*166$5.WNlcQlaQ
|<9>*156$4.1aMCm8
|<9>*145$5.2FV0Ql6Q
|<0>*143$6.VYAAAAA4VU
|<0>*165$5.UFnbCAGA
|<Mon>*143$22.rDzzAzzsnzzWAA68aH88NAUVYkm6H393AU
|<Tue>*142$19.0DzwzzyTzz9a7YkNmM0tA7wW3yMAA
|<Wed>*143$23.CtztAnzmFDzYWMM80a6MW0Al4yNbAwniQA4
|<Thu>*141$19.07ztnzwtzyQ4nCMNbAAna6Nn1AtY4
|<Fri>*139$13.0y7z3zts04MSQDC7b3nY
|<Sat>*152$16.D32DYyEHs9BVYkk8U
|<Sun>*151$18.DA0XAAtAAsAAN8A30AU
|<Jan>*150$17.t31nmPY4r39W4H1UaU
|<Feb>*155$18.TV13AAS0CSTCTDATV1U
|<Feb>*148$18.DVU1AaD06DDaDDaDUUU
|<Mar>*161$16.AkkFt464HGFANCo4U
|<Mar>*166$18.4MM4TNFMPF3PP2/P8/U
|<Apr>*163$15.VUpgmAaE4mS6Hk6U
|<Apr>*160$15.X1V9Y9CU9oQAbkAU
|<May>*161$19.Akb2D9464WOHJANXqUvU
|<May>*148$20.4MH17mE4UY13AKEX5Y0nU
|<May>*160$19.4MH2DdYK6m8P1g8mqENU
|<Jun>*158$18.tAUtAgtAgtAg9AgXUgU
|<Jun>*151$18.sN0sNAsNAsNA89A31AU
|<Jul>*145$14.tACH3YktA2H0A2U
|<Jul>*158$14.sNC6HVYsN6qEA6U
|<Aug>*164$18.VaEZa6ga60aEC6LSEEU
|<Aug>*180$18.fik9igRig1ilQgjyUUU
|<Sep>*164$17.D30Amn05r7vYbq3VVU
|<Sep>*147$17.D114mPU0r3ta3n1UUU
|<Oct>*147$17.SEUwAZsT/kyH9YksMU
|<Nov>*158$17.4kaVABWt35m79aE
|<Nov>*166$18.6kb2aK8bGAbMCaNU
|<Dec>*150$18.CEsC6HC07A7b8bn1kkU
|<Dec>*151$18.QkkQ66Q07QDbNba3kkU
)"
Text:="|<tv_upper_left_time_region>363A45-101010$7.zzzzzzzzk"
if (ok:=FindText(&X:="wait", &Y:=-1, 49, 936, 1809, 973, 0, 0, Text,, 0))
x1 := ok[1].1
y1 := ok[1].2
x2 := x1+131
y2 := y1+21
if (ok := FindText(&X, &Y, x1, y1, x2, y2, .1, .1, DateTimeText))
Result := FindText().OCR(ok)
inputDateTime:=result.text
formatDateTime(dateTime) {
if (RegExMatch(dateTime, "\d{2}:\d{2}$")) {
formattedDateTime := SubStr(dateTime, 1, 3) . " " . SubStr(dateTime, 4, 2) . " " . SubStr(dateTime, 6, 3) . " " . SubStr(dateTime, 9, 3) . " " . SubStr(dateTime, 12)
} else {
formattedDateTime := SubStr(dateTime, 1, 3) . " " . SubStr(dateTime, 4, 2) . " " . SubStr(dateTime, 6, 3) . " " . SubStr(dateTime, 9)
}
return formattedDateTime
}
formattedDateTime := formatDateTime(inputDateTime)
a_clipboard:= formattedDateTime
MsgBox "Formatted DateTime: " formattedDateTime
}