Jump to content

Screensaver UDF


james3mg
 Share

Recommended Posts

I have use of the UDF's except for the last function - _SS_ShouldExit - instead, I like this method ...

CODE
$last = 0

While 1

$new = _IdleTicks()

If $new < $last Then

ExitLoop

EndIf

$last = $new

Sleep(50)

WEnd

;=================================================================================================

; script name: _IdleTicks

; author: erifash @AutoIt

; notes: erifash says that using _IdleTicks() this way will exitloop on any keystrokes

; or mouse action:

; $last = 0

; While 1

; $new = _IdleTicks()

; If $new < $last Then

; ExitLoop

; EndIf

; $last = $new

; WEnd

;=================================================================================================

Func _IdleTicks()

Local $aTSB = DllCall("kernel32.dll", "long", "GetTickCount")

Local $ticksSinceBoot = $aTSB[0]

Local $struct = DllStructCreate("uint;dword")

DllStructSetData($struct, 1, DllStructGetSize($struct))

DllCall("user32.dll", "int", "GetLastInputInfo", "ptr", DllStructGetPtr($struct))

Local $ticksSinceIdle = DllStructGetData($struct, 2)

Return ($ticksSinceBoot - $ticksSinceIdle)

EndFunc ;==>_IdleTicks

Das Häschen benutzt Radar

Link to comment
Share on other sites

  • Replies 50
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

I have use of the UDF's except for the last function - _SS_ShouldExit - instead, I like this method ...

Interesting- I hadn't seen that method before. I'll look into it and see if I can incorporate it into my UDF so that it's cleaner than my current method...then I'll repost my UDF.

Thanks :D

"There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110
Link to comment
Share on other sites

I'll look into it and see if I can incorporate it into my UDF...

Great - with some UDFs I am working on and this, it would then be easy for me to finally finish building my squirrely screensaver.

Das Häschen benutzt Radar

Link to comment
Share on other sites

I've uploaded a new version of the UDF, using this new method for determining idle status. Thanks to erifash for finding this method and squirrely1 for pointing it out.

There is a change you need to be aware of in this new version. I've left the $_SS_Sensitivity=10 parameter in _SS_ShouldExit(), but it's not used in this version. Changing the number will not have any effect any more. I've left it in to maintain backward compatibility, and because I hope to eventually let it be functional again. That means that if the mouse moves even just a little (say, even one pixel), the screensaver will exit (if this function is used). Previously, by default, the mouse would have to move 10 pixels to register (that made it less likely for the screensaver to prematurely terminate because a door slammed in your house and your desk shook a little, for instance :D ). The tradeoff of this behavior is, I think, worth it.

Now ANY key will terminate the screensaver (rather than just character typing keys, as before). So printscreen, caps lock, shift, etc will all terminate the screensaver. However, the screensaver will not grab the action of these keys- pressing caps lock will terminate the screensaver, but still actually toggle the caps lock state. Character typing keys and keys that are used in a software manner (F- keys, etc) will NOT be passed through to the window behind the screensaver. As always, Windows-registered hotkeys will still call their programs/functions after the screensaver terminates.

I'll do some research on this new method for the next version- I hope to allow the user to choose some keys (printscreen or arrow keys would probably be common ones) to NOT terminate the screensaver. But I don't know if it's possible.

As always, I'll post any updates here.

Thanks for your comments! :D

Edit: realized how I could reimplement the sensitivity paramenter-OP is updated. Now the new version is, in all ways, as good as the old method, with no downside.

Edited by james3mg
"There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110
Link to comment
Share on other sites

  • 2 months later...

I wrote a version of this great include file that james3mg began and named my copy Screensaver.au3.

My version fixes a few remaining issues, and worked perfectly on my system. But I don't have multiple monitors, I only have one computer that has XP SP3 on it, and so I can't test this on Windows 98 or Windows Vista, etcetera.

The attached include file is documented thoroughly. Feedback would be very helpful:

Latest:

v1.0 - Fixes, better doc's -

Old:

v0.99.5 - Fixes, better doc's -

v0.99 - New features & fixes -

v0.98 - Perhaps Broken -

v0.97 - New Features -

v0.96 - Fixed ---

v0.95 - Broken -

v0.90 - Original-

Moving-text example, revised once AGAIN to work with v0.99.5 of Screensaver.au3, using the Timer functions:

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Version=Beta
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_Res_Comment=A simple moving-text screensaver that displays Squirrely Biz.
#AutoIt3Wrapper_Res_Description=My Company Example SS
#AutoIt3Wrapper_Res_Fileversion=0.8.48.63
#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=Y
#AutoIt3Wrapper_Res_LegalCopyright=©My Company 2008. All rights reserved.
://////=__=
://////=__=
://////=__=
://////=__=
://////=__=://///= myCity, myCountry
://////=__=.=
://////=__=,,,,
://////=__=
://////=__=
://////=__=
://////=__=
://////=__=
://////=__=.=
://////=__=,,,.,.
://////=__=
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

