Jump to content
Sign in to follow this  
avery

Please help w/ a ScreenSaver

Recommended Posts

avery

Hello Everyone,

In the past several days I've been checking out the various User Defined Functions, mainly in the Example Scripts Section, for ScreenSaver UDF's.

I have found a good number of search results as you can imagine. The UDF I found that looked most promising was by Squirr1ly1

(http://www.autoitscript.com/forum/index.php?s=&showtopic=68216&view=findpost&p=553970). The code I came up with is attached below.

The process is making the screensaver using his examples and then Compiling the script and renaming the exectable to a .scr.

When I douple click the .scr it displays the screensaver as intended. However if I move it into the @System32 Folder and select it on the

ScreenSaver tab it gives me an error saying it can't open the script file.

I also get some warnings (quoted below) on compile/run and can't see to resolve them. Not sure if those have anything to do with it or not.

+>16:43:14 Starting AutoIt3Wrapper v.1.10.1.14 Environment(Language:0409 Keyboard:00000409 OS:WIN_2003/Service Pack 2 CPU:X64 ANSI)

>Running AU3Check (1.54.14.0) from:C:\AutoIt3

F:\Documents\au3\SecurityTool\ss\_SS_UDF.au3(54,32) : WARNING: $_SS_GUI: possibly used before declaration.

GUISetState(@SW_SHOW,$_SS_GUI)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

F:\Documents\au3\SecurityTool\ss\_SS_UDF.au3(77,47) : WARNING: $_SS_LastActionTicks: possibly used before declaration.

If _SS_LastAction() <> $_SS_LastActionTicks Then

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

F:\Documents\au3\SecurityTool\ss\_SS_UDF.au3(35,136) : WARNING: $_SS_GUI: declared global in function only. Prefer top of file.

Global $_SS_GUI=GUICreate(@ScriptFullPath,$_SS_WinWidth,$_SS_WinHeight,0,0,0x80000000,136);$WS_POPUP,$WS_EX_TOPMOST

+$WS_EX_TOOLWINDOW

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

~~~~~~~~~~~~~~~~~~~~~~

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

F:\Documents\au3\SecurityTool\ss\security_saver.au3 - 0 error(s), 3 warning(s)

->16:43:15 AU3Check ended.rc:1

+> Updated RT_VERSION information.

>16:43:15 Resource updating finished.

>Running:(3.3.0.0):C:\AutoIt3\aut2exe\aut2exe.exe /in "F:\Documents\au3\SecurityTool\ss\security_saver.au3"

/out "F:\Documents\au3\SecurityTool\ss\security_saver.exe" /comp 2 /pack /Bin C:\DOCUME~1\AVERY~1.ABO\LOCALS~1\Temp\AutoItSC.bin

Ultimate Packer for eXecutables

Copyright © 1996 - 2008

UPX 3.03w Markus Oberhumer, Laszlo Molnar & John Reiser Apr 27th 2008

File size Ratio Format Name

-------------------- ------ ----------- -----------

612864 -> 290304 47.37% win32/pe security_saver.exe

Packed 1 file.

+>16:43:22 Aut2exe.exe ended.rc:0

+>16:43:22 Created program:F:\Documents\au3\SecurityTool\ss\security_saver.exe

->Warning: This is an Unicode compiled script and will not run on Win9x/ME.

>Updated the Source Version to:1.0.0.1...

+>16:43:22 AutoIt3Wrapper Finished

>Exit code: 0 Time: 35.407

If anyone has experience with au3 and a simple text screensaver for a logon banner I would greatly appreciate your expertise.

My ScreenSaver Code:

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Res_Comment=Security Banner ScreenSaver
#AutoIt3Wrapper_Res_Description=Security Banner ScreenSaver
#AutoIt3Wrapper_Res_Fileversion=1.0.0.1
#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y
#AutoIt3Wrapper_Res_LegalCopyright=
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <_SS_UDF.au3>
#include <GUIConstants.au3>
#include <GDIPlus.au3>
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

$banner = "DoD Warning Banner" & @CRLF & "Use of this or any other DoD interest computer system constitutes" & @CRLF & _
        "consent to monitoring at all times. This is a DoD interest computer system. All DoD interest" & @CRLF & _
        "computer systems and related equipment are intended for the communication, transmission" & @CRLF & _
        "processing, and storage of official U.S. Government or other authorized information only." & @CRLF & _
        "All DoD interest computer systems are subject to monitoring at all times to ensure proper" & @CRLF & _
        "functioning of equipment and systems including security devices and systems, to prevent" & @CRLF & _
        "unauthorized use and violations of statutes and security regulations, to deter criminal" & @CRLF & _
        "activity, and for other similar purposes. Any user of a DoD interest computer system should" & @CRLF & _
        "be aware that any information placed in the system is subject to monitoring and is not" & @CRLF & _
        "subject to any expectation of privacy. If monitoring of this or any other DoD interest" & @CRLF & _
        "computer system reveals possible evidence of violation of criminal statutes, this evidence" & @CRLF & _
        "and any other related information, including identification information about the user" & @CRLF & _
        "may be provided to law enforcement officials. If monitoring of this or any other DoD" & @CRLF & _
        "interest computer systems reveals violations of security regulations or unauthorized use" & @CRLF & _
        "employees who violate security regulations or make unauthorized use of DoD interest computer" & @CRLF & _
        "systems are subject to appropriate disciplinary action. Use of this or any other DoD" & @CRLF & _
        "interest computer system constitutes consent to monitoring at all times." & @CRLF & @CRLF & _
        "CLASSIFICATION: SECRET" & @CRLF & "Lockheed Martin - Owego" & @CRLF & "FSO: Joe Vilasi x2602"

$screensaver = _SS_GUICreate()

$ss_label = GUICtrlCreateLabel($banner, 5, 5, 950, 365, $WS_BORDER + $SS_CENTER + $SS_SUNKEN, $WS_EX_WINDOWEDGE)

GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0xFF0000)
GUICtrlSetFont(-1, 12, 400, 0, "Lucida Console")

