Indigo Rose Software

Professional Software Development Tools

 
Results 1 to 6 of 6

Thread: Events Library

  1. #1
    Join Date
    Dec 2003
    Location
    The Netherlands
    Posts
    475

    Events Library

    Events library (Events.dll v.1.0.0.0) lets you get notifications for different system events. In order to get notifications for an event you must subscribe to that particular event.

    The following events are supported:

    DisplaySettingsChanging,
    DisplaySettingsChanged,
    InstalledFontsChanged,
    LowMemory,
    PaletteChanged,
    PowerModeChanged,
    SessionSwitch,
    SessionEnding,
    SessionEnded,
    TimeChanged,
    UserPreferenceChanging,
    UserPreferenceChanged

    I plan to add more events in the future.


    Actions:

    Events.Subscribe
    Events.Unsubscribe
    Events.GetEventData
    Events.GetEventCount
    Events.GetError

    Always unsubscribe from the events where you are subscribed when you're done.

    Download Events.v.1.0.0.0.

    Contents:
    1.Events.xml // Actions. Drop this to actions folder. C:\Program Files\AutoPlay Media Studio 5.0 Professional\Data\Actions.
    2.Events.Blank.Project.apt // Template project. Drop this to template folder. C:\Program Files\AutoPlay Media Studio 5.0 Professional\Templates.
    3.Events.Demo.apz // A very basic demo project to see what it does.


    .Net 2.0 required.

    With Kind Regards
    sside

  2. #2
    Join Date
    Dec 2003
    Location
    The Netherlands
    Posts
    475

    Events Library (Events.v.1.0.0.1)

    Added:
    Events.GetCancelSessionEnding
    Events.SetCancelSessionEnding

    If you are subscribed to SessionEnding event, it will fire before user logs off or shuts down computer.
    Events.GetCancelSessionEnding gets a value (true or false) whether to prevent user from logging off or shutting down the computer or not. Default is false.
    Events.SetCancelSessionEnding sets a value (true or false) whether to prevent user from logging off or shutting down the computer or not. If set to true user cannot logoff or shutdown the computer.

    Code:
    Events.SetCancelSessionEnding(true);
    This can be handy if you want to save application settings or execute some script before logging off or shutting down.


    Example:

    Page OnShow (or whatever):

    Code:
    Events.Subscribe(EventType.SessionEnding);
    Events.SetCancelSessionEnding(true);
    Page.StartTimer(100);

    Page OnTimer:

    Code:
    eventData = Events.GetEventData();
    if (eventData.EventType == "SessionEnding") then
    	--Page.StopTimer(); --You can stop timer here.
            --Do whatever you want to do. Computer won't logoff or shutdown.
    	if (eventData.EventInfo == "Logoff") then
                    --Logoff computer.
    	elseif (eventData.EventInfo == "SystemShutdown") then
                    --Shutdown computer.
    	end
    end

    You can log off or shutdown the computer by using shutdown.exe (system32 dir). These are command line arguments:

    Code:
    Usage: shutdown [-i | -l | -s | -r | -a] [-f] [-m \\computername] [-t xx] [-c "comment"] [-d up:xx:yy]
    	No args			Display this message (same as -?)
    	-i			Display GUI interface, must be the first option
    	-l			Log off (cannot be used with -m option)
    	-s			Shutdown the computer
    	-r			Shutdown and restart the computer
    	-a			Abort a system shutdown
    	-m \\computername	Remote computer to shutdown/restart/abort
    	-t xx			Set timeout for shutdown to xx seconds
    	-c "comment"		Shutdown comment (maximum of 127 characters)
    	-f			Forces running applications to close without warning
    	-d [u][p]:xx:yy		The reason code for the shutdown
    				u is the user code
    				p is a planned shutdown code
    				xx is the major reason code (positive integer less than 256)
    				yy is the minor reason code (positive integer less than 65536)
    You can use WinCmd.dll to execute commands:
    http://indigorose.com/forums/showthr...ght=WinCmd.dll

    Download:
    Events.v.1.0.0.1.

    Contents:
    1.Events.xml // Actions. Drop this to actions folder. C:\Program Files\AutoPlay Media Studio 5.0 Professional\Data\Actions.
    2.Events.Blank.Project.apt // Template project. Drop this to template folder. C:\Program Files\AutoPlay Media Studio 5.0 Professional\Templates.
    3.Events.Demo.Project.apz // A very basic demo project to see what it does.


    Note:
    Events.GetEventData() returns an EventData table. EventData.EventType (always) describes which event was fired. EventData.EventInfo (not always, depends on the EventType) has some additional info about the event that was fired. For more info about these values see project globals as the code is well commented.


    .Net 2.0 required.

    With Kind Regards
    sside

  3. #3
    Join Date
    Dec 2003
    Location
    The Netherlands
    Posts
    475

    Correction

    Before you logoff or shut down the computer you should do one of two things:

    Code:
    Events.SetCancelSessionEnding(false);
    or

    Code:
    Events.Unsubscribe(EventType.SessionEnding);
    or computer won't logoff/shutdown.


    So this:

    Code:
    Page OnTimer:
    
    
    Code:
    eventData = Events.GetEventData();
    if (eventData.EventType == "SessionEnding") then
    	--Page.StopTimer(); --You can stop timer here.
            --Do whatever you want to do. Computer won't logoff or shutdown.
    	if (eventData.EventInfo == "Logoff") then
                    --Logoff computer.
    	elseif (eventData.EventInfo == "SystemShutdown") then
                    --Shutdown computer.
    	end
    end
    should be:

    Code:
    Page OnTimer:
    
    
    Code:
    eventData = Events.GetEventData();
    if (eventData.EventType == "SessionEnding") then
    	--Page.StopTimer(); --You can stop timer here.
            --Events.SetCancelSessionEnding(false); --or
            --Events.Unsubscribe(EventType.SessionEnding); --this is better as computer will log off or shutdown anyway.
            --Take your time and do whatever you want to do here as computer won't logoff or shutdown.
    	if (eventData.EventInfo == "Logoff") then
                    --Logoff computer.
    	elseif (eventData.EventInfo == "SystemShutdown") then
                    --Shutdown computer.
    	end
    end

    With Kind Regards
    sside

  4. #4
    Join Date
    Mar 2007
    Posts
    186

    Re: sside

    Hello sside,
    Hope you wont mind reuploading these 'gems'. The links are dead.
    BTW, I really should visit this section of the forum too. Its a gold mine of great dlls by you. Thanks for the unselfish giving.

    Thank You.

  5. #5
    Join Date
    Dec 2003
    Location
    The Netherlands
    Posts
    475

  6. #6
    Join Date
    Mar 2007
    Posts
    186

    Arrow Re: sside

    Thanks again for taking time to reupload and share these Dlls...

Similar Threads

  1. Access database library
    By sside in forum AutoPlay Media Studio 5.0
    Replies: 5
    Last Post: 02-25-2009, 07:50 AM
  2. Image library
    By sside in forum AutoPlay Media Studio 5.0
    Replies: 8
    Last Post: 05-30-2006, 05:22 AM
  3. AMS5 Code & Example Library.
    By sside in forum AutoPlay Media Studio 5.0
    Replies: 11
    Last Post: 02-25-2005, 01:28 AM
  4. INFO: The Difference between the "On Close" and "On Destroy" Events
    By Support in forum AutoPlay Media Studio 4.0 Examples
    Replies: 0
    Last Post: 10-03-2002, 02:10 PM
  5. Anyone Suggest A Graphics Library and Printer?
    By wwwScottRohcom in forum AutoPlay Media Studio 4.0
    Replies: 6
    Last Post: 08-14-2002, 01:05 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts