The code is included. Take a look for yourself...Pesoen wrote:am i the only one who gets a trojan warning? and warnings about the program trying to connect to the internet?

The code is included. Take a look for yourself...Pesoen wrote:am i the only one who gets a trojan warning? and warnings about the program trying to connect to the internet?
Code: Select all
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=RainRez.ico
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <Misc.au3>
#include <Constants.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
#include "lib\desktopworkarea.au3"
Opt("TrayOnEventMode",1)
Opt("TrayMenuMode",3)
_Singleton("RainRez", 0)
$ResolutionMethod = IniRead("RainRez.cfg", "RainRez", "ResolutionMethod", "" )
If $ResolutionMethod <> "Native" and $ResolutionMethod <> "Virtual" Then
$ResolutionMethod = "NativeAspect"
EndIf
Local $OldWidth
Local $OldHeight
Local $OldAspect
GetOldResolution($OldWidth, $OldHeight)
$OldAspectValue = $OldWidth/$OldHeight
GetOldAspect($OldAspect)
$WorkingWidth = _GetworkingAreaWidth()
$WorkingHeight = _GetworkingAreaHeight()
$OldWorkingWidth = _GetworkingAreaWidth()
$OldWorkingHeight = _GetworkingAreaHeight()
$SleepCount = 0
$LayoutToLoad = "Unchanged"
$BattStatus = GetBattery()
$BattOld = $BattStatus
$BattWord = "Plugged in"
If ($BattStatus = 0) Then
$BattWord = "Discharging"
EndIf
$RainmeterPath = IniRead("RainRez.cfg", "RainRez", "RainmeterPath", "")
If StringRight($RainmeterPath, 1) <> "\" Then
$RainmeterPath = $RainmeterPath & "\"
EndIf
If not FileExists($RainmeterPath & "Rainmeter.exe") Then
MsgBox(16, "RainRez Error", "Unable to locate " & @CRLF & $RainmeterPath & "Rainmeter.exe" & @CRLF & @CRLF & "Ensure you have set RainmeterPath in RainRez.cfg to the location of your Rainmeter executable files." & @CRLF & @CRLF & "This will normally be C:\Program Files\Rainmeter")
Exit
EndIf
If Not ProcessExists("Rainmeter.exe") Then
$DefaultLayout = IniRead("RainRez.cfg", "RainRez", "Default", "" )
$BattLayout = IniRead("RainRez.cfg", "RainRez", "Battery", "" )
$ResLayout = IniRead("RainRez.cfg", "RainRez", $OldWidth & "x" & $OldHeight, "" )
;DEBUG
;MsgBox($MB_SYSTEMMODAL, "DEBUG (Res Layout)", "Defined ResLayout: " & $ResLayout, 10)
$AspectLayout = IniRead("RainRez.cfg", "RainRez", $OldAspect, "" )
$LayoutMethod = IniRead("RainRez.cfg", "RainRez", "LayoutMethod", "" )
If $LayoutMethod <> "Resolution" and $LayoutMethod <> "Aspect" Then
$LayoutMethod = "Aspect"
EndIf
If $ResLayout = "" Then
$ResLayout = $DefaultLayout
; $ResLayout = $AspectLayout ; -- If the resolution isn't found in the .cfg file, then fall back to AspectLayout.
EndIf
If $BattLayout <> "" and $BattStatus = 0 Then
$LayoutToLoad = $BattLayout
ElseIf $LayoutMethod = "Aspect" Then
$LayoutToLoad = $AspectLayout
ElseIf $LayoutMethod = "Resolution" Then
$LayoutToLoad = $ResLayout
Else
$LayoutToLoad = $DefaultLayout
EndIf
;DEBUG
;MsgBox($MB_SYSTEMMODAL, "DEBUG (Load Rainmeter, Select Layout)", "Default Layout: " & $DefaultLayout & @CRLF & "Layout Method: " & $LayoutMethod & @CRLF & "Battery Layout: " &$BattLayout & @CRLF & "OldAspect: " & @CRLF & "AspectLayout: " & $AspectLayout & @CRLF & "ResLayout: " & $ResLayout & @CRLF & "LayoutToLoad: " & $LayoutToLoad , 10)
ShellExecute(chr(34) & $RainmeterPath & "Rainmeter.exe" & chr(34), "!LoadLayout " & chr(34) & $LayoutToLoad & chr(34))
EndIf
$TrayClick = TrayCreateItem("Refresh")
TrayItemSetOnEvent(-1,"Refresh")
;$TrayClick = TrayCreateItem("Manage RM")
;TrayItemSetOnEvent(-1,"OpenSkins")
;$TrayClick = TrayCreateItem("Config")
;TrayItemSetOnEvent(-1,"Openconfig")
$TrayClick = TrayCreateItem("Exit RainRez")
TrayItemSetOnEvent(-1,"ExitRainRez")
$TrayClick = TrayCreateItem("Exit Rainmeter")
TrayItemSetOnEvent(-1,"ExitRainmeter")
TraySetIcon("RainRez.ico")
Local $CurrentWidth
Local $CurrentHeight
Local $CurrentAspect
GetCurrentResolution($CurrentWidth, $CurrentHeight)
$CurrentAspectValue = $CurrentWidth/$CurrentHeight
GetCurrentAspect($CurrentAspect)
$WorkingWidth = _GetworkingAreaWidth()
$WorkingHeight = _GetworkingAreaHeight()
UpdateToolTip()
;
; Re-launch Rainmeter if it isn't running.
;
While 1
Sleep(5000)
$BattStatus = GetBattery()
if ($BattStatus = 0) Then
$BattWord = "Discharging"
Else
$BattWord = "Plugged in"
EndIf
GetCurrentResolution($CurrentWidth, $CurrentHeight)
$CurrentAspectValue = $CurrentWidth/$CurrentHeight
GetCurrentAspect($CurrentAspect)
$WorkingWidth = _GetworkingAreaWidth()
$WorkingHeight = _GetworkingAreaHeight()
If Not ProcessExists("Rainmeter.exe") Then
ShellExecute(chr(34) & $RainmeterPath & "Rainmeter.exe" & chr(34))
EndIf
If $CurrentWidth <> $OldWidth or $CurrentHeight <> $OldHeight or $BattStatus <> $BattOld Then
$DefaultLayout = IniRead("RainRez.cfg", "RainRez", "Default", "" )
$BattLayout = IniRead("RainRez.cfg", "RainRez", "Battery", "" )
$ResLayout = IniRead("RainRez.cfg", "RainRez", $OldWidth & "x" & $OldHeight, "" )
$AspectLayout = IniRead("RainRez.cfg", "RainRez", $OldAspect, "" )
$LayoutMethod = IniRead("RainRez.cfg", "RainRez", "LayoutMethod", "" )
If $LayoutMethod <> "Resolution" and $LayoutMethod <> "Aspect" Then
$LayoutMethod = "Aspect"
EndIf
If $ResLayout = "" Then
$ResLayout = $DefaultLayout
EndIf
If $BattLayout <> "" and $BattStatus = 0 Then
$LayoutToLoad = $BattLayout
ElseIf $LayoutMethod = "Aspect" Then
$LayoutToLoad = $AspectLayout
ElseIf $LayoutMethod = "Resolution" Then
$LayoutToLoad = $ResLayout
Else
$LayoutToLoad = $DefaultLayout
EndIf
ShellExecute(chr(34) & $RainmeterPath & "Rainmeter.exe" & chr(34), "!LoadLayout " & chr(34) & $LayoutToLoad & chr(34))
ShellExecute(chr(34) & $RainmeterPath & "Rainmeter.exe" & chr(34), "!RefreshApp")
$OldHeight = _WinAPI_GetSystemMetrics($SM_CYVIRTUALSCREEN)
$OldWidth = _WinAPI_GetSystemMetrics($SM_CXVIRTUALSCREEN)
$OldWorkingWidth = _GetworkingAreaWidth()
$OldWorkingHeight = _GetworkingAreaHeight()
$BattOld = GetBattery()
UpdateToolTip()
EndIf
If $WorkingWidth <> $OldWorkingWidth or $WorkingHeight <> $OldWorkingHeight Then
Refresh()
$OldWorkingWidth = _GetworkingAreaWidth()
$OldWorkingHeight = _GetworkingAreaHeight()
UpdateToolTip()
EndIf
WEnd
Exit
;Func OpenConfig()
; ShellExecute(chr(34) & "RainRez.cfg" & chr(34))
; EndFunc
;Func OpenSkins()
; ShellExecute(chr(34) & $RainmeterPath & "Rainmeter.exe" & chr(34), "!Manage skins")
;EndFunc
;Func OpenLayouts()
; ShellExecute(chr(34) & $RainmeterPath & "Rainmeter.exe" & chr(34), "!Manage layouts")
;EndFunc
Func Refresh()
ShellExecute(chr(34) & $RainmeterPath & "Rainmeter.exe" & chr(34), "!RefreshApp")
EndFunc
Func UpdateToolTip()
TraySetToolTip("RainRez" & @CRLF & "Layout: " & $LayoutToLoad & @CRLF & "Working Area: " & _GetworkingAreaWidth() & "x" & _GetworkingAreaHeight() & @CRLF & "Resolution: " & $CurrentWidth & "x" & $CurrentHeight & @CRLF & "Aspect Ratio: " & $CurrentAspect & @CRLF & "Power/Battery: " & $BattWord)
EndFunc
Func GetBattery()
;Thanks to PsaltyDS for the script I used as a reference (http://www.autoitscript.com/forum/index.php?showtopic=10993&view=findpost&p=531988)
$struct = DllStructCreate("ubyte;ubyte;ubyte;ubyte;ulong;ulong")
$call = DllCall("kernel32.dll", "int", "GetSystemPowerStatus", "ptr", DllStructGetPtr($struct))
If @error Then
Return -1
EndIf
If Not $call[0] Then
Return -1
EndIf
Return DllStructGetData($struct, 1)
EndFunc
Func GetOldResolution(ByRef $OldWidth, ByRef $OldHeight)
If $ResolutionMethod = "Virtual" Then
$OldWidth = _WinAPI_GetSystemMetrics($SM_CXVIRTUALSCREEN)
$OldHeight = _WinAPI_GetSystemMetrics($SM_CYVIRTUALSCREEN)
ElseIf $ResolutionMethod = "Native" Then
$OldWidth = @DesktopWidth
$OldHeight = @DesktopHeight
Else
$OldWidth = @DesktopWidth
$OldHeight = @DesktopHeight
EndIf
EndFunc
Func GetCurrentResolution(ByRef $CurrentWidth, ByRef $CurrentHeight)
If $ResolutionMethod = "Virtual" Then
$CurrentWidth = _WinAPI_GetSystemMetrics($SM_CXVIRTUALSCREEN)
$CurrentHeight = _WinAPI_GetSystemMetrics($SM_CYVIRTUALSCREEN)
ElseIf $ResolutionMethod = "Native" Then
$CurrentWidth = @DesktopWidth
$CurrentHeight = @DesktopHeight
Else
$CurrentWidth = @DesktopWidth
$CurrentHeight = @DesktopHeight
EndIf
EndFunc
Func GetOldAspect(ByRef $OldAspect)
If $OldAspectValue > "1.3334" Then
$OldAspect = "Wide"
Else
$OldAspect = "Standard"
EndIf
EndFunc
Func GetCurrentAspect(ByRef $CurrentAspect)
If $CurrentAspectValue > "1.3334" Then
$CurrentAspect = "Wide"
Else
$CurrentAspect = "Standard"
EndIf
EndFunc
Func ExitRainmeter()
ShellExecute(chr(34) & $RainmeterPath & "Tools\nircmd.exe" & chr(34), "killprocess Rainmeter.exe" & chr(34))
Exit
EndFunc
Func ExitRainRez()
Exit
EndFunc ;StartRainmeter
Code: Select all
[RainRez]
RainmeterPath=C:\Utils\Rainmeter
ResolutionMethod=Native
; ^-- Native / Virtual
; Native/Virtual will determine how the resolution
; is calculated, using either the Native resolution, or the Virtual resolution.
LayoutMethod=Aspect
; Resolution/Aspect will set the layout selection method
; using either the detected resolutions (based on ResolutionMethod),
; or by determining if the aspect ratio is Wide or Standard, then load the
; layout as defined in the .CFG for Wide/Standard aspect settings respectively,
; or load the resolution layout. If a layout for the resolution is not defined
; in the .CFG, we fall back to use the defined Default layout.
; (if the numberator divided by denominator > 1.3334 then
; it's considered a wide aspect ratio)
Default=4.3
Battery=Battery
Wide=16.9
Standard=4.3
10240x4320=16.9
8192x4608=16.9
5120x2880=16.9
5120x2160=16.9
3440x1440=16.9
3200x2400=4.3
3000x2000=4.3
2736x1824=4.3
2560x1600=4.3
2048x1152=16.9
1920x1200=4.3
1920x1080=16.9
1680x1050=16.9
1440x900=16.9
1280x1024=4.3
1280x800=16.9
1280x768=16.9
1024x768=4.3
800x600=4.3
640x480=640x480
I don't mean to answer your question with a question (sorry!), but is there any particular reason why you are using a scheduled task to start RainRez instead of using the suggestion given in the next to last paragraph in the initial post (i.e., run RainRez when you start your machine instead of Rainmeter).teiji wrote: ↑January 10th, 2023, 12:56 am Hello,
When trying to run Rainrez.exe from the Task Scheduler, it always gives a "Unable to locate \Rainmeter.exe" error. Yes, I've set the RainmeterPath="C:\Program Files\Rainmeter" in cfg. And when I run Rainrez.exe manually, it works fine with no error. Why is this?
I notice whenever Rainrez/Rainmeter autostart with my PC, some of my skins doesn't work correctly (the ones with plugins and depending on 3rd party software like HWINFO/Afterburner). But if I refresh the skin afterward, it works like normal. So I want to delay Rainrez and Rainmeter from autostart by 1-2min, so those 3rd party software load first and then Rainmeter+Rainrez can run after.SilverAzide wrote: ↑January 10th, 2023, 3:05 am I don't mean to answer your question with a question (sorry!), but is there any particular reason why you are using a scheduled task to start RainRez instead of using the suggestion given in the next to last paragraph in the initial post (i.e., run RainRez when you start your machine instead of Rainmeter).
Ah, I see, that makes sense. (Although the proper fix is the author(s) of the skins you are using should properly handle this situation and not force you to do a refresh once HWiNFO/Afterburner are loaded.)teiji wrote: ↑January 10th, 2023, 3:26 am I notice whenever Rainrez/Rainmeter autostart with my PC, some of my skins doesn't work correctly (the ones with plugins and depending on 3rd party software like HWINFO/Afterburner). But if I refresh the skin afterward, it works like normal. So I want to delay Rainrez and Rainmeter from autostart by 1-2min, so those 3rd party software load first and then Rainmeter+Rainrez can run after.
Thanks for the replies. Ashamed to say but I'm the author of the skin actually. (I'm still new to Rainmeter coding.)SilverAzide wrote: ↑January 10th, 2023, 5:32 pm Ah, I see, that makes sense. (Although the proper fix is the author(s) of the skins you are using should properly handle this situation and not force you to do a refresh once HWiNFO/Afterburner are loaded.)
So it looks like there is a glitch/bug in RainRez where it is not able to find the .cfg file if the current working directory is not the folder where the RainRez executable is installed. When you create a scheduled task, it runs the app without changing the current working directory (which I assume is C:\Windows\System32, but could be anything).
Here's a workaround:
Use File Explorer to navigate to the location where you installed RainRez. Right-click RainRez.exe and from the context menu and select "Create Shortcut". By default, the shortcut you create from doing this should have the "Start in" option set to the folder where the executable is located (you can verify this if you want). Next, edit your scheduled task and change the executable path from "C:\whatever your path is\RainRez.exe" to "C:\whatever your path is\RainRez.lnk". In other words, run the shortcut instead of the executable.
I think this should resolve your issue. Let us know if not. Perhaps jsmorley can release a tweak to fix this glitch someday. Finally, you should know that you can replicate everything that RainRez does by creating a special (and simple) invisible "layout controller" skin that can switch layouts just like RainRez does. You could even add delays for HWiNFO and etc. if you wanted.