#Region my_code

;   Example SS.au3
;       A Basic Floating Text Screensaver that uses _SS_Exit_OnTimer from v0.99 of Screensaver.au3


;#NoTrayIcon ; Before you call your screen saver a finished product, un-comment this line.

Opt("MustDeclareVars", 1)

#include "Screensaver.au3"; use this line if Screensaver.au3 (v0.99) is is same folder with this file.

Global Const $FLOATING_TEXT = "Squirrely Biz"
Global $MyLabel, $cntr, $limitX, $limitY
Global $XmovePX = 1, $YmovePX = 1, $Xpos = 0, $Ypos = 0

_SS_SetAppendedExitFunc("MyAdditionalExitFunc")
_SS_SetTestLoopFunc("MyTextMoverLoop")
_SS_SetInstallLoopFunc("MyTextMoverLoop")

_SS_Initialize_RunMode(3, 9); Brand new syntax again, this only takes 4 parameters !

_SS_GUICreate()
GUISetBkColor(0x000000, $_SS_Gui)

Switch $_SS_Mode
    Case "Test"
        $MyLabel = GUICtrlCreateLabel($FLOATING_TEXT, 0, 0, 481, 101)
        GUICtrlSetFont($MyLabel, 64, 400, 0, "Tahoma")
        $limitX = $_SS_Width - 481
        $limitY = $_SS_Height - 101
    Case "Install"
        $MyLabel = GUICtrlCreateLabel($FLOATING_TEXT, 0, 0, 57, 13)
        GUICtrlSetFont($MyLabel, 8, 400, 0, "Tahoma")
        $limitX = $_SS_Width - 57
        $limitY = $_SS_Height - 13
EndSwitch
GUICtrlSetColor($MyLabel, 0xFFFFFF)

_SS_Start()

#EndRegion my_code

Func MyAdditionalExitFunc()
    _SS_Kill_ExitTimer()
EndFunc

Func MyTextMoverLoop()
    _SS_Exit_OnTimer()
    While 1
        Sleep(36)
        Sub_UpdateTheScreen()
    WEnd
EndFunc

Func Sub_UpdateTheScreen()
    $Xpos += $XmovePX
    $Ypos += $YmovePX
    ControlMove($_SS_Gui, "", $MyLabel, $Xpos, $Ypos)
    If $Xpos = 0 Or $Xpos = $limitX Then $XmovePX *= -1
    If $Ypos = 0 Or $Ypos = $limitY Then $YmovePX *= -1
EndFunc
Edited by Squirrely1

Das Häschen benutzt Radar

Link to comment
Share on other sites

Hi,

I realy like your _SS_UDF but can you explain me how to implement a password-routine?

Best regards,

Aakira

I guess you are talking about the "/a" or "-a" command-lin switch - well it is only for Windows 98 and Windows ME as far as I know, and I can't explore the use of that parameter because I only have one machine with XP and the other one uses MSDOS 6.2 for an OS. But all that switch is supposed to do is to open a dialog wherein you change a password and password protect your screensaver that way, instead, I guess, of doing it the way we do in XP, by just leaving checked the little checkbox there in the Screen Saver tab of the Display Properties applet you find under the Control Panel.

I am sure that one of the coders here has Windows 98 going, and it might just be a matter of time before someone finds the includes file and adds that last bit of functionality to it.

Do you use Windows 98 or ME ?

Das Häschen benutzt Radar

Link to comment
Share on other sites

I guess you are talking about the "/a" or "-a" command-lin switch - well it is only for Windows 98 and Windows ME as far as I know, and I can't explore the use of that parameter because I only have one machine with XP and the other one uses MSDOS 6.2 for an OS. But all that switch is supposed to do is to open a dialog wherein you change a password and password protect your screensaver that way, instead, I guess, of doing it the way we do in XP, by just leaving checked the little checkbox there in the Screen Saver tab of the Display Properties applet you find under the Control Panel.

I am sure that one of the coders here has Windows 98 going, and it might just be a matter of time before someone finds the includes file and adds that last bit of functionality to it.

Do you use Windows 98 or ME ?

No, I am using W2k. But I don't want to use the normal Windows-Password. I want to use an other password.

Link to comment
Share on other sites

Well I am not an expert at writing screensavers, but this seems like a great idea and I have thought about it.