_SS_SetMainLoop("main_ss")
Global $xp = 1
Global $yp = 1
Global $xd = 1
Global $yd = 1

_SS_Start()

Func main_ss()
    Do
        GUICtrlSetPos($ss_label, $xp, $yp)
        $xp += $xd
        $yp += $yd
        If $yp = 0 Or ($yp = $_SS_WinHeight - 365 And $yd = 1) Then $yd = $yd * - 1
        If $xp = 0 Or ($xp = $_SS_WinWidth - 950 And $xd = 1) Then $xd = $xd * - 1
        Sleep(4200)
    Until _SS_ShouldExit()
EndFunc   ;==>main_ss

avery

Edited by avery

www.abox.orgAvery HowellVisit My AutoIt Websitehttp://www.abox.org

Share this post


Link to post
Share on other sites
NiVZ

Hi avery,

I too studied Squirrely1's UDF and came up with my own cut down template for making Screensavers. I've incorporated what you had written into my template (complete with preview). I've adjusted the Sleep to 500 as 4200 was a bit too long.

Let me know what you think. You might also want to check out using GDI+ instead of using a label for the animated box.

NiVZ

; Screensaver Template

#NoTrayIcon

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

; Check if there are command line paramaters
if $cmdline[0] > 0 Then

; Configure Mode - Settings button pressed
    if StringUpper(StringLeft($cmdline[1],2)) = "/C" Then

        _Configure()

; Preview Mode
    elseif StringUpper(StringLeft($cmdline[1],2)) = "/P" Then
        
        _Preview()
    
; ScreenSaver Mode
    ElseIf StringUpper(StringLeft($cmdline[1],2)) = "/S" Then
    
        _Screensaver()
    
    EndIf

Else
; If no paramaters then show config screen
    _Configure()
EndIf

; Exit screensaver
Exit


; -- User Functions -----------------------------------------------------------------------------------------------

