Prevent windows from locking code not working

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Skudge
Posts: 2
Joined: 23 Jul 2021, 07:33

Prevent windows from locking code not working

23 Jul 2021, 07:47

Hi all,

I want to prevent windows from auto locking (unable to change as decided by group policy :problem:). The simplest solution I can think of is getting AHK to auto move the mouse as set intervals, so I've found the following code online to add into my AHK and it just doesn't seem to want to work, I've tried to bind the below to the F8 key by adding 'F8::' to the start. If it matters, I'm using a portable version on version number 1.1.30.03.

Code: Select all

F8::
CoordMode, Mouse, Screen
Loop
{
    ; Move mouse
    MouseMove, 1, 1, 0, R
    ; Replace mouse to its original location
    MouseMove, -1, -1, 0, R
    ; Wait before moving the mouse again
    Sleep, 3000
}
return
I'm hoping someone could suggest where I may be going wrong? All my other scripts work fine, just this one doesn't.
User avatar
mikeyww
Posts: 26945
Joined: 09 Sep 2014, 18:38

Re: Prevent windows from locking code not working

23 Jul 2021, 08:21

The mouse is moving by one pixel and then instantaneously back to its original position. If you are in disbelief about it, change the 1 to a 10.

A working script does not, by itself, mean that it will negate your computer's policy or your employer's policy.
Skudge
Posts: 2
Joined: 23 Jul 2021, 07:33

Re: Prevent windows from locking code not working

23 Jul 2021, 08:39

I have tried various instances of changing the sleep seconds and also changing the amount the mouse moves by but even still it doesn't seem to work. When I say 'doesn't work', I mean the mouse doesn't make any visual movements so it implies the script is not in effect at all, not that it doesn't work at not getting around the group policy.
User avatar
mikeyww
Posts: 26945
Joined: 09 Sep 2014, 18:38

Re: Prevent windows from locking code not working

23 Jul 2021, 09:43

OK. Try the following.

Code: Select all

If !A_IsAdmin && !RegExMatch(DllCall("GetCommandLine", "str"), " /restart(?!\S)") {
 Try Run *RunAs "%A_AhkPath%" /restart "%A_ScriptFullPath%"
 ExitApp
}
Loop {
 MouseMove, 100, 100,, R
 Sleep, 500
 MouseMove, -100, -100,, R
 Sleep, 500
}
Esc::ExitApp

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Araphen, DaveT1, Descolada, Google [Bot], KolaBorat and 175 guests