+ Reply to Thread
Results 1 to 3 of 3

Stop Screenlock or Stop ShutDown through an Excel File

  1. #1
    Forum Contributor
    Join Date
    12-27-2012
    Location
    cebu, Philippines
    MS-Off Ver
    Excel 2016
    Posts
    210

    Stop Screenlock or Stop ShutDown through an Excel File

    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.
    don't worry, there's a lot of people that are far more confused than you
    but if you liked what i suggested. Click for me the "Add Reputation" - that way, we'd be both happy.

  2. #2
    Forum Expert
    Join Date
    12-15-2009
    Location
    Chicago, IL
    MS-Off Ver
    Microsoft Office 365
    Posts
    3,177

    Re: Stop Screenlock or Stop ShutDown through an Excel File

    the first thing came to my mind was the application.Wait statement. So ultimately you just need to trick the system that the PC is still active? If that's the case maybe this might help. The code below is going refresh the macro every 2 hours for 14 hours since the time you run the macro

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    12-27-2012
    Location
    cebu, Philippines
    MS-Off Ver
    Excel 2016
    Posts
    210

    Re: Stop Screenlock or Stop ShutDown through an Excel File

    thanks Jiejenn but that code is hardly different from the second line i posted that i tried:
    *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
    like the Ontime medthod, the Wait method cant fool a PC that there's no one in there, on the test i did -
    i set up a looping sub that calls sendkeys
    Please Login or Register  to view this content.
    this code is supposed to loop and simulate pressing the ESC key - but its a failure - there were no errors on the code, its just that, the code is not doing what i expected a "side effect" of keeping the PC active could be.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] How do I stop an Excel file from being copied
    By John Driscoll in forum Excel General
    Replies: 11
    Last Post: 02-06-2019, 05:08 PM
  2. Stop Embeded WAV File In Excel
    By tclark in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-09-2008, 09:54 AM
  3. Replies: 1
    Last Post: 10-02-2007, 04:10 AM
  4. Replies: 5
    Last Post: 09-14-2005, 02:06 PM
  5. Replies: 0
    Last Post: 03-29-2005, 11:06 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1