Jump to content
Sign in to follow this  
rrandom

Avoid screensaver

Recommended Posts

rrandom

Dear readers,

for a programmer it could be less than 4 lines code?

For a designer it could be a needed help.

To avoid the start of a screensaver (managed via admin) some action must happen during a tme interval.

If the mouse is moving 1px forwards and 1px backwards (via x) every 3 minutes, the problem would be solved. :)

Are 4 lines of code needed, or can it be done with 3 or 2 lines?

Thank you for your interest

rrANdOm

Share this post


Link to post
Share on other sites
iCode

i would suggest posting an example and letting other critique it


FUNCTIONS: WinDock (dock window to screen edge) | EditCtrl_ToggleLineWrap (line/word wrap for AU3 edit control) | SendEX (yet another alternative to Send( ) ) | Spell Checker (Hunspell wrapper) | SentenceCase (capitalize first letter of sentences)

CODE SNIPPITS: Dynamic tab width (set tab control width according to window width)

Share this post


Link to post
Share on other sites
DatMCEyeBall

HotKeySet("^{ESC}", "_Exit")

GLobal $hTimer = TimerInit(), $fClose = False
While 1
    If TimerDiff($hTimer) >= 3 * 60000 Then
        $aPos = MouseGetPos()
        MouseMove($aPos[0] + 1, aPos[1], 0)
        MouseMove($aPos[0], aPos[1], 0)
        $hTimer = TimerInit()
    EndIf
    If $fClose Then
        ExitLoop
    EndIf
    Sleep(10) ;Sleep to avoid high CPU usage
WEnd

Func _Exit()
    $fClose = True
EndFunc


"Just be fred, all we gotta do, just be fred."  -Vocaliod

"That is a Hadouken. A KAMEHAMEHA would have taken him 13 days and 54 episodes to form." - Roden Hoxha

@tabhooked

Clock made of cursors ♣ Desktop Widgets ♣ Water Simulation

Share this post


Link to post
Share on other sites
mrider
Are 4 lines of code needed, or can it be done with 3 or 2 lines?

 

Something to keep in mind: There's software you write for yourself, and there's software you write for others.  When I write a utility or program for myself, I often times skip some of the various error traps and things that make a program bullet-proof - or at least bullet resistant.  When the software is intended for others, I often have to add numerous lines of code to make sure it won't explode in a user's face.

A "real" program, meant to be used in production by actual users is often times 80% safety code, and 20% algorithms (if you'll forgive me pulling a number out of my arse).  So it's likely someone can make a really short program, but it probably won't be very forgiving.  For example, what happens if the mouse starts at the top of the monitor?  How is it going to move even further up?

  • Like 1

How's my riding? Dial 1-800-Wait-There

Trying to use a computer with McAfee installed is like trying to read a book at a rock concert.

Share this post


Link to post
Share on other sites
DatMCEyeBall

'?do=embed' frameborder='0' data-embedContent>>

that is more than 4 lines Mr Eyeball... :pirate:

That's just an example. You write the code if you want it to be 4 lines.

Understand?

 

For example, what happens if the mouse starts at the top of the monitor?  How is it going to move even further up?

It's moving the mouse 1 pixel left and then back.

 

 

Or just disable it

RegWrite("HKEY_CURRENT_USERControl PanelDesktop", "ScreenSaveActive", "REG_SZ", "0") ; Disable Screensaver

 

Clever. :)

EDIT:

Enhanced "you"'s

Edited by DatMCEyeBall

"Just be fred, all we gotta do, just be fred."  -Vocaliod

"That is a Hadouken. A KAMEHAMEHA would have taken him 13 days and 54 episodes to form." - Roden Hoxha

@tabhooked

Clock made of cursors ♣ Desktop Widgets ♣ Water Simulation

Share this post


Link to post
Share on other sites
l3ill

 

billo, on 18 Nov 2013 - 5:12 PM, said:

'?do=embed' frameborder='0' data-embedContent>>

that is more than 4 lines Mr Eyeball...

That's just an example. You write the code if you want it to be 4 lines.

Understand?

 

Understand what? That YOU have no sense of humor?   :ermm:

Edited by billo

Share this post


Link to post
Share on other sites
DatMCEyeBall

I posted an example to show you the concept.

I just don't understand why it would have to be 4 lines, it makes no sense at all.


"Just be fred, all we gotta do, just be fred."  -Vocaliod

"That is a Hadouken. A KAMEHAMEHA would have taken him 13 days and 54 episodes to form." - Roden Hoxha

