Monitor requesting alert configuration

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.

Hi @rm2, may we know what you are trying to accomplish?

Our developers uses Python to write scripts.

I do not understand Python.

So, I inserted what I thought was most logical in the code, based on another code that had the alert.

Hello @rm2 ,

We appreciate you sharing this. We have notified our script developers regarding your post. We will get back to you as soon as possible. Thanks and have a good one!

@rm2 Just to give you a bit of info: Python uses leading white spaces (indents) as part of its execution logic to denote code blocks. You can see these in MS Code Writer, for example, by choosing Python as the code language and changing the settings to show WhiteSpaces and Tabs. Of course, you then need to know enough Python to understand where to place your code blocks.