Func _Configure()
    MsgBox(64, "Screensaver", "No settings to configure")
EndFunc


Func _Preview()
; Set Width and Height of preview window
    $VirtualDesktopWidth=152
    $VirtualDesktopHeight=112

; Create the form
    $Form1 = GUICreate("", $VirtualDesktopWidth, $VirtualDesktopHeight, 0, 0, 0x80000000)
    GUISetBkColor(0x000000)

    $banner = "DoD Warning Banner" & @CRLF & "Use of this or any other DoD interest computer system constitutes" & @CRLF & _
    "consent to monitoring at all times. This is a DoD interest computer system. All DoD interest" & @CRLF & _
    "computer systems and related equipment are intended for the communication, transmission" & @CRLF & _
    "processing, and storage of official U.S. Government or other authorized information only." & @CRLF & _
    "All DoD interest computer systems are subject to monitoring at all times to ensure proper" & @CRLF & _
    "functioning of equipment and systems including security devices and systems, to prevent" & @CRLF & _
    "unauthorized use and violations of statutes and security regulations, to deter criminal" & @CRLF & _
    "activity, and for other similar purposes. Any user of a DoD interest computer system should" & @CRLF & _
    "be aware that any information placed in the system is subject to monitoring and is not" & @CRLF & _
    "subject to any expectation of privacy. If monitoring of this or any other DoD interest" & @CRLF & _
    "computer system reveals possible evidence of violation of criminal statutes, this evidence" & @CRLF & _
    "and any other related information, including identification information about the user" & @CRLF & _
    "may be provided to law enforcement officials. If monitoring of this or any other DoD" & @CRLF & _
    "interest computer systems reveals violations of security regulations or unauthorized use" & @CRLF & _
    "employees who violate security regulations or make unauthorized use of DoD interest computer" & @CRLF & _
    "systems are subject to appropriate disciplinary action. Use of this or any other DoD" & @CRLF & _
    "interest computer system constitutes consent to monitoring at all times." & @CRLF & @CRLF & _
    "CLASSIFICATION: SECRET" & @CRLF & "Lockheed Martin - Owego" & @CRLF & "FSO: Joe Vilasi x2602"
    
    $ss_label = GUICtrlCreateLabel($banner, 0, 0, 100, 50, $WS_BORDER + $SS_CENTER + $SS_SUNKEN, $WS_EX_WINDOWEDGE)

    GUICtrlSetColor(-1, 0xFFFFFF)
    GUICtrlSetBkColor(-1, 0xFF0000)
    GUICtrlSetFont(-1, 1, 400, 0, "Lucida Console")
    
; Hook to User32.dll for preview
    $USER32 = DllOpen("user32.dll")
    DllCall($USER32,"int","SetParent","hwnd",$Form1,"hwnd",HWnd($cmdline[2]))
    DllClose($USER32)

; Show the form
    GUISetState(@SW_SHOW)
        
    Global $xp = 1
    Global $yp = 1
    Global $xd = 1
    Global $yd = 1
    
; Main loop
    While 1
        GUICtrlSetPos($ss_label, $xp, $yp)
        $xp += $xd
        $yp += $yd
        If $yp = 0 Or ($yp = $VirtualDesktopHeight - 50 And $yd = 1) Then $yd = $yd * - 1
        If $xp = 0 Or ($xp = $VirtualDesktopWidth - 100 And $xd = 1) Then $xd = $xd * - 1
        Sleep(500)

; Exit if Preview window is closed
        If NOT WinExists(HWnd($cmdline[2])) Then 
            GUIDelete($Form1)
            Exit
        EndIf
    Wend
EndFunc


Func _Screensaver()
    
    If Not IsDeclared("SM_VIRTUALWIDTH") Then Global Const $SM_VIRTUALWIDTH = 78
    If Not IsDeclared("SM_VIRTUALHEIGHT") Then Global Const $SM_VIRTUALHEIGHT = 79
    