@tabhooked

Clock made of cursors ♣ Desktop Widgets ♣ Water Simulation

Share this post


Link to post
Share on other sites
mrider

 

It's moving the mouse 1 pixel left and then back.

 

My statement wasn't aimed at you, so no need to make the correction.  Besides which, what if it was at the left instead of top?

 

However, that's precisley my point.  The point being that one needs to think about how the software is going to be used and by whom.  For example, I can disable the screensaver in the registry as Chimaera suggests, however, it'll magically reenable itself after a short time.  The desktop computers here have a process running in the background that ensures various sanity settings are always set to the corporate standard: One of those sanity checks being that desktops lock after a certain time period.

My point being that fewer lines of code run a greater risk of hitting some edge case that causes it to fail.  That's fine if the software is intended for your own use, but it may or may not be fine for others.

My own don't-sleep script (which is longer than 3 lines and can fail if the mouse is in the upper right corner) looks like this:

$index = 0
While True
    $mouse_xy = MouseGetPos()
    If BitAND($index, 1) = 1 Then
        MouseMove($mouse_xy[0] + 1, $mouse_xy[1] + 1)
    Else
        MouseMove($mouse_xy[0] - 1, $mouse_xy[1] - 1)
    EndIf
    $index += 1
    Sleep(5 * 60 * 1000)
WEnd

How's my riding? Dial 1-800-Wait-There

Trying to use a computer with McAfee installed is like trying to read a book at a rock concert.

Share this post


Link to post
Share on other sites
NewPlaza

How about this?

Local $mouse_xy
While True
    $mouse_xy = MouseGetPos()
    MouseMove($mouse_xy[0] + 1, $mouse_xy[1])
    MouseMove($mouse_xy[0] - 1, $mouse_xy[1])
    Sleep(5 * 60 * 1)
WEnd

Sure.. It's not 4 lines... But ii should work.

EDIT: Yeah you need to change the sleep to your needs.

Edited by NewPlaza

Share this post


Link to post
Share on other sites
kaotkbliss

The one I use 24/7 and has never failed me :) (although it too is more than 4 lines)

While 1
$pos = MouseGetPos()
$x = $pos[0]
$y = $pos[1]
If $x<1023/2 And $y<767/2 Then MouseMove($x + 5,$y + 5)
If $x>1023/2 And $y>767/2 Then MouseMove($x - 5,$y - 5)
If $x<1023/2 And $y>767/2 Then MouseMove($x + 5,$y - 5)
If $x>1023/2 And $y<767/2 Then MouseMove($x - 5,$y + 5)
    Sleep(300000)
WEnd

Although it's very old and was one of the first scripts I made. Looking at my source here, a couple changes would be to skip defining $x and $y and just use the $pos array

and the other change would be using the desktop width and height macros instead of the pre-defined resolution I was using.


010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Share this post


Link to post
Share on other sites
NewPlaza

Perhaps I'm looking at it wrong but...

Why do any checks on where the mouse is and how big the desktop resolution is?

The mouse should already be in a useable area of the desktop. just move one right then one left.  Why test?

 

 

Or just disable it

RegWrite("HKEY_CURRENT_USERControl PanelDesktop", "ScreenSaveActive", "REG_SZ", "0") ; Disable Screensaver

 

 

I wished I could use this. But alot of my settings at login is control by the AD.

Edited by NewPlaza

Share this post


Link to post
Share on other sites
mrider

 

The mouse should already be in a useable area of the desktop. just move one right then one left.  Why test?

 

Question answered even before it's asked, all in the same post.  (I take it you've never pushed your mouse way off to one side to clear desktop space...)

I'm not arguing with you.  Really.  You'll note that I don't check in my own post.  Again, all I'm saying is that one needs to think before coding, and that "fewest lines of code" doesn't automatically translate to "best way to do it".

 

[EDIT] "And yet we still don't have a reason for it having to be 4 lines."

Agreed...

Edited by mrider

How's my riding? Dial 1-800-Wait-There

Trying to use a computer with McAfee installed is like trying to read a book at a rock concert.

Share this post


Link to post
Share on other sites
kaotkbliss

I do this so that when it comes to move the mouse, it moves it towards the center of the screen. That way it never gets stuck in a corner or at the edge. And by moving it 5px, it a slight enough move to not be noticed, but also enough that the cursor should never reach dead center so it will always meet one of the conditions to move towards the center :)


010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Share this post


Link to post
Share on other sites
guinness

A timer would be better than using Sleep().


UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

×