Freeze Windows clock

Asked

Viewed 758 times

0

It would be possible to freeze the Windows clock with Python?

If so, which library does it?

  • 5

    Could you elaborate on your question?

  • Take a look at [tour]. You can accept an answer if it solved your problem. You can vote on every post on the site as well. Did any help you more? You need something to be improved?

  • Freeze? You’d need to be going back 1s every second. That’s what you want?

1 answer

2

I may not have understood what you want, but from what I understand, it’s not possible. No programming language with any library has the capacity to make such a profound change in the operating system. You can only change something in it if it allows, this is one of the reasons for an operating system.

I cannot imagine a practical use for this, but it is possible to obtain a near result of this by successively changing the time of the computer. This is what Windows allows. You could create a loop (which would not allow the application to do other tasks, although you can allow this) to repeat the change:

import datetime
import time 
time_tuple = time.localtime(time.time())
while True:
    win_set_time(time_tuple)
    time.sleep(1) # espera 1 segundo

def win_set_time(time_tuple):
    import pywin32
    dayOfWeek = datetime.datetime(time_tuple).isocalendar()[2]
    pywin32.SetSystemTime(time_tuple[:2] + (dayOfWeek,) + time_tuple[2:])

I put in the Github for future reference.

Code removed of that response in the OS.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.