; Get Screen size of all desktops
    $VirtualDesktopWidth = DLLCall("user32.dll", "int", "GetSystemMetrics", "int", $SM_VIRTUALWIDTH)
    $VirtualDesktopWidth = $VirtualDesktopWidth[0]
    $VirtualDesktopHeight = DLLCall("user32.dll", "int", "GetSystemMetrics", "int", $SM_VIRTUALHEIGHT)
    $VirtualDesktopHeight = $VirtualDesktopHeight[0]

; Create the form
    $Form1 = GUICreate("", $VirtualDesktopWidth, $VirtualDesktopHeight, 0, 0, $WS_POPUPWINDOW, $WS_EX_TOPMOST + $WS_EX_TOOLWINDOW)
    GuiSetBKColor(0x000000)
    
    $banner = "DoD Warning Banner" & @CRLF & "Use of this or any other DoD interest computer system constitutes" & @CRLF & _
        "consent to monitoring at all times. This is a DoD interest computer system. All DoD interest" & @CRLF & _
        "computer systems and related equipment are intended for the communication, transmission" & @CRLF & _
        "processing, and storage of official U.S. Government or other authorized information only." & @CRLF & _
        "All DoD interest computer systems are subject to monitoring at all times to ensure proper" & @CRLF & _
        "functioning of equipment and systems including security devices and systems, to prevent" & @CRLF & _
        "unauthorized use and violations of statutes and security regulations, to deter criminal" & @CRLF & _
        "activity, and for other similar purposes. Any user of a DoD interest computer system should" & @CRLF & _
        "be aware that any information placed in the system is subject to monitoring and is not" & @CRLF & _
        "subject to any expectation of privacy. If monitoring of this or any other DoD interest" & @CRLF & _
        "computer system reveals possible evidence of violation of criminal statutes, this evidence" & @CRLF & _
        "and any other related information, including identification information about the user" & @CRLF & _
        "may be provided to law enforcement officials. If monitoring of this or any other DoD" & @CRLF & _
        "interest computer systems reveals violations of security regulations or unauthorized use" & @CRLF & _
        "employees who violate security regulations or make unauthorized use of DoD interest computer" & @CRLF & _
        "systems are subject to appropriate disciplinary action. Use of this or any other DoD" & @CRLF & _
        "interest computer system constitutes consent to monitoring at all times." & @CRLF & @CRLF & _
        "CLASSIFICATION: SECRET" & @CRLF & "Lockheed Martin - Owego" & @CRLF & "FSO: Joe Vilasi x2602"
    $ss_label = GUICtrlCreateLabel($banner, 5, 5, 950, 365, $WS_BORDER + $SS_CENTER + $SS_SUNKEN, $WS_EX_WINDOWEDGE)

    GUICtrlSetColor(-1, 0xFFFFFF)
    GUICtrlSetBkColor(-1, 0xFF0000)
    GUICtrlSetFont(-1, 12, 400, 0, "Lucida Console")
    
; Show the form
    GUISetState(@SW_SHOW)

    Global $xp = 1
    Global $yp = 1
    Global $xd = 1
    Global $yd = 1

; Get curernt mouse position
    $MousePos = MouseGetPos()

; Main loop
    While 1
        
        GUICtrlSetPos($ss_label, $xp, $yp)
        $xp += $xd
        $yp += $yd
        If $yp = 0 Or ($yp = $VirtualDesktopHeight - 365 And $yd = 1) Then $yd = $yd * - 1
        If $xp = 0 Or ($xp = $VirtualDesktopWidth - 950 And $xd = 1) Then $xd = $xd * - 1
        Sleep(500)

        
; Check for GUI events
        $msg = GUIGetMsg()
        
; Get mouse position
        $mcPos = MouseGetPos()
        
; If mouse has moved or GUI is closed then exit screensaver
        If $MousePos[0] <> $mcPos[0] or $MousePos[1] <> $mcPos[1] or $msg = $GUI_EVENT_CLOSE Then
                GUIDelete($Form1)
                Exit
        EndIf
    WEnd
EndFunc
Edited by NiVZ

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.