• Hab jetzt mal mein Wetter Script fertiggestellt ( ich weiß, man kann viel verbessern und es hat keine Bilder, aber egal) :

    Spoiler anzeigen
    [autoit]

    ; Globale Variablen und Einstellungen
    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')

    [/autoit] [autoit][/autoit] [autoit]

    While sleep(500)
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    ; Eigene Funktionen
    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;">', '&deg')
    $ntemperatur[0]-=32
    $ntemperatur[0]/=1.8
    GUICtrlSetData($Temperatur, "Temperatur: "&Round($ntemperatur[0])&" °C")
    $ngtemperatur=_StringBetween($source, 'display: block;">', '&deg')
    $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()
    $state=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

    [/autoit] [autoit][/autoit] [autoit]

    ; Funktionen aus UDF's
    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)

    [/autoit] [autoit][/autoit] [autoit]

    ; Set If type
    Local $s_If = ""
    If $v_If = Default Or $v_If = -1 Then $s_If = "(?i)"

    [/autoit] [autoit][/autoit] [autoit]

    ; Escape characters
    Local $s_pattern_escape = "(\.|\||\*|\?|\+|\(|\)|\{|\}|\[|\]|\^|\$|\\)"
    $s_Start = StringRegExpReplace($s_Start, $s_pattern_escape, "\\$1")
    $s_End = StringRegExpReplace($s_End, $s_pattern_escape, "\\$1")

    [/autoit] [autoit][/autoit] [autoit]

    ; If you want data from beginning then replace blank start with beginning of string
    If $s_Start = "" Then $s_Start = "\A"

    [/autoit] [autoit][/autoit] [autoit]

    ; If you want data from a start to an end then replace blank with end of string
    If $s_End = "" Then $s_End = "\z"

    [/autoit] [autoit][/autoit] [autoit]

    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)
    Return $a_ret
    EndFunc ;==>Funktionen aus UDF's

    [/autoit]


    Man kann zwischen zwei Wetterseiten wählen; mit Accu Weather gehen bisher nur Städte aus Deutschland, mit Google Weather sollten alle gehen.
    Sollte die Stadt nicht vorhanden sein, wird man in die Optionen GUI weitergeleitet, um eine neue anzugeben.

    7 Mal editiert, zuletzt von Ineluki (10. Juni 2010 um 16:44)

  • Hi,
    bei mir tritt folgendes Problem auf, wenn ich in den Optionen die Stadt eingebe und die Sichtbarkeit umstelle:
    C:\Users\****\Desktop\test.au3 (42) : ==> Subscript used with non-Array variable.:
    GUICtrlSetData($type, $ntype[0])
    GUICtrlSetData($type, $ntype^ ERROR

  • Wenn die Stadt nicht in Deutschland liegt, geht es nicht, hab ich vergessen, dazuzuschreiben ^^. Aber ich merke grad, dass die Transparenz nicht klappt.
    Edit: Jetzt geht die Transparenz

    Einmal editiert, zuletzt von Ineluki (8. Juni 2010 um 19:51)

  • Gut, :thumbup:
    wenn du willst kannst du dir sicher bei "Desk Weather" von TheShadowAE was abgucken.

    mfg Ubuntu

  • Ohh. FehlerMeldung.
    Ich habe die Stadt geändert.
    Dann kommt folgende FehlerMeldung:

    Code
    >"C:\Programme\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:\Users\*****\Desktop\weather.au3" /autoit3dir "C:\Programme\AutoIt3" /UserParams	
    +>20:08:16 Starting AutoIt3Wrapper v.2.0.1.24	Environment(Language:0407  Keyboard:00000407  OS:WIN_7/  CPU:X64 OS:X86)
    >Running AU3Check (1.54.19.0)  from:C:\Programme\AutoIt3
    +>20:08:16 AU3Check ended.rc:0
    >Running:(3.3.6.0):C:\Programme\AutoIt3\autoit3.exe "C:\Users\******\Desktop\weather.au3"	
    C:\Users\******\Desktop\weather.au3 (42) : ==> Subscript used with non-Array variable.:
    GUICtrlSetData($type, $ntype[0])
    GUICtrlSetData($type, $ntype^ ERROR
    ->20:08:37 AutoIT3.exe ended.rc:1
    >Exit code: 1	Time: 22.599

    Nur keine Hektik - das Leben ist stressig genug

  • Ich glaube, ich weiß, woran es liegt, aber ich krieg es grad nicht so hin, wie ich es will...
    Edit: So, hab den Fehler, aber leider keine Zeit mehr. Vllt. krieg ich es noch schnell hin (kommt auf meine Tippgeschwindigkeit an :D ) ansonsten kommt es morgen.

    Einmal editiert, zuletzt von Ineluki (8. Juni 2010 um 21:01)

  • Weiß nciht, ob der Code klappt, ich muss jetzt off:

    Spoiler anzeigen
    [autoit]

    ; Globale Variablen und Einstellungen
    Global $windtype
    Global $oGUI
    Global $state
    Global $city
    Global $trans
    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, 160, 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')

    [/autoit] [autoit][/autoit] [autoit]

    While sleep(500)
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    ; Eigene Funktionen
    Func update()
    $source=_INetGetSource('http://www.accuweather.com/de/EUR/DE/GM'&IniRead("data", "Main", "state", "003")&'/'&IniRead("data", "Main", "city", "Berlin")&'/quick-look.aspx')

    [/autoit] [autoit][/autoit] [autoit]

    $ntype=_StringBetween($source, '<span id="ctl00_cphContent_lblCurrentText" style="display: block; font-size: 11px;line-height: 17px;">', "</span>")
    GUICtrlSetData($type, $ntype[0])
    $ntemperatur=_StringBetween($source, '<span id="ctl00_cphContent_lblCurrentTemp" style="display: block; font-weight: bold;font-size: 18px; line-height: 24px;">', '&deg')
    $ntemperatur[0]-=32
    $ntemperatur[0]/=1.8
    GUICtrlSetData($Temperatur, "Temperatur: "&Round($ntemperatur[0])&" °C")
    $ngtemperatur=_StringBetween($source, 'display: block;">', '&deg')
    $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])=10 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")
    EndFunc
    Func _exit()
    Exit
    EndFunc
    Func options()
    TrayItemSetState($opt, 4)
    $oGUI = GUICreate("Optionen", 204, 179, 192, 124)
    GUISetOnEvent(-3, "close")
    GUICtrlCreateLabel("Bundesland: ", 8, 8, 100, 17)
    $state = GUICtrlCreateInput("", 64, 6, 121, 21)
    GUICtrlCreateLabel("Stadt: ", 8, 48, 27, 17)
    $city = GUICtrlCreateInput("", 64, 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"))
    GUICtrlCreateButton("Änderungen speichern", 44, 128, 120, 25)
    GUICtrlSetOnEvent(-1, "save")
    GUISetState(@SW_SHOW)
    EndFunc
    Func close()
    GUIDelete($oGUI)
    EndFunc
    Func save()
    $state=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)
    If $nstate<>IniRead("data", "Main", "state", "") 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)
    GUIDelete($oGUI)
    WinSetTrans("Wetter", "", $trans)
    update()
    EndFunc
    Func about()
    TrayItemSetState($about, 4)
    MsgBox(0, "Über", "Code: Jan Timon"&@CRLF&"Wetterdaten: http://www.accuweather.com")
    EndFunc ;==>Eigene Funktionen

    [/autoit] [autoit][/autoit] [autoit]

    ; Funktionen aus UDF's
    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)

    [/autoit] [autoit][/autoit] [autoit]

    ; Set If type
    Local $s_If = ""
    If $v_If = Default Or $v_If = -1 Then $s_If = "(?i)"

    [/autoit] [autoit][/autoit] [autoit]

    ; Escape characters
    Local $s_pattern_escape = "(\.|\||\*|\?|\+|\(|\)|\{|\}|\[|\]|\^|\$|\\)"
    $s_Start = StringRegExpReplace($s_Start, $s_pattern_escape, "\\$1")
    $s_End = StringRegExpReplace($s_End, $s_pattern_escape, "\\$1")

    [/autoit] [autoit][/autoit] [autoit]

    ; If you want data from beginning then replace blank start with beginning of string
    If $s_Start = "" Then $s_Start = "\A"

    [/autoit] [autoit][/autoit] [autoit]

    ; If you want data from a start to an end then replace blank with end of string
    If $s_End = "" Then $s_End = "\z"

    [/autoit] [autoit][/autoit] [autoit]

    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)
    Return $a_ret
    EndFunc ;==>Funktionen aus UDF's

    [/autoit]
  • 2 Worte: ;)
    Einfach & gut

  • TheShadowAE: Wie ist denn der Link bei Google Weather aufgebaut? Und eigt. geht accuweather.com auch, der Fehler lag nur bei mir :P Aber andere Länder sind mit accuweater etwas viel Schreibarbeit...
    Abgucken wollte ich aber eigt. nicht, sollte mein eigenes Wetterscript werden :)
    fschaef: Danke :)

  • Naja Googlelink siehste im Deskweather, da brauchst du egal wo die Stadt ist gleichen Aufwand, mit der Funktion in Deskweather ca. = 0,1, du Funktion habe ich übrigens aus dem Wetterscript von Kev oder so ähnlich, ich habe sie nur modifiziert (glaube ich)

  • Wenn ich das Programm zum 1.mal starte und einfach auf "Menu" und "Über" klickte , hängt sich das Programm auf.

    Code
    ==> Subscript used with non-Array variable.:
    $ntemperatur[0]-=32
    $ntemperatur^ ERROR

    Auch so , wenn ich das Programm starte laggt es und dauert knapp 6Sekunden bis ist fertig benutztbar offen ist.

  • 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
    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')

    [/autoit] [autoit][/autoit] [autoit]

    While sleep(500)
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    ; Eigene Funktionen
    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;">', '&deg')
    $ntemperatur[0]-=32
    $ntemperatur[0]/=1.8
    GUICtrlSetData($Temperatur, "Temperatur: "&Round($ntemperatur[0])&" °C")
    $ngtemperatur=_StringBetween($source, 'display: block;">', '&deg')
    $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

    [/autoit] [autoit][/autoit] [autoit]

    ; Funktionen aus UDF's
    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)

    [/autoit] [autoit][/autoit] [autoit]

    ; Set If type
    Local $s_If = ""
    If $v_If = Default Or $v_If = -1 Then $s_If = "(?i)"

    [/autoit] [autoit][/autoit] [autoit]

    ; Escape characters
    Local $s_pattern_escape = "(\.|\||\*|\?|\+|\(|\)|\{|\}|\[|\]|\^|\$|\\)"
    $s_Start = StringRegExpReplace($s_Start, $s_pattern_escape, "\\$1")
    $s_End = StringRegExpReplace($s_End, $s_pattern_escape, "\\$1")

    [/autoit] [autoit][/autoit] [autoit]

    ; If you want data from beginning then replace blank start with beginning of string
    If $s_Start = "" Then $s_Start = "\A"

    [/autoit] [autoit][/autoit] [autoit]

    ; If you want data from a start to an end then replace blank with end of string
    If $s_End = "" Then $s_End = "\z"

    [/autoit] [autoit][/autoit] [autoit]

    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)
    Return $a_ret
    EndFunc ;==>Funktionen aus UDF's

    [/autoit]


    Änderungen:
    - Man kann zwischen zwei Wetterseiten wählen
    - Das Programm stürzt nichtmehr ab, wenn die Stadt nicht gefunden werden konnte