Switch dark/light modes at certain times

My windows is permanently in dark mode,
but i want to have Dopus switching between Light mode and Dark modes at specific times of the day

i currently have a button that manually toggles ok with

Set DARKMODE = toggle

but i'm not sure how to go about automating that with a script for certain timespans

You could have an OnStartup script that never returns and waits for the appropriate time, although I'm not a fan of that as it could delay startup (the scripting system isn't designed for scripts that never return from events).

A better way would be:

  • OnStartup script that sets up the theme/mode you want when Opus launches.

  • Using the Task Scheduler in Windows (or similar) to schedule commands which change the theme.

The Task Scheduler part is simple if Opus is always running. Just make tasks to turn Dark Mode on and off similar to this:

"C:\Program Files\GPSoftware\Directory Opus\dopusrt.exe" /cmd Set DARKMODE=on

If Opus isn't always running, that will launch it, which you might not want. In that case you could have Task Scheduler run something that tests if Opus is running first. Here's some VBScript I had already which shows one way to do that:

RestartOpus script
option explicit

Dim OpusInstallPath
OpusInstallPath = "C:\Program Files\GPSoftware\Directory Opus"

Private Function ProcessIsRunning( wmi, strProcess )
	Dim colProcessList

	Set colProcessList = wmi.Execquery("Select * from Win32_Process Where Name ='" & strProcess & "'")

	If colProcessList.Count > 0 Then
		ProcessIsRunning = True
		ProcessIsRunning = False
	End If

	Set colProcessList = Nothing
End Function

Private Function WaitForProcess( wmi, strProcess )
	Dim i

	WaitForProcess = False

	For i = 0 to 100
		If ProcessIsRunning( wmi, strProcess ) Then
			WScript.Sleep 200
			WaitForProcess = True
			Exit For
		End If
End Function

' ****************************************************************************
' *** MAIN *******************************************************************
' ****************************************************************************

Dim Shell
Set Shell = CreateObject("WScript.Shell")

' Shut down dopusrt.exe and dopus.exe if they are running.

Dim wmi
Set wmi = Getobject("Winmgmts:")

If ProcessIsRunning(wmi, "dopusrt.exe") Then
	Shell.Run """" & OpusInstallPath & "\dopusrt.exe"" /dblclk=off", 1, TRUE
End If

If ProcessIsRunning(wmi, "dopus.exe") Then
	Shell.Run """" & OpusInstallPath & "\dopusrt.exe"" /CMD Close PROGRAM", 1, TRUE
End If

' Wait for dopusrt.exe and dopus.exe to finish shutting down.

Dim AllStopped
AllStopped = False

If WaitForProcess(wmi, "dopus.exe") Then
	If WaitForProcess(wmi, "dopusrt.exe") Then
		AllStopped = True
	End If
End If

If Not AllStopped Then
	MsgBox WScript.ScriptName & ": Old instance of Opus is still running"
	WScript.Quit 1
End If

Shell.CurrentDirectory = OpusInstallPath

Shell.Run """" & OpusInstallPath & "\dopusrt.exe"" /dblclk"
Shell.Run """" & OpusInstallPath & "\dopus.exe"" noautolister"

' MsgBox WScript.ScriptName & ": Opus restarted"

(Also, if Windows is set to change modes at different times during the day, Opus will automatically react to that as long as "Use system setting" is selected in Dark Mode prefs.)