Welches Forum? PHP Anfrage an www.autohotkey.com Topic is solved

Stelle Fragen zur Programmierung mit Autohotkey

Moderator: jNizM

Rohwedder
Posts: 7551
Joined: 04 Jun 2014, 08:33
Location: Germany

Welches Forum? PHP Anfrage an www.autohotkey.com

Post by Rohwedder » 31 May 2023, 02:01

Hallo,
dieser ständige Wechsel zwischen AutoHotkey v1.1 und v2 macht mich noch ganz kirre!
Ich möchte am Browserstyle sofort erkennen um welchen Dialekt es sich gerade handelt.
Bei Urls wie:
viewtopic.php?f=82&p=524124
viewtopic.php?f=82&t=117967
weiß mein Autohotkey-Skript anhand der Forumsnummer 82 sofort, daß es sich um v2 handelt und aktiviert meinen V2-Style.
(v1.1: 6,7,19,76,93 / v2: 4,13,14,37,82,83,94,96)
Mein Problem sind Urls ohne Forumsnummer wie:
viewtopic.php?p=524124
viewtopic.php?t=117967
Wie kommt man da per Autohotkey-Skript am besten an die Forumsnummer? Irgendwie was mit PHP?

KHA
Posts: 401
Joined: 21 Aug 2018, 11:11

Re: Welches Forum? PHP Anfrage an www.autohotkey.com  Topic is solved

Post by KHA » 31 May 2023, 14:40

Ich bin mir nicht sicher, ob ich dich richtig verstehe, aber meinst du vielleicht so etwas?

Code: Select all

#NoEnv
#Singleinstance Force

Url := "https://www.autohotkey.com/boards/viewtopic.php?p=524124"

Doc := DocumentFromHTML(URLDownloadToVar(Url))

	If InStr(Brotkruemelnavigation := Doc.getElementById("nav-breadcrumbs").getElementsByClassName("crumb")[3].innerText, "V2")
	   MsgBox, ist version 2
	Else If InStr(Brotkruemelnavigation, "V1")
	   MsgBox, ist version 1
	Else
	   MsgBox, Konnte nicht ermittelt werden



DocumentFromHTML(HTML) {
   Local
   Doc := ComObjCreate("htmlfile")
   Doc.write("<meta http-equiv=""X-UA-Compatible"" content=""IE=9"">")
   Doc.write(HTML)
   Return Doc
}



URLDownloadToVar(url,ByRef variable=""){
	hObject:=ComObjCreate("WinHttp.WinHttpRequest.5.1")
	hObject.Open("GET",url)
	hObject.Send()
	return variable:=hObject.ResponseText
}

Rohwedder
Posts: 7551
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Welches Forum? PHP Anfrage an www.autohotkey.com

Post by Rohwedder » 01 Jun 2023, 01:45

Vielen Dank, soetwas meinte ich!
Das 3. Krümel allein, reichte jedoch nicht. Deswegen nahm ich die Krümel 1-3:

Code: Select all

Url := "https://www.autohotkey.com/boards/viewtopic.php?t=117753"
Doc := DocumentFromHTML(URLDownloadToVar(Url)), Brotkrümel := ""
Loop, 3
	Try Brotkrümel .= Doc.getElementById("nav-breadcrumbs")
	.getElementsByClassName("crumb")[A_Index].innerText (A_Index<3?"/":"")
; Board index/AutoHotkey (v2, current version)/Bug Reports
If InStr(Brotkrümel, "V2")
	MsgBox, ist version 2
Else If InStr(Brotkrümel, "V1")
	MsgBox, ist version 1
Else
	MsgBox, Konnte nicht ermittelt werden
DocumentFromHTML(HTML)
{
	Local
	Doc := ComObjCreate("htmlfile")
	Doc.write("<meta http-equiv=""X-UA-Compatible"" content=""IE=9"">")
	Doc.write(HTML)
	Return Doc
}
URLDownloadToVar(url,ByRef variable="")
{
	hObject:=ComObjCreate("WinHttp.WinHttpRequest.5.1")
	hObject.Open("GET",url)
	hObject.Send()
	return variable:=hObject.ResponseText
}

Post Reply

Return to “Ich brauche Hilfe”