I’ve found some scripts that display alert request.
As I do not know the language it is written in, I look for another script that contains an alert and I copy the code for the script I want to add.
The Activate high performance power plan script (https://scripts.itarian.com/frontend/web/topic/activate-high-performance-power-plan) has the following code:
import ctypes
import os
class disable_file_system_redirection:
_disable = ctypes.windll.kernel32.Wow64DisableWow64FsRedirection
_revert = ctypes.windll.kernel32.Wow64RevertWow64FsRedirection
def __enter__(self):
self.old_value = ctypes.c_long()
self.success = self._disable(ctypes.byref(self.old_value))
def __exit__(self, type, value, traceback):
if self.success:
self._revert(self.old_value)
with disable_file_system_redirection():
out=os.popen('powercfg.exe /setactive 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c').read()
print(out)
When I enter the code in the monitor I’m creating, I can not save because it asks to create the alert.
I modified the code to:
import ctypes
import os
def alert(arg):
sys.stderr.write("%d%d%d" % (arg, arg, arg))
class disable_file_system_redirection:
_disable = ctypes.windll.kernel32.Wow64DisableWow64FsRedirection
_revert = ctypes.windll.kernel32.Wow64RevertWow64FsRedirection
def __enter__(self):
self.old_value = ctypes.c_long()
self.success = self._disable(ctypes.byref(self.old_value))
def __exit__(self, type, value, traceback):
if self.success:
self._revert(self.old_value)
with disable_file_system_redirection():
out=os.popen('powercfg.exe /setactive 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c').read()
print(out)
alert(1)
alert(0)
When it runs, it generates the error log:
Data: Custom Script Monitor: Standard Output: - Error Output: File “”, line 20
alert (1)
^
IndentationError: unexpected indent
If you can help, I will be immensely grateful.