Vielen Dank
Beiträge von Ineluki
-
-
Warum bekomme ich hier eine leere MsgBox zurück?
[autoit]$test=_INetGetSource("http://ineluki.bplaced.net/version.html")
[/autoit]
MsgBox(0, "", $test) -
Afaik steht e'irgendwas' für 10 hoch 'irgendwas' z.B:
e23 = 10²³ -
Ist doch im Spoiler

-
Feld 1 und 2 gehen nicht.
-
Teile mit StringLeft den Code, füg an das Ende von jedem Stück @CRLF, füg sie dann wieder zusammen und schreib das Ergebnis in eine Datei oder lass es ausgeben oder was weis ich. Geht sicherlich auch besser, aber mir fällt nix besseres ein.
-
[autoit]
If StringRegExp($c_1_ID, "Stein") Then
[/autoit]Geht bestimmt auch besser, aber so würde ich es machen.
-
Lies lieber nochmal die Hilfe zu der Funktion...
-
Ich hab jetzt nak was anderes versucht, und rausgefunden, dass es noch einen anderen Ort als meinen Wohnort gibt, der die PLZ hat. Könntest du es nicht über die Stadt oder über die PLZ machen, also dass man entweder de Stadt, oder die PLZ eingibt? Und gleiche Sache, wie mir auch schon gesagt wurde: Kannst du noch ein Label mit der aktuellen Stadt hinzufügen?
-
Komisch, bei mir gehts.
-
ICh weiß zwar jetzt nciht genau, was du möchetst (liegt wohl eher bei mir) aber hilft dir IniRead und IniWrite weiter?
-
Bei einer anderen Wetterseite und ich hab auch (zur Sicherheit) bei Google Weather geguckt. Und wenn das zählt: Das Thermometer sagt ebenfalls etwas anderes.
-
Gute Arbeit
Aber wenn ich meine PLZ eingebe, kommen total falsche Werte
-
Ich weiß nicht, was du falsch machst, aber bei mir fuktionieren alle deutschen Städte.
-
Wieso? Welche hast du denn eingegeben? Eigentlich müsste es funktionieren...
-
Hast recht, ich werd mal nach dem Problem suchen.
Edit:
#fixed:Spoiler anzeigen
[autoit]; Globale Variablen und Einstellungen
[/autoit] [autoit][/autoit] [autoit]
Global $windtype
Global $oGUI
Global $state
Global $city
Global $trans
Global $nwp
Global $wp
If IniRead("data", "Main", "weatherpage", "google")="Google Weather" Then $wp="Google Weather"
If IniRead("data", "Main", "weatherpage", "google")="Accu Weather" Then $wp="Accu Weather"
Opt("GUIOnEventMode", "1")
Opt("TrayMenuMode",1)
Opt("TrayOnEventMode", 1)
$opt=TrayCreateItem("Optionen")
TrayItemSetOnEvent(-1, "options")
TrayCreateItem("")
$about=TrayCreateItem("Über")
TrayItemSetOnEvent(-1, "about")
;==> Globale Variablen und Einstellungen
; Haupt GUI
GUICreate("Wetter", 295, 219, 189, 132)
GUISetOnEvent(-3, "_exit")
$type = GUICtrlCreateLabel("", 8, 16, 188, 18)
$Temperatur = GUICtrlCreateLabel("Temperatur:", 8, 80, 115, 17)
$gtemperatur = GUICtrlCreateLabel("Gefühlte Temperatur:", 8, 112, 290, 17)
$luftfeuchtigkeit = GUICtrlCreateLabel("Luftfeuchtigkeit:", 8, 144, 118, 17)
$wind = GUICtrlCreateLabel("Wind:", 8, 176, 160, 17)
$currentcity=GUICtrlCreateLabel("Aktuelle Stadt: "&IniRead("data", "Main", "city", "Berlin"), 8, 48, 103, 17)
$hMenu=GUICtrlCreateMenu("Menü")
GUICtrlCreateMenuItem("Optionen", $hMenu)
GUICtrlSetOnEvent(-1, "options")
GUICtrlCreateMenuItem("Über", $hMenu)
GUICtrlSetOnEvent(-1, "about")
WinSetTrans("Wetter", "", IniRead("data", "Other", "Trans", "255"))
GUISetState(@SW_SHOW)
; ==> Haupt GUI
update()
AdlibRegister('update', '30000')While sleep(500)
[/autoit] [autoit][/autoit] [autoit]
WEnd; Eigene Funktionen
[/autoit] [autoit][/autoit] [autoit]
Func update()
If $wp="Accu Weather" Then
$source=_INetGetSource('http://www.accuweather.com/de/EUR/DE/GM'&IniRead("data", "Main", "state", "003")&'/'&IniRead("data", "Main", "city", "Berlin")&'/quick-look.aspx')
$ntype=_StringBetween($source, '<span id="ctl00_cphContent_lblCurrentText" style="display: block; font-size: 11px;line-height: 17px;">', "</span>")
If not IsArray($ntype) Then
MsgBox(0, "Fehler", "Die angegebene Stadt wurde nicht gefunden")
options()
Return
EndIf
GUICtrlSetData($type, $ntype[0])
$ntemperatur=_StringBetween($source, '<span id="ctl00_cphContent_lblCurrentTemp" style="display: block; font-weight: bold;font-size: 18px; line-height: 24px;">', '°')
$ntemperatur[0]-=32
$ntemperatur[0]/=1.8
GUICtrlSetData($Temperatur, "Temperatur: "&Round($ntemperatur[0])&" °C")
$ngtemperatur=_StringBetween($source, 'display: block;">', '°')
$ngtemperatur[0]=StringRight($ngtemperatur[0], 2)
$ngtemperatur[0]-=32
$ngtemperatur[0]/=1.8
GUICtrlSetData($gtemperatur, "Gefühlte Temperatur: "&Round($ngtemperatur[0])&" °C")
$nluftfeuchtigkeit=_StringBetween($source, 'display: block;"', '%')
$nluftfeuchtigkeit[0]=StringRight($nluftfeuchtigkeit[0], 2)
GUICtrlSetData($luftfeuchtigkeit, "Luftfeuchtigkeit: "&$nluftfeuchtigkeit[0]&" %")
$nwind=_StringBetween($source, '<span id="ctl00_cphContent_lblWindsValue" style="width: 80px; float: right; display: block;">', '</span>')
If StringLen($nwind[0])=7 Then
$windtype=StringLeft($nwind[0], 1)
$nwind[0]=StringTrimLeft($nwind[0], 1)
ElseIf StringLen($nwind[0])=8 Then
$windtype=StringLeft($nwind[0], 2)
$nwind[0]=StringTrimLeft($nwind[0], 2)
ElseIf StringLen($nwind[0])=9 Then
$windtype=StringLeft($nwind[0], 3)
$nwind[0]=StringTrimLeft($nwind[0], 3)
EndIf
$nwind[0]=StringTrimRight($nwind[0], 3)
$nwind[0]*=1.609344
If StringRegExp($windtype, "E")=1 Then $windtype=StringRegExpReplace($windtype, "E", "O")
GUICtrlSetData($wind, "Wind: "&$windtype&" "&Round($nwind[0])&" km/h")
Else
$source=_INetGetSource('http://www.google.com/ig/api?weather='&IniRead("data", "Main", "city", "Berlin")&'&hl=de')
$ntype=_StringBetween($source, '<condition data="', '"')
GUICtrlSetData($type, $ntype[1])
$ntemperatur=_StringBetween($source, '<temp_c data="', '"')
GUICtrlSetData($Temperatur, "Temperatur: "&$ntemperatur[0]&" °C")
GUICtrlSetData($gtemperatur, "Gefühlte Temperatur: Nicht bei Google Weather vorhanden.")
$nluftfeuchtigkeit=_StringBetween($source, '<humidity data="Feuchtigkeit: ', '"')
GUICtrlSetData($luftfeuchtigkeit, "Luftfeuchtigkeit: "&$nluftfeuchtigkeit[0])
$nwind=_StringBetween($source, '<wind_condition data="Wind: ', '"')
$nwind[0]=StringRegExpReplace($nwind[0], "mit", "")
GUICtrlSetData($wind, "Wind: "&$windtype&" "&$nwind[0])
EndIf
EndFunc
Func _exit()
Exit
EndFunc
Func options()
TrayItemSetState($opt, 4)
$oGUI = GUICreate("Optionen", 205, 198, 192, 124)
GUISetOnEvent(-3, "close")
GUICtrlCreateLabel("Bundesland: ", 8, 8, 100, 17)
$state = GUICtrlCreateInput("", 70, 6, 121, 21)
GUICtrlCreateLabel("Stadt: ", 8, 48, 27, 17)
$city = GUICtrlCreateInput("", 70, 46, 121, 21)
GUICtrlCreateLabel("Sichtbarkeit:", 8, 88, 60, 17)
$trans = GUICtrlCreateSlider(72, 80, 126, 45)
GUICtrlSetLimit(-1, 255, 0)
GUICtrlSetData(-1, IniRead("data", "Other", "trans", "0"))
$nwp = GUICtrlCreateCombo(IniRead("data", "Main", "weatherpage", "Accu Weather"), 112, 136, 89, 25)
GUICtrlSetData(-1, "Accu Weather | Google Weather")
GUICtrlCreateLabel("Wetterinformationen", 8, 136, 99, 17)
GUICtrlCreateButton("Änderungen speichern", 44, 168, 120, 25)
GUICtrlSetOnEvent(-1, "save")
GUISetState(@SW_SHOW)
EndFunc
Func close()
GUIDelete($oGUI)
EndFunc
Func save()
$nstate=GUICtrlRead($state)
If $state="Baden-Württemberg" Then $nstate="001"
If $state="Baden Württemberg" Then $nstate="001"
If $state="Bayern" Then $nstate="002"
If $state="Berlin" Then $nstate="003"
If $state="Brandenburg" Then $nstate="004"
If $state="Bremen" Then $nstate="005"
If $state="Hamburg" Then $nstate="006"
If $state="Hessen" Then $nstate="007"
If $state="Niedersachsen" Then $nstate="009"
If $state="Mecklenburg-Vorpommern" Then $nstate="010"
If $state="Mecklenburg Vorpommern" Then $nstate="010"
If $state="Nordrhein-Westfalen" Then $nstate="011"
If $state="Nordrhein Westfalen" Then $nstate="011"
If $state="Rheinland-Pfalz" Then $nstate="012"
If $state="Rheinland Pfalz" Then $nstate="012"
If $state="Saarland" Then $nstate="013"
If $state="Sachsen" Then $nstate="014"
If $state="Sachsen-Anhalt" Then $nstate="015"
If $state="Sachsen Anhalt" Then $nstate="015"
If $state="Schleswig-Holstein" Then $nstate="016"
If $state="Schleswig Holstein" Then $nstate="016"
If $state="Thüringen" Then $nstate="017"
$city=GUICtrlRead($city)
$trans=GUICtrlRead($trans)
$nwp=GUICtrlRead($nwp)
If $nstate<>IniRead("data", "Main", "state", "")And $nstate<>"" Then IniWrite("data", "Main", "state", $nstate)
If $city<>"" Then IniWrite("data", "Main", "city", $city)
If $trans<>IniRead("data", "Other", "trans", "") Then IniWrite("data", "Other", "trans", $trans)
If $nwp<>"" Then IniWrite("data", "Main", "weatherpage", $nwp)
GUIDelete($oGUI)
WinSetTrans("Wetter", "", IniRead("data", "Other", "trans", "255"))
GUICtrlSetData($currentcity, "Aktuelle Stadt:"&$city)
update()
EndFunc
Func about()
TrayItemSetState($about, 4)
MsgBox(0, "Über", "Code: Jan Timon"&@CRLF&"Wetterdaten: http://www.accuweather.com | http://www.google.com/ig/api?weather")
EndFunc ;==>Eigene Funktionen; Funktionen aus UDF's
[/autoit] [autoit][/autoit] [autoit]
Func _INetGetSource($s_URL, $bString = True)
Local $sString = InetRead($s_URL, 1)
Local $nError = @error, $nExtended = @extended
If $bString Then $sString = BinaryToString($sString)
Return SetError($nError, $nExtended, $sString)
EndFunc
Func _StringBetween($s_String, $s_Start, $s_End, $v_If = -1); Set If type
[/autoit] [autoit][/autoit] [autoit]
Local $s_If = ""
If $v_If = Default Or $v_If = -1 Then $s_If = "(?i)"; Escape characters
[/autoit] [autoit][/autoit] [autoit]
Local $s_pattern_escape = "(\.|\||\*|\?|\+|\(|\)|\{|\}|\[|\]|\^|\$|\\)"
$s_Start = StringRegExpReplace($s_Start, $s_pattern_escape, "\\$1")
$s_End = StringRegExpReplace($s_End, $s_pattern_escape, "\\$1"); If you want data from beginning then replace blank start with beginning of string
[/autoit] [autoit][/autoit] [autoit]
If $s_Start = "" Then $s_Start = "\A"; If you want data from a start to an end then replace blank with end of string
[/autoit] [autoit][/autoit] [autoit]
If $s_End = "" Then $s_End = "\z"Local $a_ret = StringRegExp($s_String, "(?s)" & $s_If & $s_Start & "(.*?)" & $s_End, 3)
[/autoit] [autoit][/autoit] [autoit]If @error Then Return SetError(1, 0, 0)
[/autoit]
Return $a_ret
EndFunc ;==>Funktionen aus UDF's -
Aktuelle Stadt ist jetzt dabei. Das zu kleine Label, wenn man Google Weather nimmt bei Gefühlte Temperatur passt jetzt auch. Die kleine Auswahl, welche Wetterseite man haben will, find ich jetzt nicht so schlimm, wenn man die Auswahl ausklappt, steht es vollständig da. Neuer Code:
Spoiler anzeigen
[autoit]; Globale Variablen und Einstellungen
[/autoit] [autoit][/autoit] [autoit]
Global $windtype
Global $oGUI
Global $state
Global $city
Global $trans
Global $nwp
Global $wp
If IniRead("data", "Main", "weatherpage", "google")="Google Weather" Then $wp="Google Weather"
If IniRead("data", "Main", "weatherpage", "google")="Accu Weather" Then $wp="Accu Weather"
Opt("GUIOnEventMode", "1")
Opt("TrayMenuMode",1)
Opt("TrayOnEventMode", 1)
$opt=TrayCreateItem("Optionen")
TrayItemSetOnEvent(-1, "options")
TrayCreateItem("")
$about=TrayCreateItem("Über")
TrayItemSetOnEvent(-1, "about")
;==> Globale Variablen und Einstellungen
; Haupt GUI
GUICreate("Wetter", 295, 219, 189, 132)
GUISetOnEvent(-3, "_exit")
$type = GUICtrlCreateLabel("", 8, 16, 188, 18)
$Temperatur = GUICtrlCreateLabel("Temperatur:", 8, 80, 115, 17)
$gtemperatur = GUICtrlCreateLabel("Gefühlte Temperatur:", 8, 112, 290, 17)
$luftfeuchtigkeit = GUICtrlCreateLabel("Luftfeuchtigkeit:", 8, 144, 118, 17)
$wind = GUICtrlCreateLabel("Wind:", 8, 176, 160, 17)
$currentcity=GUICtrlCreateLabel("Aktuelle Stadt: "&IniRead("data", "Main", "city", "Berlin"), 8, 48, 103, 17)
$hMenu=GUICtrlCreateMenu("Menü")
GUICtrlCreateMenuItem("Optionen", $hMenu)
GUICtrlSetOnEvent(-1, "options")
GUICtrlCreateMenuItem("Über", $hMenu)
GUICtrlSetOnEvent(-1, "about")
WinSetTrans("Wetter", "", IniRead("data", "Other", "Trans", "255"))
GUISetState(@SW_SHOW)
; ==> Haupt GUI
update()
AdlibRegister('update', '30000')While sleep(500)
[/autoit] [autoit][/autoit] [autoit]
WEnd; Eigene Funktionen
[/autoit] [autoit][/autoit] [autoit]
Func update()
If $wp="Accu Weather" Then
$source=_INetGetSource('http://www.accuweather.com/de/EUR/DE/GM'&IniRead("data", "Main", "state", "003")&'/'&IniRead("data", "Main", "city", "Berlin")&'/quick-look.aspx')
$ntype=_StringBetween($source, '<span id="ctl00_cphContent_lblCurrentText" style="display: block; font-size: 11px;line-height: 17px;">', "</span>")
If not IsArray($ntype) Then
MsgBox(0, "Fehler", "Die angegebene Stadt wurde nicht gefunden")
options()
Return
EndIf
GUICtrlSetData($type, $ntype[0])
$ntemperatur=_StringBetween($source, '<span id="ctl00_cphContent_lblCurrentTemp" style="display: block; font-weight: bold;font-size: 18px; line-height: 24px;">', '°')
$ntemperatur[0]-=32
$ntemperatur[0]/=1.8
GUICtrlSetData($Temperatur, "Temperatur: "&Round($ntemperatur[0])&" °C")
$ngtemperatur=_StringBetween($source, 'display: block;">', '°')
$ngtemperatur[0]=StringRight($ngtemperatur[0], 2)
$ngtemperatur[0]-=32
$ngtemperatur[0]/=1.8
GUICtrlSetData($gtemperatur, "Gefühlte Temperatur: "&Round($ngtemperatur[0])&" °C")
$nluftfeuchtigkeit=_StringBetween($source, 'display: block;"', '%')
$nluftfeuchtigkeit[0]=StringRight($nluftfeuchtigkeit[0], 2)
GUICtrlSetData($luftfeuchtigkeit, "Luftfeuchtigkeit: "&$nluftfeuchtigkeit[0]&" %")
$nwind=_StringBetween($source, '<span id="ctl00_cphContent_lblWindsValue" style="width: 80px; float: right; display: block;">', '</span>')
If StringLen($nwind[0])=7 Then
$windtype=StringLeft($nwind[0], 1)
$nwind[0]=StringTrimLeft($nwind[0], 1)
ElseIf StringLen($nwind[0])=8 Then
$windtype=StringLeft($nwind[0], 2)
$nwind[0]=StringTrimLeft($nwind[0], 2)
ElseIf StringLen($nwind[0])=9 Then
$windtype=StringLeft($nwind[0], 3)
$nwind[0]=StringTrimLeft($nwind[0], 3)
EndIf
$nwind[0]=StringTrimRight($nwind[0], 3)
$nwind[0]*=1.609344
If StringRegExp($windtype, "E")=1 Then $windtype=StringRegExpReplace($windtype, "E", "O")
GUICtrlSetData($wind, "Wind: "&$windtype&" "&Round($nwind[0])&" km/h")
Else
$source=_INetGetSource('http://www.google.com/ig/api?weather='&IniRead("data", "Main", "city", "Berlin")&'&hl=de')
$ntype=_StringBetween($source, '<condition data="', '"')
GUICtrlSetData($type, $ntype[1])
$ntemperatur=_StringBetween($source, '<temp_c data="', '"')
GUICtrlSetData($Temperatur, "Temperatur: "&$ntemperatur[0]&" °C")
GUICtrlSetData($gtemperatur, "Gefühlte Temperatur: Nicht bei Google Weather vorhanden.")
$nluftfeuchtigkeit=_StringBetween($source, '<humidity data="Feuchtigkeit: ', '"')
GUICtrlSetData($luftfeuchtigkeit, "Luftfeuchtigkeit: "&$nluftfeuchtigkeit[0])
$nwind=_StringBetween($source, '<wind_condition data="Wind: ', '"')
$nwind[0]=StringRegExpReplace($nwind[0], "mit", "")
GUICtrlSetData($wind, "Wind: "&$windtype&" "&$nwind[0])
EndIf
EndFunc
Func _exit()
Exit
EndFunc
Func options()
TrayItemSetState($opt, 4)
$oGUI = GUICreate("Optionen", 205, 198, 192, 124)
GUISetOnEvent(-3, "close")
GUICtrlCreateLabel("Bundesland: ", 8, 8, 100, 17)
$state = GUICtrlCreateInput("", 70, 6, 121, 21)
GUICtrlCreateLabel("Stadt: ", 8, 48, 27, 17)
$city = GUICtrlCreateInput("", 70, 46, 121, 21)
GUICtrlCreateLabel("Sichtbarkeit:", 8, 88, 60, 17)
$trans = GUICtrlCreateSlider(72, 80, 126, 45)
GUICtrlSetLimit(-1, 255, 0)
GUICtrlSetData(-1, IniRead("data", "Other", "trans", "0"))
$nwp = GUICtrlCreateCombo(IniRead("data", "Main", "weatherpage", "Accu Weather"), 112, 136, 89, 25)
GUICtrlSetData(-1, "Accu Weather | Google Weather")
GUICtrlCreateLabel("Wetterinformationen", 8, 136, 99, 17)
GUICtrlCreateButton("Änderungen speichern", 44, 168, 120, 25)
GUICtrlSetOnEvent(-1, "save")
GUISetState(@SW_SHOW)
EndFunc
Func close()
GUIDelete($oGUI)
EndFunc
Func save()
$nstate=GUICtrlRead($state)
If $state="Baden-Württemberg" Then $nstate="001"
If $state="Baden Württemberg" Then $nstate="001"
If $state="Bayern" Then $nstate="002"
If $state="Berlin" Then $nstate="003"
If $state="Brandenburg" Then $nstate="004"
If $state="Bremen" Then $nstate="005"
If $state="Hamburg" Then $nstate="006"
If $state="Hessen" Then $nstate="007"
If $state="Niedersachsen" Then $nstate="009"
If $state="Mecklenburg-Vorpommern" Then $nstate="010"
If $state="Mecklenburg Vorpommern" Then $nstate="010"
If $state="Nordrhein-Westfalen" Then $nstate="011"
If $state="Nordrhein Westfalen" Then $nstate="011"
If $state="Rheinland-Pfalz" Then $nstate="012"
If $state="Rheinland Pfalz" Then $nstate="012"
If $state="Saarland" Then $nstate="013"
If $state="Sachsen" Then $nstate="014"
If $state="Sachsen-Anhalt" Then $nstate="015"
If $state="Sachsen Anhalt" Then $nstate="015"
If $state="Schleswig-Holstein" Then $nstate="016"
If $state="Schleswig Holstein" Then $nstate="016"
If $state="Thüringen" Then $nstate="017"
$city=GUICtrlRead($city)
$trans=GUICtrlRead($trans)
$nwp=GUICtrlRead($nwp)
If $nstate<>IniRead("data", "Main", "state", "")And $nstate<>"" Then IniWrite("data", "Main", "state", $nstate)
If $city<>"" Then IniWrite("data", "Main", "city", $city)
If $trans<>IniRead("data", "Other", "trans", "") Then IniWrite("data", "Other", "trans", $trans)
If $nwp<>"" Then
IniWrite("data", "Main", "weatherpage", $nwp)
EndIf
GUIDelete($oGUI)
WinSetTrans("Wetter", "", $trans)
GUICtrlSetData($currentcity, "Aktuelle Stadt:"&$city)
update()
EndFunc
Func about()
TrayItemSetState($about, 4)
MsgBox(0, "Über", "Code: Jan Timon"&@CRLF&"Wetterdaten: http://www.accuweather.com | http://www.google.com/ig/api?weather")
EndFunc ;==>Eigene Funktionen; Funktionen aus UDF's
[/autoit] [autoit][/autoit] [autoit]
Func _INetGetSource($s_URL, $bString = True)
Local $sString = InetRead($s_URL, 1)
Local $nError = @error, $nExtended = @extended
If $bString Then $sString = BinaryToString($sString)
Return SetError($nError, $nExtended, $sString)
EndFunc
Func _StringBetween($s_String, $s_Start, $s_End, $v_If = -1); Set If type
[/autoit] [autoit][/autoit] [autoit]
Local $s_If = ""
If $v_If = Default Or $v_If = -1 Then $s_If = "(?i)"; Escape characters
[/autoit] [autoit][/autoit] [autoit]
Local $s_pattern_escape = "(\.|\||\*|\?|\+|\(|\)|\{|\}|\[|\]|\^|\$|\\)"
$s_Start = StringRegExpReplace($s_Start, $s_pattern_escape, "\\$1")
$s_End = StringRegExpReplace($s_End, $s_pattern_escape, "\\$1"); If you want data from beginning then replace blank start with beginning of string
[/autoit] [autoit][/autoit] [autoit]
If $s_Start = "" Then $s_Start = "\A"; If you want data from a start to an end then replace blank with end of string
[/autoit] [autoit][/autoit] [autoit]
If $s_End = "" Then $s_End = "\z"Local $a_ret = StringRegExp($s_String, "(?s)" & $s_If & $s_Start & "(.*?)" & $s_End, 3)
[/autoit] [autoit][/autoit] [autoit]If @error Then Return SetError(1, 0, 0)
[/autoit]
Return $a_ret
EndFunc ;==>Funktionen aus UDF's -
Was genau meinst du mit den Satelliten?
Die ausgewählte Stadt in der GUI anzeigen zu lassen, kann ich schnell hinzufügen.
Welche Controls sind denn zu klein? Bei mir passt alles, außer die Combo Box, die reicht nicht ganz, wenn man die aber ausklappt, passt es.
Wieso soll ich die Ini deklarieren? So gehts doch auch
Und wieso mit einer Extension versehen?
Insgesamt aber danke für die Kritik. -
Komisch, bei mir klappt es. Woher die 6 Sekunden Wartezeit am Anfang kommen weiß ich auch nicht.
Neue Version:Spoiler anzeigen
[autoit]; Globale Variablen und Einstellungen
[/autoit] [autoit][/autoit] [autoit]
Global $windtype
Global $oGUI
Global $state
Global $city
Global $trans
Global $nwp
Global $wp
If IniRead("data", "Main", "weatherpage", "google")="Google Weather" Then $wp="Google Weather"
If IniRead("data", "Main", "weatherpage", "google")="Accu Weather" Then $wp="Accu Weather"
Opt("GUIOnEventMode", "1")
Opt("TrayMenuMode",1)
Opt("TrayOnEventMode", 1)
$opt=TrayCreateItem("Optionen")
TrayItemSetOnEvent(-1, "options")
TrayCreateItem("")
$about=TrayCreateItem("Über")
TrayItemSetOnEvent(-1, "about")
;==> Globale Variablen und Einstellungen
; Haupt GUI
GUICreate('Wetter', 233, 193, 186, 132)
GUISetOnEvent(-3, "_exit")
$type = GUICtrlCreateLabel('', 8, 16, 188, 18)
$Temperatur = GUICtrlCreateLabel('Temperatur:', 8, 56, 115, 17)
$gtemperatur = GUICtrlCreateLabel('Gefühlte Temperatur:', 8, 88, 290, 17)
$luftfeuchtigkeit = GUICtrlCreateLabel('Luftfeuchtigkeit:', 8, 120, 118, 17)
$wind = GUICtrlCreateLabel('Wind:', 8, 152, 160, 17)
$hMenu=GUICtrlCreateMenu("Menü")
GUICtrlCreateMenuItem("Optionen", $hMenu)
GUICtrlSetOnEvent(-1, "options")
GUICtrlCreateMenuItem("Über", $hMenu)
GUICtrlSetOnEvent(-1, "about")
WinSetTrans("Wetter", "", IniRead("data", "Other", "Trans", "255"))
GUISetState(@SW_SHOW)
; ==> Haupt GUI
update()
AdlibRegister('update', '30000')While sleep(500)
[/autoit] [autoit][/autoit] [autoit]
WEnd; Eigene Funktionen
[/autoit] [autoit][/autoit] [autoit]
Func update()
If $wp="Accu Weather" Then
$source=_INetGetSource('http://www.accuweather.com/de/EUR/DE/GM'&IniRead("data", "Main", "state", "003")&'/'&IniRead("data", "Main", "city", "Berlin")&'/quick-look.aspx')
$ntype=_StringBetween($source, '<span id="ctl00_cphContent_lblCurrentText" style="display: block; font-size: 11px;line-height: 17px;">', "</span>")
If not IsArray($ntype) Then
MsgBox(0, "Fehler", "Die angegebene Stadt wurde nicht gefunden")
options()
Return
EndIf
GUICtrlSetData($type, $ntype[0])
$ntemperatur=_StringBetween($source, '<span id="ctl00_cphContent_lblCurrentTemp" style="display: block; font-weight: bold;font-size: 18px; line-height: 24px;">', '°')
$ntemperatur[0]-=32
$ntemperatur[0]/=1.8
GUICtrlSetData($Temperatur, "Temperatur: "&Round($ntemperatur[0])&" °C")
$ngtemperatur=_StringBetween($source, 'display: block;">', '°')
$ngtemperatur[0]=StringRight($ngtemperatur[0], 2)
$ngtemperatur[0]-=32
$ngtemperatur[0]/=1.8
GUICtrlSetData($gtemperatur, "Gefühlte Temperatur: "&Round($ngtemperatur[0])&" °C")
$nluftfeuchtigkeit=_StringBetween($source, 'display: block;"', '%')
$nluftfeuchtigkeit[0]=StringRight($nluftfeuchtigkeit[0], 2)
GUICtrlSetData($luftfeuchtigkeit, "Luftfeuchtigkeit: "&$nluftfeuchtigkeit[0]&" %")
$nwind=_StringBetween($source, '<span id="ctl00_cphContent_lblWindsValue" style="width: 80px; float: right; display: block;">', '</span>')
If StringLen($nwind[0])=7 Then
$windtype=StringLeft($nwind[0], 1)
$nwind[0]=StringTrimLeft($nwind[0], 1)
ElseIf StringLen($nwind[0])=8 Then
$windtype=StringLeft($nwind[0], 2)
$nwind[0]=StringTrimLeft($nwind[0], 2)
ElseIf StringLen($nwind[0])=9 Then
$windtype=StringLeft($nwind[0], 3)
$nwind[0]=StringTrimLeft($nwind[0], 3)
EndIf
$nwind[0]=StringTrimRight($nwind[0], 3)
$nwind[0]*=1.609344
If StringRegExp($windtype, "E")=1 Then $windtype=StringRegExpReplace($windtype, "E", "O")
GUICtrlSetData($wind, "Wind: "&$windtype&" "&Round($nwind[0])&" km/h")
Else
$source=_INetGetSource('http://www.google.com/ig/api?weather='&IniRead("data", "Main", "city", "Berlin")&'&hl=de')
$ntype=_StringBetween($source, '<condition data="', '"')
GUICtrlSetData($type, $ntype[1])
$ntemperatur=_StringBetween($source, '<temp_c data="', '"')
GUICtrlSetData($Temperatur, "Temperatur: "&$ntemperatur[0]&" °C")
GUICtrlSetData($gtemperatur, "Gefühlte Temperatur: Nicht bei Google Weather vorhanden.")
$nluftfeuchtigkeit=_StringBetween($source, '<humidity data="Feuchtigkeit: ', '"')
GUICtrlSetData($luftfeuchtigkeit, "Luftfeuchtigkeit: "&$nluftfeuchtigkeit[0])
$nwind=_StringBetween($source, '<wind_condition data="Wind: ', '"')
$nwind[0]=StringRegExpReplace($nwind[0], "mit", "")
GUICtrlSetData($wind, "Wind: "&$windtype&" "&$nwind[0])
EndIf
EndFunc
Func _exit()
Exit
EndFunc
Func options()
TrayItemSetState($opt, 4)
$oGUI = GUICreate("Optionen", 205, 198, 192, 124)
GUISetOnEvent(-3, "close")
GUICtrlCreateLabel("Bundesland: ", 8, 8, 100, 17)
$state = GUICtrlCreateInput("", 70, 6, 121, 21)
GUICtrlCreateLabel("Stadt: ", 8, 48, 27, 17)
$city = GUICtrlCreateInput("", 70, 46, 121, 21)
GUICtrlCreateLabel("Sichtbarkeit:", 8, 88, 60, 17)
$trans = GUICtrlCreateSlider(72, 80, 126, 45)
GUICtrlSetLimit(-1, 255, 0)
GUICtrlSetData(-1, IniRead("data", "Other", "trans", "0"))
$nwp = GUICtrlCreateCombo(IniRead("data", "Main", "weatherpage", "Accu Weather"), 112, 136, 89, 25)
GUICtrlSetData(-1, "Accu Weather | Google Weather")
GUICtrlCreateLabel("Wetterinformationen", 8, 136, 99, 17)
GUICtrlCreateButton("Änderungen speichern", 44, 168, 120, 25)
GUICtrlSetOnEvent(-1, "save")
GUISetState(@SW_SHOW)
EndFunc
Func close()
GUIDelete($oGUI)
EndFunc
Func save()
$nstate=GUICtrlRead($state)
If $state="Baden-Württemberg" Then $nstate="001"
If $state="Baden Württemberg" Then $nstate="001"
If $state="Bayern" Then $nstate="002"
If $state="Berlin" Then $nstate="003"
If $state="Brandenburg" Then $nstate="004"
If $state="Bremen" Then $nstate="005"
If $state="Hamburg" Then $nstate="006"
If $state="Hessen" Then $nstate="007"
If $state="Niedersachsen" Then $nstate="009"
If $state="Mecklenburg-Vorpommern" Then $nstate="010"
If $state="Mecklenburg Vorpommern" Then $nstate="010"
If $state="Nordrhein-Westfalen" Then $nstate="011"
If $state="Nordrhein Westfalen" Then $nstate="011"
If $state="Rheinland-Pfalz" Then $nstate="012"
If $state="Rheinland Pfalz" Then $nstate="012"
If $state="Saarland" Then $nstate="013"
If $state="Sachsen" Then $nstate="014"
If $state="Sachsen-Anhalt" Then $nstate="015"
If $state="Sachsen Anhalt" Then $nstate="015"
If $state="Schleswig-Holstein" Then $nstate="016"
If $state="Schleswig Holstein" Then $nstate="016"
If $state="Thüringen" Then $nstate="017"
$city=GUICtrlRead($city)
$trans=GUICtrlRead($trans)
$nwp=GUICtrlRead($nwp)
If $nstate<>IniRead("data", "Main", "state", "")And $nstate<>"" Then IniWrite("data", "Main", "state", $nstate)
If $city<>"" Then IniWrite("data", "Main", "city", $city)
If $trans<>IniRead("data", "Other", "trans", "") Then IniWrite("data", "Other", "trans", $trans)
If $nwp<>"" Then
IniWrite("data", "Main", "weatherpage", $nwp)
EndIf
GUIDelete($oGUI)
WinSetTrans("Wetter", "", $trans)
update()
EndFunc
Func about()
TrayItemSetState($about, 4)
MsgBox(0, "Über", "Code: Jan Timon"&@CRLF&"Wetterdaten: http://www.accuweather.com | http://www.google.com/ig/api?weather")
EndFunc ;==>Eigene Funktionen; Funktionen aus UDF's
[/autoit] [autoit][/autoit] [autoit]
Func _INetGetSource($s_URL, $bString = True)
Local $sString = InetRead($s_URL, 1)
Local $nError = @error, $nExtended = @extended
If $bString Then $sString = BinaryToString($sString)
Return SetError($nError, $nExtended, $sString)
EndFunc
Func _StringBetween($s_String, $s_Start, $s_End, $v_If = -1); Set If type
[/autoit] [autoit][/autoit] [autoit]
Local $s_If = ""
If $v_If = Default Or $v_If = -1 Then $s_If = "(?i)"; Escape characters
[/autoit] [autoit][/autoit] [autoit]
Local $s_pattern_escape = "(\.|\||\*|\?|\+|\(|\)|\{|\}|\[|\]|\^|\$|\\)"
$s_Start = StringRegExpReplace($s_Start, $s_pattern_escape, "\\$1")
$s_End = StringRegExpReplace($s_End, $s_pattern_escape, "\\$1"); If you want data from beginning then replace blank start with beginning of string
[/autoit] [autoit][/autoit] [autoit]
If $s_Start = "" Then $s_Start = "\A"; If you want data from a start to an end then replace blank with end of string
[/autoit] [autoit][/autoit] [autoit]
If $s_End = "" Then $s_End = "\z"Local $a_ret = StringRegExp($s_String, "(?s)" & $s_If & $s_Start & "(.*?)" & $s_End, 3)
[/autoit] [autoit][/autoit] [autoit]If @error Then Return SetError(1, 0, 0)
[/autoit]
Return $a_ret
EndFunc ;==>Funktionen aus UDF's
Änderungen:
- Man kann zwischen zwei Wetterseiten wählen
- Das Programm stürzt nichtmehr ab, wenn die Stadt nicht gefunden werden konnte -
Das sieht gut aus, ich glaube ich werde es so machen, dass man zwischen accuweather und googleweather wechseln kann.