• Login
Community
  • Login

Presentation mode?

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
5 Posts 2 Posters 737 Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R
    roweryan
    last edited by Dec 1, 2021, 4:31 PM

    Is there a way to get Notepad++ to enter presentation mode? I would like to stop the screensaver kicking in all the time (IT set it to 5 minutes and I cannot change it). Thanks.

    A 1 Reply Last reply Dec 1, 2021, 4:41 PM Reply Quote 0
    • A
      Alan Kilborn @roweryan
      last edited by Dec 1, 2021, 4:41 PM

      @roweryan

      Ah, those I.T. clowns…always doing dumb things.

      Sounds like what you need is a mouse-jiggler.

      A 1 Reply Last reply Dec 1, 2021, 7:48 PM Reply Quote 1
      • A
        Alan Kilborn @Alan Kilborn
        last edited by PeterJones Dec 1, 2021, 8:01 PM Dec 1, 2021, 7:48 PM

        So, as I often do, I grabbed the jiggler script I use, and I cleaned it up for forum posting. The script runs via the PythonScript plugin and executes behind the scenes whenever your Notepad++ is running, preventing your computer from entering screensaver/sleep mode.

        Curiously, I notice if I have Visual Studio IDE running in addition to Notepad++, my computer WILL sleep after the I.T. prescribed timeout – I have no idea why this is.

        Here’s MouseJiggleDaemon.py:

        # -*- coding: utf-8 -*-
        
        import ctypes
        from ctypes import Structure, c_uint, sizeof, byref, POINTER, c_int
        from ctypes.wintypes import DWORD, LONG
        import threading
        import time
        
        ULONG_PTR = ctypes.POINTER(DWORD)
        
        INPUT_MOUSE          = 0
        MOUSEEVENTF_ABSOLUTE = 0x8000
        MOUSEEVENTF_MOVE     = 0x0001
        
        class MOUSEINPUT(ctypes.Structure):
            _fields_ = (
                ('dx', LONG),
                ('dy', LONG),
                ('mouseData', DWORD),
                ('dwFlags', DWORD),
                ('time', DWORD),
                ('dwExtraInfo', ULONG_PTR)
                )
        
        class _INPUTunion(ctypes.Union):
            _fields_ = (
                ('mi', MOUSEINPUT),
                )
        
        def MouseInput(flags, x, y, data): return MOUSEINPUT(x, y, data, flags, 0, None)
        def Input(structure): return INPUT(INPUT_MOUSE, _INPUTunion(mi=structure))
        def Mouse(flags, x=0, y=0, data=0): return Input(MouseInput(flags, x, y, data))
        
        class INPUT(ctypes.Structure):
            _fields_ = (
                ('type', DWORD),
                ('union', _INPUTunion)
                )
        
        def sendInput(*inputs):
            nInputs = len(inputs)
            LPINPUT = INPUT * nInputs
            pInputs = LPINPUT(*inputs)
            cbSize = ctypes.c_int(ctypes.sizeof(INPUT))
            return ctypes.windll.user32.SendInput(nInputs, pInputs, cbSize)
        
        def sendMouseMoveDeltaXY(x, y):
            flags = MOUSEEVENTF_MOVE
            event = Mouse(flags, x, y, 0)
            return sendInput(event)
        
        class MJD(object):
        
            def __init__(self):
                self.jiggle_thread = threading.Thread(target=self.jiggle_thread_function, args=(1,))
                self.jiggle_thread.daemon = True  # thread won't stop until parent ends
                self.jiggle_thread.start()
        
            def jiggle_thread_function(self, name):
                multiplier = 1
                while True:
                    sendMouseMoveDeltaXY(multiplier, multiplier)
                    multiplier *= -1
                    time.sleep(5.0)  # use this so we don't continuously use CPU time
        
        if __name__ == "__main__":
            try:
                mjd
            except NameError:
                mjd = MJD()
        

        You can set it up for automatic use by adding these two lines to your user startup.py file:

        import MouseJiggleDaemon
        mjd = MouseJiggleDaemon.MJD()
        

        and by configuring your PythonScript to run “at startup” by choosing this setting:

        Imgur

        R 1 Reply Last reply Dec 3, 2021, 6:25 PM Reply Quote 3
        • R
          roweryan @Alan Kilborn
          last edited by Dec 3, 2021, 6:25 PM

          @alan-kilborn it is working thank you.

          Maybe this could make it to mainline np++ one day :)

          A 1 Reply Last reply Dec 3, 2021, 6:30 PM Reply Quote 1
          • A
            Alan Kilborn @roweryan
            last edited by Dec 3, 2021, 6:30 PM

            @roweryan said in Presentation mode?:

            Maybe this could make it to mainline np++ one day

            It seems perfect as an add-on script.
            Glad that it works for you.

            Now you have a reason to never exit N++.
            If you need such a reason.
            :-)

            1 Reply Last reply Reply Quote 0
            • A Alan Kilborn referenced this topic on Nov 12, 2024, 1:04 AM
            • P PeterJones referenced this topic on Nov 14, 2024, 11:03 PM
            3 out of 5
            • First post
              3/5
              Last post
            The Community of users of the Notepad++ text editor.
            Powered by NodeBB | Contributors