You would have a function that creates a GUI and you use GUICtrlCreateInput using the password flag, and I guess you try to hide the password in the registry somewhere. I have come across threads in this forum that describe a good way to hide that password in the registry and so forth.

Since somone wanted this functionality, I will make a note to myself to create a function for it sometime - but it probably won't happen soon.

Das Häschen benutzt Radar

Link to comment
Share on other sites

  • 2 weeks later...

I compiled Squirrely1's screensaver v0.97 and found out that the close function for preview is not working properly:

If I open the screensaver settings window where I can select any of available screensaver, I can see the preview of it.

But if I'm going to select another one then normally the called process from rundll32.exe should close the old screensaver (Squirrely1's screensaver) process

and should start the new one.

But this is not done - after selecting another one, 2 screensaver tasks are running at the same time. When closing the screensaver settings window then all processes

will close.

Can somebody confirm?

Thanks,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

  • 2 weeks later...

I compiled Squirrely1's screensaver v0.97 and found out that the close function for preview is not working properly...

Using v0.98 of the includes file, the process ends as required when changing selections in the dropdown box. I couldn't replicate the error you describe on my Windows XP, UEZ.

Will you make the latest version (v0.98) of the includes file work on your version of Windows, tell me what code you changed, and also - describe the platform(s) you have checked the file on and for which it is now working properly?

Das Häschen benutzt Radar

Link to comment
Share on other sites

Here is a .zip file containing the code and other files required to build the compiled screensaver linked at the bottom of my signature - for use only with the v0.98 of Screensaver.au3, also linked in my sig ...

Das Häschen benutzt Radar

Link to comment
Share on other sites

Using v0.98 of the includes file, the process ends as required when changing selections in the dropdown box. I couldn't replicate the error you describe on my Windows XP, UEZ.

Will you make the latest version (v0.98) of the includes file work on your version of Windows, tell me what code you changed, and also - describe the platform(s) you have checked the file on and for which it is now working properly?

Yes, that's right but I compiled your screensaver v0.97 with _SS_UDF.au3 made by james3mg. I'am using Vista SP1 and latest AutoIt (not beta).

By the way, udf screensaver.au3 doesn't close the screensaver preview process properly when closing screensaver settings window. It just close the rundll32.exe and makes the child screensaver process to parent! But the closing of screensaver task when selecting a different one from the pull down list, is working!

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

UEZ - using the new and improved v0.98 of Screensaver.au3, your screensaver will now close when you click on a new tab - such as Desktop or Appearance, whereas in v0.97 it would not close.

If you discover that it does not work this way in Vista, let me know - I want it to work properly under Vista.

Das Häschen benutzt Radar

Link to comment
Share on other sites

UEZ - using the new and improved v0.98 of Screensaver.au3, your screensaver will now close when you click on a new tab - such as Desktop or Appearance, whereas in v0.97 it would not close.

If you discover that it does not work this way in Vista, let me know - I want it to work properly under Vista.

Squirrely1,

same situation on WinXP:

I compiled Light a Candle.au3 with latest AutoIt version, screensaver.au3 v0.98 (UDF) and moved Light a Candle.scr to %windir%\system32.

When I open screensaver settings tab and select your ss 'Light a Candle' then it will be started by rundll32.exe as parent process and your ss 'Light a Candle.scr' becomes a child process -> see screenshot Process1.png

If I switch to another tab then the ss process will be closed properly by parent process (rundll32.exe) which is still active.

But when I selected your ss and press ok then parent process (rundll32.exe) will be closed and your ss process become parent process -> see screenshot Process2.png. Normally it should be closed, too.

So, I assume that the close process is not working properly.

ProcessExplorer used to list processes!

UEZ

post-29844-1218578822_thumb.png

post-29844-1218579030_thumb.png

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

UEZ - Thank you for helping to fix this.

Replace the following function in v0.98 of Screensaver.au3 with this ...

