Search the Community
Showing results for tags 'trayhover'.
-
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. #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