topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Wednesday December 11, 2024, 12:35 pm
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: Screensaver Timeout Changer  (Read 7086 times)

Ordstrin

  • Member
  • Joined in 2009
  • **
  • Posts: 32
    • View Profile
    • Ordstrin's Home
    • Donate to Member
Screensaver Timeout Changer
« on: January 31, 2009, 12:24 AM »
Alright, at the suggestion of lanux.. here's the source.

Maybe this should be moved until the program is working?
50th edit lucky right? I hope...

Spoiler
#SingleInstance, Force
#NoTrayIcon

Gui, Add, Button, x6 y10 w100 h30 gChangeButton, Change
Gui, Add, Button, x136 y10 w100 h30 gSetToDefault, Default
Gui, Add, Button, x266 y10 w100 h30 gExitButton, Exit
Gui, Add, GroupBox, x6 y50 w360 h100 , Time to wait before starting screensaver.
Gui, Add, Radio, x26 y70 w50 h20 vRadioChosen gRadioChange, Hours
Gui, Add, Radio, x116 y70 w60 h20 Checked1 gRadioChange, Minutes
Gui, Add, Radio, x216 y70 w60 h20 gRadioChange, Seconds
Gui, Add, Edit, x46 y110 w20 h20 Limit2 +Number +Disabled -HScroll vHoursTime,
Gui, Add, Edit, x126 y110 w30 h20 Limit4 +Number -HScroll vMinutesTime,
Gui, Add, Edit, x226 y110 w40 h20 Limit5 +Number +Disabled -HScroll vSecondsTime,
Gui, Show, x257 y231 h162 w376, Screensaver Timeout Changer
Return

ChangeButton:
Gui, Submit, NoHide

IfEqual, RadioChosen, 1
  {
  IfNotEqual, HoursTime,
    {
   TimeVar1:=(HoursTime*3600)
   
   TimeInMinutes:=(HoursTime*60)
   
   RegWrite, REG_SZ, HKEY_CURRENT_USER, Control Panel\Desktop, ScreenSaveTimeOut, %TimeVar1%
   
   MsgBox, Screensaver Timeout has been changed to: %HoursTime% Hours (%TimeInMinutes% Minutes) (%TimeVar1% Seconds)
   }
   Else
   {
   MsgBox, Error: You must enter a number.
   }
  }

IfEqual, RadioChosen, 2
  {
  IfNotEqual, MinutesTime,
    {
   TimeVar1:=(MinutesTime*60)
   
   RegWrite, REG_SZ, HKEY_CURRENT_USER, Control Panel\Desktop, ScreenSaveTimeOut, %TimeVar1%
   
   MsgBox, Screensaver Timeout has been changed to: %MinutesTime% Minutes (%TimeVar1% Seconds)
   }
   Else
   {
   MsgBox, Error: You must enter a number.
   }
  }

IfEqual, RadioChosen, 3
  {
  IfNotEqual, SecondsTime,
    {
   TimeVar1:=(SecondsTime*1)

   RegWrite, REG_SZ, HKEY_CURRENT_USER, Control Panel\Desktop, ScreenSaveTimeOut, %TimeVar1%
   
   MsgBox, Screensaver Timeout has been changed to: %TimeVar1% Seconds
   }
   Else
   {
   MsgBox, Error: You must enter a number.
   }
  }

return

RadioChange:
Gui, Submit, NoHide

IfEqual, RadioChosen, 1
  {
  GuiControl, Enable, HoursTime
  GuiControl, Disable, MinutesTime
  GuiControl, Disable, SecondsTime
  }

IfEqual, RadioChosen, 2
  {
  GuiControl, Disable, HoursTime
  GuiControl, Enable, MinutesTime
  GuiControl, Disable, SecondsTime
  }

IfEqual, RadioChosen, 3
  {
  GuiControl, Disable, HoursTime
  GuiControl, Disable, MinutesTime
  GuiControl, Enable, SecondsTime
  }
 
return

SetToDefault:
RegWrite, REG_SZ, HKEY_CURRENT_USER, Control Panel\Desktop, ScreenSaveTimeOut, 600
MsgBox, Screensaver Timeout has been changed to Default: 10 Minutes (600 Seconds)
return

ExitButton:
ExitApp
return

GuiClose:
ExitApp


It modifies the correct registry setting, but that doesn't make any difference.
« Last Edit: January 31, 2009, 01:10 AM by Ordstrin »

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,277
    • View Profile
    • Donate to Member
Re: thread absent
« Reply #1 on: January 31, 2009, 01:03 AM »
why not post the source? i'm sure there are some knowledgeable AHK coders here to advise you. ;)

also Skrommel has written a few screensaver related scripts (right now, only RunSaver comes to mind) and you can pick up a few pointers from there.

Ordstrin

  • Member
  • Joined in 2009
  • **
  • Posts: 32
    • View Profile
    • Ordstrin's Home
    • Donate to Member
Re: thread absent
« Reply #2 on: January 31, 2009, 01:05 AM »
Yet again, sound advice from a member of DC. I'll do just that I think.

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,277
    • View Profile
    • Donate to Member
Re: Screensaver Timeout Changer
« Reply #3 on: January 31, 2009, 08:05 AM »
looking from your code, i did something a while ago (changes to the registry i mean) and had the same result. the new value is written to the registry but it's not recognized by windows. there must be a way to refresh the registry programatically. i'll let you know if i find out anything. :)