directories end_directories; settings operation_mode = real_time; startup_options call_procedures = false; activate_receivers = false; output_action = set_local; end_startup_options; login login_system_enabled = true; login_window_visible = true; end_login; end_settings; driver end_driver; data const SEC_IN_DAY = 86400; INIT_IDLE_TIME = 10; end_const; var IdleTime : real {init_value = INIT_IDLE_TIME}; end_var; end_data; instrument panel pMain; gui owner = background; position = 135, 60, 195, 80; access = [ 0 ]; window type = normal; title = 'AutoLogout'; end_window; end_gui; end_panel; control control_IdleTime; gui owner = pMain; position = 90, 10, 80, 18; end_gui; output = IdleTime; mode = count_box; range_from = 5; init_value = INIT_IDLE_TIME; dec_places = 0; end_control; label lTimeToLogout; gui owner = pMain; position = 38, 15; window disable = zoom, maximize; end_window; end_gui; text_list text = 'Idle time'; end_text_list; end_label; meter mLogoutCounter; static cnt : real; end_static; gui owner = pMain; position = 90, 45, 75, 18; end_gui; mode = text_display; low_limit = 0; high_limit = 100; dec_places = 1; font = font_caption; colors ink = black; value = white; low_limit = white; high_limit = white; end_colors; procedure OnActivate(); begin if cnt > 0 then cnt = cnt - 0.1; SetValue( cnt ); pause 0.1; send self; end; (* if *) end_procedure; procedure Start(); begin cnt = IdleTime; SetValue( cnt ); send self; end_procedure; end_meter; label lTimeToLogout; gui owner = pMain; position = 10, 50; window disable = zoom, maximize; end_window; end_gui; text_list text = 'Time to logout'; end_text_list; end_label; program pgmLogout; static LogoutTime : real; end_static; procedure OnActivate(); begin if date.GetDateTimeJD() > LogoutTime then system.SetNewUser( MaxLongCard, '' ); else pause 1; send self; end; (* if *) end_procedure; procedure StartTimer(); begin LogoutTime = date.GetDateTimeJD() + IdleTime / SEC_IN_DAY;; mLogoutCounter.Start(); send self; end_procedure; end_program; program pgmIdle; activity period = 0.1; end_activity; procedure OnActivate(); static LastMouseX : integer; LastMouseY : integer; LastScanCode : cardinal; begin if (user_level <> MaxLongCard) and ((LastScanCode <> scan_code) or (LastMouseX <> mouse_x) or (LastMouseY <> mouse_y)) then LastMouseX = mouse_x; LastMouseY = mouse_y; LastScanCode = scan_code; pgmLogout.StartTimer(); end; (* if *) end_procedure; end_program; end_instrument;