... Anregungen und Tipps sind sehr willkommen
Code: Select all
SetTimer,UPDATEDSCRIPT,500
ANow := A_Now
If !FileExist(A_ScriptDir "\save\")
FileCreateDir,% A_ScriptDir "\save\"
FileCopy, % A_ScriptFullPath, % A_ScriptDir "\save\" A_ScriptName " save " A_Now " .ahk"
;setTimer, TimerMAINGui, -3000
;21 Kryptokurse von der BSDEX Internetseite parsen Persönlich Microsoft Edge
;https://www.autohotkey.com/boards/viewtopic.php?f=9&t=118808
#NoEnv
#SingleInstance,Force
SetBatchLines, -1
; Große GUI: Maus Click auf "ColClick" erzeugt GUI
; Maus Click auf ListView offnet MsgBox
; Rechte Maus Taste auf ListView exportiert ListView in CSV Datei
; Option ExportierenMitPunktOderKomma
ListViewWidth := 900
spaltenTitelEXPORTIEREN := 0 ; RMouse auf "TimeLine Gui" exportiert ListView in name.csv
ExportierenMitPunktOderKomma := 0 ; true = punkt -
; Excel benötigt zum rechnen das Komma, AHK rechnet mit Punkt
ShowGuiSTATISTIK := 1 ; true = Gui Show
ShowGuiMAIN := 1 ; true = Gui Show
ShowToday := 0 ; nur aktuellen tag im listview anzeigen
ShowYesterday := 1 ; nur wenn [ShowToday] = true, aktuellen und gestrigen tag im listview anzeigen
global showBreite := 0 ; spaltenTitel in der GUI jeweils durch spaltenbreite ersetzen für Test
thisStart := true
Gui, STATISTIK: Add, Listview, r20 w%ListViewWidth% Grid vSTATS ggLabelSTATISTIKListView AltSubmit NoSort, A|B|C|D|E|F|G|H|I|J|K|L
; Gui, STATISTIK: Show,, Kryptokurse BSDEX TimeLine
Gui, STATISTIK: Show, x100 y1, Kryptokurse BSDEX TimeLine
if !ShowGuiSTATISTIK
Gui, STATISTIK: Show, hide
thisStart:
Url := "https://widgets.bsdex.de/de/markets/?hide_cta=1&range=24H" ;Versteckte Url
; Url := "https://app.bsdex.de/signin"
Doc := ""
try Doc := DocumentFromHTML(UrlDownloadToVar(Url))
if !isObject(Doc)
{
random, rand,% (.1*1000*60),% (.3*1000*60) ; 6 bis 18 sekunden
sleep,% rand
goto thisStart
}
dok := doc
;msgbox % isObject(Dok)
Namen := Doc.getElementsByClassName("styled__AssetName-sc-1posrgm-2")
Shorts := Doc.getElementsByClassName("styled__AssetShort-sc-1posrgm-1")
Werte := Doc.getElementsByClassName("styled__Price-sc-dgnucy-7")
Dif24 := Doc.getElementsByClassName("styled__Change-sc-h922kl-1")
Anz := Namen.length
AnzDif24 := Dif24.length
Rows := Min(AnzDif24, Anz)
; msgbox % Rows "`t" AnzDif24 "`nShorts:`t" Shorts.length
test := 0
if test
{
res =
loop % Anz
res .= Shorts[a_index-1].innerText "`n"
StringUpper,res,res
if res
Msgbox,,% "a_lineNumber: `t" a_lineNumber, % res ,4
}
if thisStart { ; wird nur einmal gestartet
Gui, MAIN: Add, Listview, w%ListViewWidth% r%Rows% Grid vLV, Name|Short|Preis €|Änderung 24h `%|MIN( thisCoin )|Datum|MAX( thisCoin )|Datum|Tage
Gui, MAIN: Show, x100 y410, Kryptokurse BSDEX
if !ShowGuiMAIN
Gui, MAIN: Show, hide
thisStart := false
thisStart#2 := true
}
Gui, MAIN: Default
Gui, MAIN: Listview, LV
CoinsListe := ""
STATISTIK := ""
CoinNameALL =
I1 := I2 := 0
While (I1 < Anz) {
CoinName := Namen[I1].innerText
Short := Shorts[I1].innerText
CoinWert := RTrim(Werte[I1].innerText, " €")
CoinDiff := RTrim(Dif24[I2].innerText, " %")
; stringreplace,CoinWert,CoinWert,`.,`',all
stringreplace,CoinWert,CoinWert,`.,,all
stringreplace,CoinWert,CoinWert,`,,`.,all
stringreplace,CoinDiff,CoinDiff,`,,`.,all
StringUpper, Short, Short
; CoinsListe .= CoinName "`t" Short "`t" CoinWert "`t" CoinDiff "`n"
; CoinsListe.= Name "`t" Short "`t" Preis € "`t" Änderung 24h `% "`t" MIN( thisCoin ) "`t" Datum "`t" MAX( thisCoin ) "`t" Datum "`t" Tage "`n"
STATISTIK .= CoinWert "`t"
spaltenTitel .= CoinName "`t"
I1 += 1
I2 += 2
I3 += 3
}
Gui, STATISTIK: Default
Gui, STATISTIK: Listview, STATS
if thisStart#2 { ; wird nur einmal gestartet ; listView History laden
spaltenTitelARR := strSplit(spaltenTitel,"`t")
LV_ModifyCol(1,,"TimeStamp")
for aindex, sp in spaltenTitelARR {
LV_ModifyCol(aindex+1,,spaltenTitelARR[aindex])
x := strReplace(spaltenTitelARR[aindex],a_space,"_")
if x
%x% := []
}
datum := []
mutad := []
/*
#NoEnv
HTML := {0x00FFFF: "AQUA", 0x000000: "BLACK", 0x0000FF: "BLUE", 0xFF00FF: "FUCHSIA", 0x808080: "GRAY", 0x008000: "GREEN"
, 0x00FF00: "LIME", 0x800000: "MAROON", 0x000080: "NAVY", 0x808000: "OLIVE", 0x800080: "PURPLE", 0xFF0000: "RED"
, 0xC0C0C0: "SILVER", 0x008080: "TEAL", 0xFFFFFF: "WHITE", 0xFFFF00: "YELLOW"}
FarbWert := 0xC0C0C0
If HTML.HasKey(FarbWert)
FarbName := HTML[FarbWert]
Else
FarbName := "Ham wa nich!"
MsgBox, 0, RGB %FarbWert%, Name: %FarbName%
*/
SplashTextOn,,,Load...
fileRead, thisReload,% a_scriptdir "\BSDEX.csv"
ReloadARR := strSplit(thisReload,"`n")
GuiControl, -ReDraw, STATS
for i, this in ReloadARR {
thisSplit := strSplit(this,"`t",a_space)
;coin
for aindex, thisValue in thisSplit {
if thisValue {
thisCoin := strReplace(spaltenTitelARR[aindex],a_space,"_")
thisValue := thisSplit[aindex+1]
stringreplace,thisValue,thisValue,`',,all
stringreplace,thisValue,thisValue,`,,`.,all
%thisCoin%.push(thisValue)
; Datum[%thisCoin%].push(thisSplit.1)
; Datum[thisSplit.5] := thisSplit.1
Datum[thisValue] := thisSplit.1
mutad[thisSplit.1] := thisValue
; Datum[thisSplit.5] := thisCoin "`t" thisSplit.1
; Datum[thisSplit.1] := %thisCoin%[thisSplit.1]
; Datum[thisCoin,thisValue,thisSplit.1] := %thisCoin%[thisSplit.2]
; DatumB[thisCoin] := thisSplit.1
; das hier macht noch nicht viel sinn :)
; (x := Datum.bitcoin.hashkey("01.07.2023 00:01:59"))
;msgbox % datum.length()
}}
if thisSplit.4
{
toDay := strSplit(thisSplit.1,[".", a_space])
; msgBox % toDay.1 "`n" toDay.2 "`n" toDay.3
if ShowToday
{
if ShowYesterday
ADD := A_DD
if ((LTRIM(ADD,"0")-1=LTRIM(toDay.1,"0")) ; gestern
|| (A_DD=toDay.1)) ; heute
&& (A_MM=toDay.2)
&& (A_YYYY=toDay.3)
LV_Modify(LV_Add("", thisSplit*), "Vis")
}else{
LV_Modify(LV_Add("", thisSplit*), "Vis")
}
}else
fileAppend, % thisSplit.1 "`n", BSDEX_error.txt
}
Loop % AnzDif24
LV_ModifyCol(A_Index, "AutoHdr")
GuiControl, +ReDraw, STATS
thisStart#2 := false
SplashTextOff
}
;STATISTIK
if !(lastStat=STATISTIK)
{
GuiControl, -ReDraw, STATS
thisStat := STATISTIK
statsSplit := strSplit(STATISTIK,"`t")
anow := A_DD "." A_MM "." A_YYYY a_space a_space A_Hour ":" A_Min ":" A_Sec ; ":" A_MSec
if statsSplit {
lastStat := thisStat
fileRead, BSDEXVar,% a_scriptdir "\BSDEX.csv" ; bei reload überprüfen ob der eintrag schon vorhanden ist
BSDEXarr := strSplit(BSDEXVar,"`n")
a_LastLine := BSDEXarr[BSDEXarr.length()-1] ; letzte zeile
if a_lastline not contains %STATISTIK%
{
fileAppend,% anow "`t" STATISTIK "`n",% a_scriptdir "\BSDEX.csv"
if statsSplit.3
{
LV_Modify(LV_Add("", anow, statsSplit*), "Vis")
;coin
for aindex, thisValue in statsSplit {
if thisValue {
thisCoin := strReplace(spaltenTitelARR[aindex],a_space,"_")
thisValue := statsSplit[aindex]
stringreplace,thisValue,thisValue,`',,all
stringreplace,thisValue,thisValue,`,,`.,all
%thisCoin%.push(thisValue)
}}}
Loop % AnzDif24
LV_ModifyCol(A_Index, "AutoHdr")
thisBSDEX := strSplit(a_LastLine,"`t",,2) ; TimeStamp entfernten
;msgbox,,, % a_LastLine "`n`n" thisBSDEX.2 "`n`n" STATISTIK "`n`n" thisSplit.1 ,10
}}
columnsWidthsPlusX(2)
GuiControl, +ReDraw, STATS
thisTimerMAINGui := true
}
Namen := ""
Werte := ""
Dif24 := ""
Doc := ""
debugRes := ""
MainCounter++
; toolTip % MainCounter
;msgbox,,% a_linenumber, % bitcoin[1]
if thisTimerMAINGui
{
setTimer, TimerMAINGui, -1
thisTimerMAINGui := 0
}
random, rand,% (.1*1000*60),% (.3*1000*60) ; 6 bis 18 sekunden
sleep,% rand
goto thisStart
Return
GuiClose:
return
ExitApp
;########################################################################################################################################################################
;########################################################################################################################################################################
TimerMAINGui:
doc := dok
; dok := doc
Namen := doc.getElementsByClassName("styled__AssetName-sc-1posrgm-2")
Shorts := doc.getElementsByClassName("styled__AssetShort-sc-1posrgm-1")
Werte := doc.getElementsByClassName("styled__Price-sc-dgnucy-7")
Dif24 := doc.getElementsByClassName("styled__Change-sc-h922kl-1")
Anz := Namen.length
AnzDif24 := Dif24.length
Rows := Min(AnzDif24, Anz)+1
; msgbox % Rows "`t" AnzDif24 "`nShorts:`t" Shorts.length
CoinNameALL =
Gui, MAIN: Default
Gui, MAIN: Listview, LV
LVAdd := ""
; CoinsListe:= ""
STATISTIK := ""
CoinNameALL =
; spaltenTitel := ""
I1 := I2 := 0
While (I1 < Anz) {
CoinName := Namen[I1].innerText
Short := Shorts[I1].innerText
CoinWert := RTrim(Werte[I1].innerText, " €")
CoinDiff := RTrim(Dif24[I2].innerText, " %")
stringreplace,CoinWert,CoinWert,`.,`',all
stringreplace,CoinWert,CoinWert,`,,`.,all
stringreplace,CoinDiff,CoinDiff,`,,`.,all
StringUpper, Short, Short
; CoinsListe.= CoinName "`t" Short "`t" CoinWert "`t" CoinDiff "`r`n"
STATISTIK .= CoinWert "`t"
spaltenTitel .= CoinName "`t"
;msgbox % datum.maxindex()
thisCoin := StrReplace(CoinName,a_space,"_")
;if !inStr(CoinNameALL,CoinName "|")
;date := (round(max(%thisCoin%*),3))
; (x := Datum.hashkey("27949,44"))
;Datum[thisValue] := thisSplit.1
;mutad[thisSplit.1] := thisValue
If datum.HasKey(CoinWert)
thisDate := datum[CoinWert]
If datum.HasKey(thisDate)
xthisCoinWert := datum[thisDate]
LVAdd .= CoinName "`t" Short "`t" CoinWert "`t" CoinDiff "`t" (round(min(%thisCoin%*),3)) "`t" thisDate "`t" (round(max(%thisCoin%*),3)) "`t" thisDate "`t" xthisCoinWert "`n" ;ROUND((%thisCoin%.length())/10/10) "`n"
; MeinArray.HasKey("Schlüssel")
;CoinNameALL .= CoinName "|"
I1 += 1
I2 += 2
I3 += 3
}
/*
#NoEnv
HTML := {0x00FFFF: "AQUA", 0x000000: "BLACK", 0x0000FF: "BLUE", 0xFF00FF: "FUCHSIA", 0x808080: "GRAY", 0x008000: "GREEN"
, 0x00FF00: "LIME", 0x800000: "MAROON", 0x000080: "NAVY", 0x808000: "OLIVE", 0x800080: "PURPLE", 0xFF0000: "RED"
, 0xC0C0C0: "SILVER", 0x008080: "TEAL", 0xFFFFFF: "WHITE", 0xFFFF00: "YELLOW"}
FarbWert := 0xC0C0C0
If HTML.HasKey(FarbWert)
FarbName := HTML[FarbWert]
Else
FarbName := "Ham wa nich!"
MsgBox, 0, RGB %FarbWert%, Name: %FarbName%
*/
Gui, MAIN: Default
Gui, MAIN: Listview, LV
GuiControl, -ReDraw, LV
LV_Delete()
CoinNameALL =
for i, thisAdd in strSplit(LVADD,"`n") {
LVADDs := strSplit(thisAdd,"`t")
if LVADDs.1
LV_Add("", LVADDs*)
}
STATISTIKOLD := STATISTIK
Loop 4
LV_ModifyCol(A_Index, "AutoHdr")
; MsgBox, % RTrim(CoinsListe, "`r`n")
columnsWidthsPlusX(1)
GuiControl, +ReDraw, LV
random, rand,% (.1*1000*60),% (.5*1000*60) ; 6 bis 18 sekunden
;setTimer, TimerMAINGui,% rand
return
;###################################################################################################################################
; beautify ListView
columnsWidthsPlusX(auswahl) {
Gui +LastFound
if (auswahl=1)
{
Gui, MAIN: Default
Gui, MAIN: Listview, LV
GuiControl, -ReDraw, LV
Loop % LV_GetCount("Column")
LV_ModifyCol(A_Index, "AutoHdr")
Loop % LV_GetCount("Column")
{
SendMessage, 0x101D, A_Index - 1, 0, SysListView321 ; 0x101D ist LVM_GETCOLUMNWIDTH.
thisErrorLevel := ErrorLevel
if (a_index=1) {
SB := (thisErrorLevel + 27)
LV_ModifyCol(a_index,SB)
if showBreite
LV_ModifyCol(a_index,,SB)
}else{
SB := (thisErrorLevel + 10)
LV_ModifyCol(a_index,SB)
if showBreite
LV_ModifyCol(a_index,,SB)
}
; LV_ModifyCol(10,"AutoHdr")
LV_ModifyCol(9,"AutoHdr")
}
GuiControl, +ReDraw, LV
}
if (auswahl=2)
{
Gui, STATISTIK: Default
Gui, STATISTIK: Listview, STATS
GuiControl, -ReDraw, STATS
Loop % LV_GetCount("Column")
{
SendMessage, 0x101D, A_Index - 1, 0, SysListView321 ; 0x101D ist LVM_GETCOLUMNWIDTH.
thisErrorLevel := ErrorLevel
if (a_index=1) {
SB := (thisErrorLevel + 35)
LV_ModifyCol(a_index,SB)
if showBreite
LV_ModifyCol(a_index,,SB)
}else{
SB := (thisErrorLevel + 17)
LV_ModifyCol(a_index,SB)
if showBreite
LV_ModifyCol(a_index,,SB)
}
LV_ModifyCol(11,"AutoHdr")
LV_ModifyCol(12,"AutoHdr")
}
; Loop % LV_GetCount("Column")
; LV_ModifyCol(A_Index, "AutoHdr")
GuiControl, +ReDraw, STATS
}
if (auswahl=3)
{
; Gui, STATISTIK: Default
; Gui, STATISTIK: Listview, STATS
GuiControl, -ReDraw, STATS
Loop % LV_GetCount("Column")
LV_ModifyCol(A_Index, "AutoHdr")
Loop % LV_GetCount("Column")
{
SendMessage, 0x101D, A_Index - 1, 0, SysListView321 ; 0x101D ist LVM_GETCOLUMNWIDTH.
thisErrorLevel := ErrorLevel
if (a_index=1) {
SB := (thisErrorLevel + 30)
LV_ModifyCol(a_index,SB)
if showBreite
LV_ModifyCol(a_index,,SB)
}else{
SB := (thisErrorLevel + 5)
LV_ModifyCol(a_index,SB)
if showBreite
LV_ModifyCol(a_index,,SB)
}
LV_ModifyCol(2,"AutoHdr")
}
GuiControl, +ReDraw, STATS
}
}
gLabelSTATISTIKListView:
Gui, STATISTIK: Default
Gui, STATISTIK: Listview, STATS
; if (A_GuiEvent = "DoubleClick")
; if (A_GuiEvent = "R")
if (A_GuiEvent = "Normal")
; if (A_GuiEvent = "RightClick")
{
LV_GetText(TimeStamp, A_EventInfo, 1) ; Text des ersten Feldes abrufen.
loop, % Anz
LV_GetText(coin%a_index%, A_EventInfo, a_index+1)
clipBoard := "Zeile:`t" A_EventInfo "`n" timeStamp "`n`n"
loop, % Anz
clipBoard .= spaltenTitelARR[a_index] "`t" coin%a_index% "`n"
MsgBox,4096,Kryptokurse BSDEX, % clipBoard,
}
if (A_GuiEvent = "RightClick")
{
gosub EXPORT
}
if (A_GuiEvent = "ColClick")
{
res := ((A_EventInfo=1) ? "" : (A_GuiEvent "`n" (spaltenTitelARR[A_EventInfo-1])))
if (A_EventInfo=1) ; TimeStamp click ignorieren
return
thisCoin := strReplace((spaltenTitelARR[A_EventInfo-1]),a_space,"_")
thisClick := "thisCoin:`t" strReplace(thisCoin,"_",a_space) "`n"
. "MaxINDEX:`t" %thisCoin%[%thisCoin%.MAXIndex()] "`n"
. "MinINDEX:`t" %thisCoin%[%thisCoin%.MINIndex()] "`n"
. "min(" thisCoin "):`t" round(min(%thisCoin%*),3) "`n"
. "max(" thisCoin "):`t" round(max(%thisCoin%*),3) "`n"
. thisCoin ".Length():`t" %thisCoin%.length()
thisGUI := "A" a_tickCount "A"
Gui, %thisGUI%: Add, Listview, r6 vTMPLV%thisGUI% NoSort, Name|Wert
Gui, %thisGUI%: default
Gui, %thisGUI%: +AlwaysOnTop
stringreplace,CoinWert,CoinWert,`.,,all
stringreplace,CoinWert,CoinWert,`,,`.,all
lv_ADD("", "thisCoin", strReplace(thisCoin,"_",a_space))
lv_ADD("", "MaxINDEX", %thisCoin%[%thisCoin%.MAXIndex()])
lv_ADD("", "MinINDEX", %thisCoin%[%thisCoin%.MINIndex()])
;msgbox % thisTMPcoin := "2" %thisCoin%[%thisCoin%.length()]
lv_ADD("", "min(" thisCoin ")", round(min(%thisCoin%*),3))
lv_ADD("", "max(" thisCoin ")", round(max(%thisCoin%*),3))
%thisCoin%length := %thisCoin%.length()
lv_ADD("", thisCoin ".Length()", %thisCoin%length)
Loop % LV_GetCount("Column")
LV_ModifyCol(A_Index, "AutoHdr")
columnsWidthsPlusX(3)
Gui, %thisGUI%: Show,,% "ColClick: " thisCoin
; MsgBox,,, % (spaltenTitelARR[A_EventInfo-1]) "`n" Bitcoin[Bitcoin.MAXIndex()],2
; MsgBox,,, % (A_EventInfo=1) ? "" : (res),1
; MsgBox,,, % Solana.Length(),1
; MsgBox,,, % Solana.MinIndex(),1
; MsgBox,,, % Solana.MAXIndex(),1
; MsgBox,,, % Solana[Solana.MINIndex()]
}
return
;----------------------------------------------------------------------------------------
EXPORT:
anow := A_DD "." A_MM "." A_YYYY "_" A_Hour "-" A_Min "-" A_Sec ; ":" A_MSec
Filename := a_scriptDir "\" anow " BSDEX_EXPORT.csv"
oFile := FileOpen(FileName, "w") ; Creates a new file, overwriting any existing file.
If (!IsObject(oFile)) { ; make sure the file opened and exit if it didn't
Msgbox 0x40000,, % "Can't create "FileName " for writing.!!!"
ExitApp
}
if spaltenTitelEXPORTIEREN
oFile.WriteLine("TimeStamp`t" RTRIM(spaltenTitel,"`t"))
Gui, STATISTIK: Default
Gui, STATISTIK: Listview, STATS
Loop % LV_GetCount() {
LV_GetText(oCol1, A_index, 1)
LV_GetText(oCol2, A_index, 2)
LV_GetText(oCol3, A_index, 3)
LV_GetText(oCol4, A_index, 4)
LV_GetText(oCol5, A_index, 5)
LV_GetText(oCol6, A_index, 6)
LV_GetText(oCol7, A_index, 7)
LV_GetText(oCol8, A_index, 8)
LV_GetText(oCol9, A_index, 9)
LV_GetText(oCol10, A_index, 10)
LV_GetText(oCol11, A_index, 11)
oLine := oCol2 "`t" oCol3 "`t" oCol4 "`t" oCol5 "`t" oCol6 "`t" oCol7 "`t" oCol8 "`t" oCol9 "`t" oCol10 "`t" oCol11 "`t"
stringreplace,oLine,oLine,`',,all
if ExportierenMitPunktOderKomma
stringreplace,oLine,oLine,`,,`.,all
else
stringreplace,oLine,oLine,`.,`,,all
stringreplace,oCol1,oCol1,`,,`.,all
oLine := oCol1 "`t" oLine
DOPPELTESUCHE := oCol2 "`t" oCol3 "`t" oCol4 "`t" oCol5 "`t" oCol6 "`t" oCol7 "`t" oCol8 "`t" oCol9 "`t" oCol10 "`t" oCol11 "`t"
oLine := RTRIM(oLine,"`t")
if !(DOPPELTESUCHEold=DOPPELTESUCHE)
oFile.WriteLine(oLine)
DOPPELTESUCHEold := DOPPELTESUCHE
}
oFile.Close()
oFile:=""
oLine:=""
try run % Filename
;Msgbox 0x40000,, % "File " Filename " exported"
Return
;----------------------------------------------------------------------------------------
URLDownloadToVar(Url){
Local HTTP
HTTP := ComObjCreate("WinHttp.WinHttpRequest.5.1")
HTTP.Open("GET", Url)
HTTP.Send()
Return HTTP.ResponseText
}
DocumentFromHTML(HTML) {
Local Doc
Doc := ComObjCreate("htmlfile")
Doc.write("<meta http-equiv=""X-UA-Compatible"" content=""IE=9"">")
Doc.write(HTML)
Return Doc
}
UPDATEDSCRIPT:
FileGetAttrib,attribs,%A_ScriptFullPath%
IfInString,attribs,A
{
FileSetAttrib,-A,%A_ScriptFullPath%
SplashTextOn,,,Updated script,
Sleep,1500
Reload
}
;SetTimer,UPDATEDSCRIPT,500