Func __SS_ClosePrevInstance_OpenDLL()
    Local $tPos[4]
    If WinExists($_WIN_TITLE) Then WinKill($_WIN_TITLE)
    AutoItWinSetTitle($_WIN_TITLE)
    Switch $_SS_Mode
        Case "Test"
            $hUser32DLL = DllOpen("user32.dll"); needed for _SS_ShouldExit, etcetera.
            Sleep(230)

        Case "Configure"
            $_AppletTab_Left = (@DesktopWidth / 2) - (516 / 2)
            $_AppletTab_Top = (@DesktopHeight / 2) - (236 / 2)
            If $CmdLine[0] And StringMid($CmdLine[1], 2, 2) = "c:" Then
                $hScrTab = HWnd(StringMid($CmdLine[1], 4)); get the handle of the Screen Saver tab
                If IsHWnd($hScrTab) Then
                    $tPos = WinGetPos(HWnd($hScrTab))
                    $_AppletTab_Left = $tPos[0] + 20
                    $_AppletTab_Top = $tPos[1] + 20
                EndIf
            EndIf

        Case "Install"
            $hUser32DLL = DllOpen("user32.dll")
            Sleep(230)
            $hWinLittlePreview = HWnd($CmdLine[2])
            $hScrTab = __WinGetParent($hWinLittlePreview, $hUser32DLL); Screen Saver tab of the applet window.
            
            ; Needed for _SS_ShouldExit or _SS_ShallExit_OnTimer ...
            $hAppletWin = __WinGetParent($hScrTab, $hUser32DLL); Control Panel applet window handle.
            $hAppletCombo1 = ControlGetHandle($hAppletWin, "", "[ID:1300]"); Applet's Dropdown handle.
            $initSel = __ComboGetCurSel($hAppletCombo1); Index of the item currently selected in Dropdown.
            
MsgBox($_MSG_BOX_STYLES, "", _
            "String($hUser32DLL):" & String($hUser32DLL) & " - should NOT be -1" _
    & @CR & "IsHWnd($hWinLittlePreview):"&IsHWnd($hWinLittlePreview) & " - should be 1" _
    & @CR & "IsHWnd($hScrTab):"&IsHWnd($hScrTab) & " - should be 1" _
    & @CR & "WinGetTitle($hScrTab):"&WinGetTitle($hScrTab) & " - should be: [Unknown]." _
    & @CR & "IsHWnd($hAppletWin):"&IsHWnd($hAppletWin) & " - should be 1" _
    & @CR & "WinGetTitle($hAppletWin):"&WinGetTitle($hAppletWin)&" - should be Display Properties" _
    & @CR & "IsHWnd($hAppletCombo1):"&IsHWnd($hAppletCombo1) & " - should be 1" _
    & @CR & "$initSel:"&$initSel & " - should NOT be 0" _
)
            
    EndSwitch
EndFunc

You would have to compile, but if you would, please post a .png screenshot of the MsgBox, into this thread.

If the screensaver closes properly when you select a different screensaver from the ComboBox, that means our code is working correctly to get the handle of the ComboBox, which it could not do without also correctly finding the handle to $hAppletWin, as far as I know, and so the following line in the function _SS_ShouldExit is supposed to close the screensaver:

If Not WinExists(HWnd($hAppletWin)) Then Return 1

:P

Edited by Squirrely1

Das Häschen benutzt Radar

Link to comment
Share on other sites

Another idea:

Is it possible to get the parent process PID from ss? And then how many child processes the parent process has openend?

E.g. let take the screenshots from my previous post:

RunDLL32.exe with PID 2156

Light a Candle.scr PID 2540

Is it possible now to get the PID of rundll32.exe within screensaver? Afterwards the amount of child processes of rundll32.exe?

Why? Because if another child process will be opened by rundll32.exe, e.g. when selecting another ss in settings window, then the current ss can be closed.

If child processes > 1 then close screensaver

Your are using ComboBox to know whether another ss has been selected.

Thanks,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Is it possible to get the parent process PID from ss? And then how many child processes the parent process has openend?

That might be possible UEZ, and I will investigate that possibility, but it will probably be a few days before I have come up with anything along those lines. There probably is a function to find out whether a process is a child of another using AutoIt, but I have not seen it in the AutoIt help file. I would begin the search here in the forums.

There is a standard udf that comes with the latest versions of AutoIt to get the parent window of a window.

Edit: Function replacement removed.

Thanks for identifying this problem, UEZ; I think I know of a fix and it should show up in v0.99 - the next version.

Edited by Squirrely1

Das Häschen benutzt Radar

Link to comment
Share on other sites

UEZ - Thank you for helping to fix this.

Replace the following function in v0.98 of Screensaver.au3 with this ...

...

You would have to compile, but if you would, please post a .png screenshot of the MsgBox, into this thread.

If the screensaver closes properly when you select a different screensaver from the ComboBox, that means our code is working correctly to get the handle of the ComboBox, which it could not do without also correctly finding the handle to $hAppletWin, as far as I know, and so the following line in the function _SS_ShouldExit is supposed to close the screensaver:

If Not WinExists(HWnd($hAppletWin)) Then Return 1

:P

Here the screenshot from Vista.

Yes, it closes properly when selecting a different ss but not when you select ss compiled with screensaver.au3 and press ok. It becomes parent process running as described above.

UEZ

PS: screenshot deleted because of attachment space is nearly full :-(

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
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
 Share

  • Recently Browsing   0 members

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