careca Posted October 29, 2018 Share Posted October 29, 2018 Hi, this is a small little tool i made to show me some information about the weather in my area. I downloaded the icons and converted to png's, so it shows the icon for today and tomorrow, if it's sunny or cloudy etc and bellow the image it shows only 2 numbers max and min temps forecast for the day. Can be made to start with windows in the tray menu. expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=ipma.ico #AutoIt3Wrapper_UseX64=n #AutoIt3Wrapper_Res_Comment=By:careca #AutoIt3Wrapper_Res_Description=IPMA Get Weather for Sines #AutoIt3Wrapper_Res_Fileversion=1.1 #AutoIt3Wrapper_Res_SaveSource=y #AutoIt3Wrapper_Res_Icon_Add=ipma.ico #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7 #AutoIt3Wrapper_Run_Tidy=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ;============================================================================= #Region ;Include + Opt #include <IE.au3> #include <File.au3> #include <WinAPI.au3> #include <GDIPlus.au3> #include <WinAPIGdi.au3> #include <GuiTreeView.au3> #include <TrayConstants.au3> #include <ScreenCapture.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <AutoItConstants.au3> #include <WindowsConstants.au3> Opt("TrayMenuMode", 3) Opt("TrayIconHide", 0) Opt("GUIResizeMode", 1) Opt("TrayIconDebug", 1) Opt("TrayAutoPause", 0) Opt("MouseCoordMode", 2) Opt("GUIOnEventMode", 1) Opt("MustDeclareVars", 1) Opt("GUIEventOptions", 1) Opt("TrayOnEventMode", 1) Opt("ExpandEnvStrings", 1) Opt("WinDetectHiddenText", 1) #EndRegion ;Include + Opt ;============================================================================= #Region ;GuiVars + FileInstall Global $GUI, $Button_1, $hGraphic, $hGraphic2, $sString, $hFont, $aInfo, $hFormat, $hBrush, $hImage, $hImageR, $hFamily, $tLayout, $IndexDay, $RefreshItem, $wpos Global $ExitItem, $Label, $Label1, $oIE, $oDoc, $oElement1, $oElement2, $StringMid, $Split1, $Split2, $Trim, $Number, $ID, $Pic, $String, $SetString, $CfgFldr Global $Day = 0, $WS, $StartWinCheck Global Const $AC_SRC_ALPHA = 1 Global $i_x1 = 0, $i_y1 = 0, $i_x3 = 25, $i_y3 = 25 Global $aMousePos, $aMousePos2, $iMouseOver = 0 Global $InstallDir = @LocalAppDataDir & '\ipma' DirCreate($InstallDir & '\SVG') Global $cfg = $InstallDir & '\ipma.ini' Global $aProcessList = ProcessList(@AutoItExe) If $aProcessList[0][0] >= 2 Then Exit If StringInStr($cmdlineRaw, "/source") Then FileInstall(@ScriptFullPath, $InstallDir & '\' & @ScriptName, 1) Exit EndIf FileInstall("ipma.ico", $InstallDir & '\ipma.ico', 1) FileInstall('.\SVG\w_ic_d_01anim.png', $InstallDir & '\SVG\w_ic_d_01anim.png', 1) FileInstall('.\SVG\w_ic_d_02anim.png', $InstallDir & '\SVG\w_ic_d_02anim.png', 1) FileInstall('.\SVG\w_ic_d_03anim.png', $InstallDir & '\SVG\w_ic_d_03anim.png', 1) FileInstall('.\SVG\w_ic_d_04anim.png', $InstallDir & '\SVG\w_ic_d_04anim.png', 1) FileInstall('.\SVG\w_ic_d_05anim.png', $InstallDir & '\SVG\w_ic_d_05anim.png', 1) FileInstall('.\SVG\w_ic_d_06anim.png', $InstallDir & '\SVG\w_ic_d_06anim.png', 1) FileInstall('.\SVG\w_ic_d_07anim.png', $InstallDir & '\SVG\w_ic_d_07anim.png', 1) FileInstall('.\SVG\w_ic_d_08anim.png', $InstallDir & '\SVG\w_ic_d_08anim.png', 1) FileInstall('.\SVG\w_ic_d_09anim.png', $InstallDir & '\SVG\w_ic_d_09anim.png', 1) FileInstall('.\SVG\w_ic_d_10anim.png', $InstallDir & '\SVG\w_ic_d_10anim.png', 1) FileInstall('.\SVG\w_ic_d_11anim.png', $InstallDir & '\SVG\w_ic_d_11anim.png', 1) FileInstall('.\SVG\w_ic_d_12anim.png', $InstallDir & '\SVG\w_ic_d_12anim.png', 1) FileInstall('.\SVG\w_ic_d_13anim.png', $InstallDir & '\SVG\w_ic_d_13anim.png', 1) FileInstall('.\SVG\w_ic_d_14anim.png', $InstallDir & '\SVG\w_ic_d_14anim.png', 1) FileInstall('.\SVG\w_ic_d_15anim.png', $InstallDir & '\SVG\w_ic_d_15anim.png', 1) FileInstall('.\SVG\w_ic_d_16anim.png', $InstallDir & '\SVG\w_ic_d_16anim.png', 1) FileInstall('.\SVG\w_ic_d_17anim.png', $InstallDir & '\SVG\w_ic_d_17anim.png', 1) FileInstall('.\SVG\w_ic_d_18anim.png', $InstallDir & '\SVG\w_ic_d_18anim.png', 1) FileInstall('.\SVG\w_ic_d_20anim.png', $InstallDir & '\SVG\w_ic_d_20anim.png', 1) FileInstall('.\SVG\w_ic_d_23anim.png', $InstallDir & '\SVG\w_ic_d_23anim.png', 1) FileInstall('.\SVG\w_ic_d_25anim.png', $InstallDir & '\SVG\w_ic_d_25anim.png', 1) FileInstall('.\SVG\w_ic_d_26anim.png', $InstallDir & '\SVG\w_ic_d_26anim.png', 1) FileInstall('.\SVG\w_ic_d_27anim.png', $InstallDir & '\SVG\w_ic_d_27anim.png', 1) FileInstall('.\SVG\w_ic_d_28anim.png', $InstallDir & '\SVG\w_ic_d_28anim.png', 1) FileInstall('.\SVG\w_ic_d_29anim.png', $InstallDir & '\SVG\w_ic_d_29anim.png', 1) FileInstall('.\SVG\w_ic_d_30anim.png', $InstallDir & '\SVG\w_ic_d_30anim.png', 1) #EndRegion ;GuiVars + FileInstall ;============================================================================= #Region ;GUI TraySetIcon("ipma.ico") $GUI = GUICreate('IPMA', 1, 1, @DesktopWidth - 220, @DesktopHeight - 180, $WS_POPUP, $WS_EX_LAYERED + $WS_EX_TOOLWINDOW) GUISetBkColor(0x444444) GUISetOnEvent($GUI_EVENT_CLOSE, "Quit") GUISetOnEvent($GUI_EVENT_MINIMIZE, "Minimize") GUISetOnEvent($GUI_EVENT_RESTORE, "Restore") $WS = TrayCreateItem("StartWithWindows") GUICtrlSetTip(-1, 'Startup with windows', "Startup", 1) TrayItemSetOnEvent($WS, "StartWinChoose") $CfgFldr = TrayCreateItem("Config Folder") TrayItemSetOnEvent(-1, "CfgFolder") $RefreshItem = TrayCreateItem("Refresh") TrayItemSetOnEvent(-1, "Start") $ExitItem = TrayCreateItem("Close") TrayItemSetOnEvent(-1, "Quit") TraySetState(1) TraySetClick(8) TraySetOnEvent($TRAY_EVENT_MOUSEOVER, "_overTray") _Load() GUISetState() ;WinSetOnTop($GUI, '', 1) _GDIPlus_Startup() _WinAPI_SetLayeredWindowAttributes($GUI, 0xABCDEF, 240) ;0xABCDEF 0xFFFFFF 0x000000 Global $WX = 150, $WY = 110 ;WinMove($GUI, '', @DesktopWidth - 180, @DesktopHeight - 150, $WX, $WY, 1) WinMove($GUI, '', @DesktopWidth + 1000, @DesktopHeight + 1000, $WX, $WY, 1) _GuiRoundCorners($GUI, $i_x1, $i_y1, $i_x3, $i_y3) ;============================================================================= ;_SetGraphics('today', 0, 10) ;_SetGraphics('tomorrow', 70, 10) ;============================================================================= ;_SetLabel(IniRead($cfg, 'String', 'today', ''), 10, 80) ;_SetLabel(IniRead($cfg, 'String', 'tomorrow', ''), 85, 80) #EndRegion ;GUI ;============================================================================= Start() ;============================================================================= Func _SetGraphics($Day, $x, $y) $hImage = _GDIPlus_ImageLoadFromFile($InstallDir & '\SVG\w_ic_d_' & IniRead($cfg, 'ImageID', $Day, '') & 'anim.png') $hImageR = _GDIPlus_ImageResize($hImage, 100, 100, $GDIP_INTERPOLATIONMODE_HIGHQUALITYBICUBIC) $hGraphic2 = _GDIPlus_GraphicsCreateFromHWND($GUI) _GDIPlus_GraphicsDrawImageRect($hGraphic2, $hImageR, $x, $y, 75, 75) _GDIPlus_ImageDispose($hImage) _GDIPlus_BitmapDispose($hImageR) _GDIPlus_GraphicsDispose($hGraphic2) EndFunc ;==>_SetGraphics ;============================================================================= Func _SetLabel($String, $x, $y) $hGraphic = _GDIPlus_GraphicsCreateFromHWND($GUI) $hFormat = _GDIPlus_StringFormatCreate() $hFamily = _GDIPlus_FontFamilyCreate("Arial") $hFont = _GDIPlus_FontCreate($hFamily, 12, 1) $tLayout = _GDIPlus_RectFCreate($x, $y, 390, 50) $hBrush = _GDIPlus_BrushCreateSolid("0xFFFFFFFF") _GDIPlus_GraphicsDrawStringEx($hGraphic, $String, $hFont, $tLayout, $hFormat, $hBrush) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_FontDispose($hFont) _GDIPlus_BrushDispose($hBrush) EndFunc ;==>_SetLabel ;============================================================================= Func Start() TrayItemSetState($RefreshItem, $TRAY_UNCHECKED) If WinExists("Instituto") = 0 Then $oIE = _IECreate("http://www.ipma.pt/pt/index.html", 0, 0, 1, 1) _IELoadWait($oIE) ;Else ;WinActivate("Instituto") ;$oIE = _IEAttach("Instituto", 'title', 1) EndIf If Not @error Then _Temps() _Icon() _Tomorrow() _Temps() _Icon() _Today() _IEQuit($oIE) ;============================================================================= Else ;MsgBox(64 + 262144, '', 'Fail') EndIf EndFunc ;==>Start ;============================================================================= Func _overTray() $aMousePos = MouseGetPos() If Not $iMouseOver Then AdlibRegister("_checkMouseOverTrayAdlib", 100) $iMouseOver = 1 EndFunc ;==>_overTray ;============================================================================= Func _checkMouseOverTrayAdlib() $wpos = WinGetPos($GUI) $aMousePos2 = MouseGetPos() If $aMousePos2[0] <> $aMousePos[0] Or $aMousePos2[1] <> $aMousePos[1] Then $iMouseOver = 0 AdlibUnRegister("_checkMouseOverTrayAdlib") If $wpos[0] <> @DesktopWidth + 1000 Or $wpos[1] <> @DesktopHeight + 1000 Then WinMove($GUI, '', @DesktopWidth + 1000, @DesktopHeight + 1000, Null, Null, 1) EndIf Return EndIf ;============================================================================= If $wpos[0] <> @DesktopWidth - 180 Or $wpos[1] <> @DesktopHeight - 150 Then WinMove($GUI, '', @DesktopWidth - 180, @DesktopHeight - 150, $WX, $WY, 1) ;============================================================================= _SetGraphics('today', 0, 10) _SetGraphics('tomorrow', 70, 10) ;============================================================================= _SetLabel(IniRead($cfg, 'String', 'today', ''), 10, 80) _SetLabel(IniRead($cfg, 'String', 'tomorrow', ''), 85, 80) ;============================================================================= EndIf EndFunc ;==>_checkMouseOverTrayAdlib ;============================================================================= Func _Today() Local $oIE_ObjectToClick1 = _IEGetObjById($oIE, 'today') _IEAction($oIE_ObjectToClick1, 'click') _IELoadWait($oIE) ConsoleWrite(@CRLF) $Day = 0 EndFunc ;==>_Today ;============================================================================= Func _Tomorrow() Local $oIE_ObjectToClick1 = _IEGetObjById($oIE, 'tomorrow') _IEAction($oIE_ObjectToClick1, 'click') _IELoadWait($oIE) ConsoleWrite(@CRLF) $Day = 1 EndFunc ;==>_Tomorrow ;============================================================================= Func _Temps() ;Temp Max/Min $oDoc = _IEDocReadHTML($oIE) $oElement1 = StringInStr($oDoc, "color: rgb(255, 255, 255); font-weight: normal; margin-top: -20px; margin-left: 14px; z-index: 312; opacity: 0.9; transform: translate(115px, 312px); background-color: transparent;") If Not @error Then $oElement2 = StringInStr($oDoc, "color: rgb(255, 255, 255); font-weight: normal; margin-top: -20px; margin-left: 14px; z-index: 41; opacity: 0.9; transform: translate(116px, 41px); background-color: transparent;") If Not @error Then $StringMid = StringMid($oDoc, $oElement1, $oElement2 - $oElement1) $Split1 = StringSplit($StringMid, "tMax", 1) $Split2 = StringSplit($StringMid, "tMin", 1) $SetString = StringLeft(StringTrimLeft($Split1[2], 2), StringInStr($Split1[2], '<') - 3) & ' - ' & StringLeft(StringTrimLeft($Split2[2], 2), StringInStr($Split2[2], '<') - 3) If $Day = 0 Then IniWrite($cfg, 'String', 'today', $SetString) Else IniWrite($cfg, 'String', 'tomorrow', $SetString) EndIf EndIf EndIf EndFunc ;==>_Temps ;============================================================================= Func _Icon() ;Icon $oDoc = _IEDocReadHTML($oIE) $oElement1 = StringInStr($oDoc, "color: transparent; font-weight: normal; margin-top: -15px; margin-left: -15px; z-index: 312; opacity: 0.9; transform: translate(115px, 312px); background-color: transparent;") If Not @error Then $oElement2 = StringInStr($oDoc, "color: transparent; font-weight: normal; margin-top: -15px; margin-left: -15px; z-index: 41; opacity: 0.9; transform: translate(116px, 41px); background-color: transparent;") If Not @error Then $StringMid = StringMid($oDoc, $oElement1, $oElement2 - $oElement1) $Split1 = StringSplit($StringMid, "src", 1) $Trim = StringLeft(StringTrimLeft($Split1[2], 3), StringInStr($Split1[2], '<') - 5) $Number = StringMid($Trim, StringInStr($Split1[2], 'w_ic_d_') + 4, 2) If $Day = 0 Then IniWrite($cfg, 'ImageID', 'today', $Number) Else IniWrite($cfg, 'ImageID', 'tomorrow', $Number) EndIf EndIf EndIf EndFunc ;==>_Icon ;============================================================================= Func _GuiRoundCorners($h_win, $i_x1, $i_y1, $i_x3, $i_y3) Local $pos, $ret, $ret2 $pos = WinGetPos($h_win) $ret = DllCall("gdi32.dll", "long", "CreateRoundRectRgn", "long", $i_x1, "long", $i_y1, "long", $pos[2], "long", $pos[3], "long", $i_x3, "long", $i_y3) If $ret[0] Then $ret2 = DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $h_win, "long", $ret[0], "int", 1) If $ret2[0] Then Return 1 Else Return 0 EndIf Else Return 0 EndIf EndFunc ;==>_GuiRoundCorners ;============================================================================= #Region ;Window Func Minimize() WinSetState('', '', @SW_MINIMIZE) EndFunc ;==>Minimize ;============================================================================= Func Restore() WinSetState('', '', @SW_RESTORE) EndFunc ;==>Restore ;============================================================================= Func Quit() TrayItemSetState($ExitItem, $TRAY_UNCHECKED) _GDIPlus_Shutdown() _IEQuit($oIE) $StartWinCheck = TrayItemGetState($WS) If $StartWinCheck = 65 Then IniWrite($cfg, 'Options', 'StartWithWin', 1) ElseIf $StartWinCheck = 68 Then IniWrite($cfg, 'Options', 'StartWithWin', 0) EndIf Exit EndFunc ;==>Quit #EndRegion ;Window ;============================================================================= Do ;Main Sleep(100) Until GUIGetMsg() = $GUI_EVENT_CLOSE ;====================================================================================== Func StartWinChoose() $StartWinCheck = TrayItemGetState($WS) If $StartWinCheck = 68 Then StartWithWin() ElseIf $StartWinCheck = 65 Then RemFromStartWithWin() EndIf EndFunc ;==>StartWinChoose ;====================================================================================== Func StartWithWin() FileCreateShortcut(@AutoItExe, 'C:\Users\' & @UserName & '\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\ipma.lnk') If FileExists('C:\Users\' & @UserName & '\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\ipma.lnk') Then TrayItemSetState($WS, $GUI_CHECKED) IniWrite($cfg, 'Options', 'StartWithWin', 1) MsgBox(64, '', 'Application setup to start with windows') Else TrayItemSetState($WS, $GUI_UNCHECKED) IniWrite($cfg, 'Options', 'StartWithWin', 0) MsgBox(64, '', 'Could not set the application to start with windows') EndIf EndFunc ;==>StartWithWin ;====================================================================================== Func RemFromStartWithWin() FileDelete('C:\Users\' & @UserName & '\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\ipma.lnk') Sleep(100) If FileExists('C:\Users\' & @UserName & '\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\ipma.lnk') Then TrayItemSetState($WS, $GUI_CHECKED) IniWrite($cfg, 'Options', 'StartWithWin', 1) MsgBox(64, '', 'Could not remove the application from the start of windows') Else TrayItemSetState($WS, $GUI_UNCHECKED) IniWrite($cfg, 'Options', 'StartWithWin', 0) MsgBox(64, '', 'Removed application from start of windows') EndIf EndFunc ;==>RemFromStartWithWin ;====================================================================================== Func CfgFolder() TrayItemSetState($CfgFldr, $TRAY_UNCHECKED) ShellExecute($InstallDir) EndFunc ;==>CfgFolder ;============================================================================= Func _Load() If FileExists('C:\Users\' & @UserName & '\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\ipma.lnk') Then Local $aDetails = FileGetShortcut('C:\Users\' & @UserName & '\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\ipma.lnk') If Not @error Then If $aDetails[0] <> @AutoItExe Then FileDelete('C:\Users\' & @UserName & '\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\ipma.lnk') FileCreateShortcut(@AutoItExe, 'C:\Users\' & @UserName & '\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\ipma.lnk') EndIf EndIf TrayItemSetState($WS, $GUI_CHECKED) IniWrite($cfg, 'Options', 'StartWithWin', 1) Else ;TrayItemSetState($WS, $GUI_UNCHECKED) IniWrite($cfg, 'Options', 'StartWithWin', 0) EndIf EndFunc ;==>_Load ;============================================================================= Â ipma.ico SVG.rar Skeletor 1 Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe Link to comment Share on other sites More sharing options...
jcpetu Posted October 31, 2018 Share Posted October 31, 2018 Hi careca, thnks for sharing. I got the following error: $SetString = StringLeft(StringTrimLeft($Split1[2], 2), StringInStr($Split1[2], '<') - 3) & ' - ' & StringLeft(StringTrimLeft($Split2[2], 2), StringInStr($Split2[2], '<') - 3) $SetString = StringLeft(StringTrimLeft(^ ERROR Link to comment Share on other sites More sharing options...
careca Posted October 31, 2018 Author Share Posted October 31, 2018 (edited) Hi, that's interesting. Can you replace $oIE = _IECreate("http://www.ipma.pt/pt/index.html", 0, 0, 1, 1) ;to this $oIE = _IECreate("http://www.ipma.pt/pt/index.html", 0, 1, 1, 1) ;to make the window visible, this way you can see the site loading up. One other thing is this function, if you could try it like this it'd be nice Func _Temps() ;Temp Max/Min $oDoc = _IEDocReadHTML($oIE) $oElement1 = StringInStr($oDoc, "px; z-index: 312; opacity: 0.9; transform:") If $oElement1 <> 0 Then $oElement2 = StringInStr($oDoc, "px; z-index: 41; opacity: 0.9; transform:") If $oElement2 <> 0 Then $StringMid = StringMid($oDoc, $oElement1, $oElement2 - $oElement1) $Split1 = StringSplit($StringMid, "tMax", 1) $Split2 = StringSplit($StringMid, "tMin", 1) $SetString = StringLeft(StringTrimLeft($Split1[2], 2), StringInStr($Split1[2], '<') - 3) & ' - ' & StringLeft(StringTrimLeft($Split2[2], 2), StringInStr($Split2[2], '<') - 3) If $Day = 0 Then IniWrite($cfg, 'String', 'today', $SetString) Else IniWrite($cfg, 'String', 'tomorrow', $SetString) EndIf Else MsgBox(64 + 262144, '', 'Fail oElement2') EndIf Else MsgBox(64 + 262144, '', 'Fail oElement1') EndIf EndFunc ;==>_Temps function is untested, but seems fine Edited October 31, 2018 by careca Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe Link to comment Share on other sites More sharing options...
jcpetu Posted November 1, 2018 Share Posted November 1, 2018 Hi careca, I did the replacement and got this message: Then the following error: --> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop --> IE.au3 T3.0-2 Error from function _IEDocReadHTML, $_IESTATUS_InvalidDataType --> IE.au3 T3.0-2 Error from function _IEDocReadHTML, $_IESTATUS_InvalidDataType "C:\Temp\Programacion\A3\Whether\Weather-Info.au3" (248) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: $Trim = StringLeft(StringTrimLeft($Split1[2], 3), StringInStr($Split1[2], '<') - 5) $Trim = StringLeft(StringTrimLeft(^ ERROR Â Link to comment Share on other sites More sharing options...
careca Posted November 1, 2018 Author Share Posted November 1, 2018 Does the site look like this to you when you open in a browser? Maybe im overthinking the issue, do you have IE installed on the pc? Can you try a simpler script to try pinpoint the issue? expandcollapse popup#include <IE.au3> #include <File.au3> #include <MsgBoxConstants.au3> Local $VisibleWin = 1 $oIE = _IECreate("http://www.ipma.pt/pt/index.html", 0, $VisibleWin, 1, 1) If $oIE <> @error Then _IELoadWait($oIE, 2000, 2000) _Temps() _IEQuit($oIE) Else MsgBox(64 + 262144, '', 'Failed on _IECreate') EndIf ;============================================================================= Func _Temps() ;Temp Max/Min $oDoc = _IEDocReadHTML($oIE) If Not @error Then MsgBox(64 + 262144, '', $oDoc) $oElement1 = StringInStr($oDoc, "color: rgb(255, 255, 255); font-weight: normal; margin-top: -20px; margin-left: 14px; z-index: 312; opacity: 0.9; transform: translate(115px, 312px); background-color: transparent;") If $oElement1 <> 0 Then $oElement2 = StringInStr($oDoc, "color: rgb(255, 255, 255); font-weight: normal; margin-top: -20px; margin-left: 14px; z-index: 41; opacity: 0.9; transform: translate(116px, 41px); background-color: transparent;") If $oElement2 <> 0 Then ConsoleWrite('$oElement1 - '& $oElement1&@CRLF&'$oElement2 - '& $oElement2 &@CRLF) $StringMid = StringMid($oDoc, $oElement1, $oElement2 - $oElement1) ConsoleWrite('$StringMid - '& $StringMid &@CRLF) $Split1 = StringSplit($StringMid, "tMax", 1) _ArrayDisplay($Split1, '$Split1') $Split2 = StringSplit($StringMid, "tMin", 1) _ArrayDisplay($Split2, '$Split2') ConsoleWrite($Split1[2]&@CRLF) $SetString = 'tMax = '&StringLeft(StringTrimLeft($Split1[2], 2), StringInStr($Split1[2], '<') - 3) & @CRLF& 'tMin = ' & StringLeft(StringTrimLeft($Split2[2], 2), StringInStr($Split2[2], '<') - 3) MsgBox(64 + 262144, '$SetString', $SetString) Else MsgBox(64 + 262144, '', 'Fail oElement2') EndIf Else MsgBox(64 + 262144, '', 'Fail oElement1') EndIf Else MsgBox(64 + 262144, '', 'Failed on _IEDocReadHTML') EndIf EndFunc ;==>_Example1 ;============================================================================= Error checks ftw. Since the error you got was in the first StringInStr, it leaves only _IEDocReadHTML or _IECreate. Thanks Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe Link to comment Share on other sites More sharing options...
jcpetu Posted November 4, 2018 Share Posted November 4, 2018 Hi careca, thanks a lot for your time and sorry for the delay but It was impossible to test it before. I got the html and then :  Link to comment Share on other sites More sharing options...
careca Posted November 4, 2018 Author Share Posted November 4, 2018 If you see the map, it's obvious why you get the error, somehow you're not getting the information from the site, so then all fails, compare the image with what is supposed to show up. Maybe there's some AV blocking the network for the script, maybe there is connectivity issues, i dont know. But as the map shows it's gonna be impossible to retrieve the values. Not a script issue. Maybe a firewall, maybe the AV. Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe Link to comment Share on other sites More sharing options...
jcpetu Posted November 4, 2018 Share Posted November 4, 2018 careca, thanks a lot for your time. I'll check the AV and FW to see if there is any issue. thanks again. Link to comment Share on other sites More sharing options...
careca Posted November 7, 2018 Author Share Posted November 7, 2018 Im curious to know if you ever found what caused the issue. Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe Link to comment Share on other sites More sharing options...
jcpetu Posted November 7, 2018 Share Posted November 7, 2018 No, I didn't really have much time to test. Â Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now