Jump to content

Recommended Posts

Posted (edited)

I am trying to do a script which makes the screensaver have a timeout and the alternative to turn it off.

My problem is when I try to send keystrokes (Send() ) the program doesn't do anything.

EDIT: The program I am trying to change settings in are the Local Group Policy Editor(gpedit.msc)

All help is appreciated :mellow:

#region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Outfile_x64=C:\Installationwizard\Remove_Screensaver.exe
#AutoIt3Wrapper_Compression=4
#endregion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#region ### START Koda GUI section ### Form=
$Form1_1 = GUICreate("Form1", 287, 145, 252, 147)
$TimeoutInput = GUICtrlCreateInput("TimeoutInput", 104, 64, 121, 21)
$Label = GUICtrlCreateLabel("How many second timeout?", 104, 40, 135, 17)
$ON = GUICtrlCreateRadio("ON", 48, 40, 41, 17)
$OFF = GUICtrlCreateRadio("OFF", 48, 64, 41, 17)
$Exit_button = GUICtrlCreateButton("Exit", 144, 104, 75, 25)
$Start_button = GUICtrlCreateButton("Start", 56, 104, 75, 25)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###
Global $var[3]
$var[0] = 0
$var[1] = 0
$var[2] = 0
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
  Case $OFF
   $var[0] = 1
  Case $ON
   $var[1] = 1
  Case $Start_button
   $var[2] = GUICtrlRead($TimeoutInput)
   ShellExecute("gpedit.msc", "", "C:\Windows\system32\")
   winwaitActive("Local Group Policy Editor", "", 3000)
   Send("{LEFT}")
   Sleep(300)
   Send("{RIGHT}")
   Sleep(300)
   Send("{DOWN 2}")
   Sleep(300)
   Send("{RIGHT}")
   Sleep(300)
   Send("{DOWN 3}")
   Sleep(300)
   Send("{RIGHT}")
   Sleep(300)
   Send("{DOWN}")
   Sleep(300)
   Send("{RIGHT}")
   Sleep(300)
   Send("{DOWN 3}")
   Sleep(300)
   Send("{TAB}")
   Sleep(300)
   If $var[0] = 1 Then
    Send("{DOWN 3}")
    Sleep(300)
    Send("{ENTER}")
    Sleep(300)
    Send("{TAB 2}")
    Sleep(300)
    Send("{DOWN 2}")
    Sleep(300)
    Send("{ENTER}")
    Sleep(300)
    ProcessClose("mmc.exe")
   EndIf
   If $var[1] = 1 Then
    Send("{DOWN 3}")
    Sleep(300)
    Send("{ENTER}")
    Sleep(300)
    Send("{TAB 2}")
    Sleep(300)
    Send("{DOWN 1}")
    Sleep(300)
    Send("{ENTER}")
    Sleep(300)
    Send("{DOWN 9}")
    Sleep(300)
    Send("{ENTER}")
    Sleep(300)
    Send("{TAB 2}")
    Sleep(300)
    Send("{DOWN}")
    Sleep(300)
    Send("{TAB 3}")
    Sleep(300)
    Send("^a")
    Sleep(300)
    Send("{DEL}")
    Sleep(300)
    Send($var[2])
    Sleep(300)
    Send("{ENTER}")
    Sleep(300)
    ProcessClose("mmc.exe")
   EndIf
  Case $Exit_button
   Exit
 
EndSwitch
WEnd

Kind Regards,

Akarillon

Edited by Akarillon

Challenge accepted!

Posted

I think some Windows Vista/7 system tools are in a secure desktop (like logonui.exe) that prevents virtual key presses. I'd google it myself if I wasn't already busy multitasking with school work.

My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.

My Projects

WhyNotWin11
Cisco FinesseGithubIRC UDFWindowEx UDF

 

Posted

I think it would be better to find which registry settings are changed and do a REGWRITE(). Send() is not a good automation practice.

Posted

  On 9/7/2011 at 12:33 PM, Juvigy said:

I think it would be better to find which registry settings are changed and do a REGWRITE(). Send() is not a good automation practice.

You have to remember that not everyone likes to go DEEP into the system. Most people prefer using a mouse over typing, notice the KODA GUI generation comments in the code he/she provided, you can logically reason that he/she does not like to go too deep into the system, and thus you should attempt to suggest a solution that would be easy for him/her to implement. Just saying. :mellow:

My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.

My Projects

WhyNotWin11
Cisco FinesseGithubIRC UDFWindowEx UDF

 

Posted

  On 9/7/2011 at 12:39 PM, rcmaehl said:

You have to remember that not everyone likes to go DEEP into the system. Most people prefer using a mouse over typing, notice the KODA GUI generation comments in the code he/she provided, you can logically reason that he/she does not like to go too deep into the system, and thus you should attempt to suggest a solution that would be easy for him/her to implement. Just saying. :mellow:

hehe :) (I am a he)

Also, I just started with AutoIT(I have programming experience).

I can do a registry edit, but I really want to know where the strings for policy editor is :) (or screensaver at least)

Challenge accepted!

Posted

GPE Registry: http://msdn.microsoft.com/en-us/library/ms815238.aspx

Screensaver Registry Help: http://support.microsoft.com/kb/314493

These may be a bit old but they should still work.

My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.

My Projects

WhyNotWin11
Cisco FinesseGithubIRC UDFWindowEx UDF

 

Posted

In Windows XP the screensaver settings are in the registry key HKey_CURRENT_USER\Control Panel\Desktop. I believe they may be in the same place in Windows 7 but the Win7 machine I have doesn't have a screensaver active and it's set by company policy so I can't change it to see if it is in the same place.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

  Reveal hidden contents

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Posted

  On 9/7/2011 at 12:52 PM, rcmaehl said:

GPE Registry: http://msdn.microsoft.com/en-us/library/ms815238.aspx

Screensaver Registry Help: http://support.microsoft.com/kb/314493

These may be a bit old but they should still work.

GPE Registry was really useful =)

I am on a university domain, so the defaul settings in HKey_CURRENT_USER\Control Panel\Desktop does not work with my user.

I have to use the HKEY_USERS\S-1-5-21-1927809936-1189766144-1318725885-362183\Software\Policies\Microsoft\Windows\Control Panel\Desktop path instead, but same thing :mellow:

Thank all, and the problem is fixed(got a new one, but will make a new topic about it)

Kind Regards,

Akarillon

Challenge accepted!

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...