i am in need of keeping my work PC on until the next day i need to use it (more than 12 hours), but IT has set it to automatically lock the screen and then later Shutdown (after about 2 hours).
so i tried several ways to avoid this:
*clicking the Windows start menu, then sticking a folded piece of paper between the Arrow Up and Down on the keyboard so the cursor keeps looping through the options (Simulating Keyboard activity)
-Works but is a BAD idea when i need to remotely access the PC
*tried creating an excel file that loops through the "ontime" method in VBA then initiating the sendkeys method every 5 mins (for ESC key)
-they say the sendkeys simulate keystrokes, but this method failed and my computer turned off
*tried going to the registry and adding a "noclose" key to disable shut down
-it disabled my shutdown Button But still the computer turned off
*a co-worker suggested that I install a program "Caffeine" that should keep my PC on
-this works but is a very good way to loose my job - not worth trying
*create another macro file that can keep the screen from locking
- working and is perfectly Suitable for the situation
the last option above in green is favorable to me, the problem is the file is getting an Error when i close it, so i may end up with a corrupted file later on. on my test (ran 5-6 hours) it kept my PC on the whole time without any user contact and no other programs opened (only that one excel file)
i snatched the code i put in it from some random site i now forgot. from what i understood, windows programatically sends a query to each program for any user related activity through the API "CallWindowProcA". the code is set to loop on itself after the Userform is launched.
Keep V2.xlsm
the attached file has it - on module 1 - that function "WindowProc" is whats looping by itself
(i tried adding conditional statements to it - like that if range B1 = "Close" it would exit function and avoid redoing itself BUT i'm getting an Error and excel tries to repair the file after it freezes
the last thing i need it to do is being able to close the file without getting errors from excel and freezing.
Bookmarks