Jump to content

Restrict Application


au3scr
 Share

Recommended Posts

Hello all,

1st i have to say"sorry for my bad english"

I made up little program that limits usage of other programs using time and weekday as arguments,well here i try explain it, but source is best explanation.

You can use this program to kill programs / applications if they run in wrong time or wrong weekday.for example if some program is allowed use after 17:20 and user try execute it at 16:45 o'clock then my program kills that application.You can have different clock time limitations for every day.You can also use internet to keep your settings, so noone else could change settings.(This program is originally designed for computer class to prevent students play urban terror when there are lessons.) you have 3 files 1 contains list of applications that you don't want to allow run, 2nd is ini file, that contains settings that tells program, how to work.

This program also write log file so you can track how it works, log file is not perfect but all comments are welcome.

I hope you can understand it, if not, maybe ini file comments help you, all questions are welcome.

Edit: I released 2 source codes for samething ,if you want see log file and tray icon, use 1-st code,if you dont want any log file and tray, use second code :)

here is KillList.txt: (I used notepad for testing reasons.)

notepad.exe

here is KillApp.ini:

[General]
;FILE MUST HAVE WINDOWS LINE ENDINGS
;General Settings start here <==
;Do you want restrict some applications,If yes change following option to True
;if no, change following option to False
;When "IsLimited" is set to "False", all restricted applications are allowed to use
IsLimited=True
;If this setting is set to 1, programm won't use internet,and "KillApp.ini" and "KillList.txt" must be in directory containing the running script.
Local=1
;Afrer howlong time you want to check if ANY of restricted applications is running?
;time is in milliseconds  (1000 = 1 SEC)
RefreshTime=2000
;Where from you want to download file that contains a list ofapplications that must be restricted
ProcessListFile=http://localhost/KillList.txt
;Wherehere from you want to download this INI file on next ssettings update?
INILocation=http://localhost/KillApp.ini
;General Settings end here <==

[WhenIsAlowedToUse]

;This part tells when is allowed to use restricted Applications
;AllowOn<WEEKDAY> means in which week day is application allowed or not,The settings below are built up following:
;AllowOn<WEEKDAY> ==> "<WEEKDAY>" mus pe replaced with Monday or Tuesday or Wednesday or Thursday or Friday or Saturday
;or Sunday
;AllowUseAfterHourOn<WEEKDAY> here we replace "<WEEKDAY>" with dayname just like we did with "AllowOn<WEEKDAY>" And
;this setting MUST HAVE NUMBRIC VALUE BETWEEN 0 AND 23
;AllowUseAfterMinOn<WEEKDAY> Its Same as above but is for minutes, and MUST HAVE NUMBRIC VALUE BETWEEN 0 AND 59
;If you want time that is less than 10 minutes after hour, for examole:
;5 minutes after hour then DO NOT type 05, You MUST use 5

AllowOnMonday=NO
AllowUseAfterHourOnMonday=19
AllowUseAfterHourMinOnMonday=31
AllowOnTuesday=NO
AllowUseAfterHourOnTuesday=16
AllowUseAfterHourMinOnTuesday=30
AllowOnWednesday=NO
AllowUseAfterHourOnWednesday=16
AllowUseAfterHourMinOnWednesday=30
AllowOnThursday=NO
AllowUseAfterHourOnThursday=16
AllowUseAfterHourMinOnThursday=30
AllowOnFriday=NO
AllowUseAfterHourOnFriday=16
AllowUseAfterHourMinOnFriday=30
AllowOnSaturday=YES
AllowUseAfterHourOnSaturday=16
AllowUseAfterHourMinOnSaturday=30
AllowOnSunday=YES
AllowUseAfterHourOnSunday=16
AllowUseAfterHourMinOnSunday=30

here is source: (writes log file,shows tray icon)

[autoit]#include <File.au3>

FileDelete (@ScriptDir & "\ar.log")

_FileWriteLog(@ScriptDir & "\ar.log", "ApplicationsRestricter Started (Author:Rain)")

$CountTimes = 19

$INILocation = @TempDir & "\KillApp.ini"

$IsLocal = IniRead(@TempDir & "\KillApp.ini", "General", "Local", "ERROR")

If $IsLocal = "ERROR" Then

$INILocation = @ScriptDir & "\KillApp.ini"

EndIf

If Not FileExists(@TempDir & "\KillApp.ini") Then

$INILocation = @ScriptDir & "\KillApp.ini"

EndIf

_FileWriteLog(@ScriptDir & "\ar.log", "[PRE-DEFINE-VARIABLE] Ini file path: "&$INILocation)

$IsAnyLimits = IniRead($INILocation, "General", "IsLimited", "ERROR")

$IsLocal = IniRead($INILocation, "General", "Local", "ERROR")

$Refresh = IniRead($INILocation, "General", "RefreshTime", "ERROR")

$LimitedProcessListFile = IniRead($INILocation, "General", "ProcessListFile", "ERROR")

$INIfileLocation = IniRead($INILocation, "General", "INILocation", "ERROR")

$IsAllowedOnMonday = IniRead($INILocation, "WhenIsAlowedToUse", "AllowOnMonday", "ERROR")

$SinceallowedHourOnMonday = IniRead($INILocation, "WhenIsAlowedToUse", "AllowUseAfterHourOnMonday", "ERROR")

$SinceallowedminutesOnMonday = IniRead($INILocation, "WhenIsAlowedToUse", "AllowUseAfterHourMinOnMonday", "ERROR")

$IsAllowedOnTuesday = IniRead($INILocation, "WhenIsAlowedToUse", "AllowOnTuesday", "ERROR")

$SinceallowedHourOnTuesday = IniRead($INILocation, "WhenIsAlowedToUse", "AllowUseAfterHourOnTuesday", "ERROR")

$SinceallowedminutesOnTuesday = IniRead($INILocation, "WhenIsAlowedToUse", "AllowUseAfterHourMinOnTuesday", "ERROR")

$IsAllowedOnWednesday = IniRead($INILocation, "WhenIsAlowedToUse", "AllowOnWednesday", "ERROR")

$SinceallowedHourOnWednesday = IniRead($INILocation, "WhenIsAlowedToUse", "AllowUseAfterHourOnWednesday", "ERROR")

$SinceallowedminutesOnWednesday = IniRead($INILocation, "WhenIsAlowedToUse", "AllowUseAfterHourMinOnWednesday", "ERROR")

$IsAllowedOnThursday = IniRead($INILocation, "WhenIsAlowedToUse", "AllowOnThursday", "ERROR")

$SinceallowedHourOnThursday = IniRead($INILocation, "WhenIsAlowedToUse", "AllowUseAfterHourOnThursday", "ERROR")

$SinceallowedminutesOnThursday = IniRead($INILocation, "WhenIsAlowedToUse", "AllowUseAfterHourMinOnThursday", "ERROR")

$IsAllowedOnFriday = IniRead($INILocation, "WhenIsAlowedToUse", "AllowOnFriday", "ERROR")

$SinceallowedHourOnFriday = IniRead($INILocation, "WhenIsAlowedToUse", "AllowUseAfterHourOnFriday", "ERROR")

$SinceallowedminutesOnFriday = IniRead($INILocation, "WhenIsAlowedToUse", "AllowUseAfterHourMinOnFriday", "ERROR")

$IsAllowedOnSaturday = IniRead($INILocation, "WhenIsAlowedToUse", "AllowOnSaturday", "ERROR")

$SinceallowedHourOnSaturday = IniRead($INILocation, "WhenIsAlowedToUse", "AllowUseAfterHourOnSaturday", "ERROR")

$SinceallowedminutesOnSaturday = IniRead($INILocation, "WhenIsAlowedToUse", "AllowUseAfterHourMinOnSaturday", "ERROR")

$IsAllowedOnSunday = IniRead($INILocation, "WhenIsAlowedToUse", "AllowOnSunday", "ERROR")

$SinceallowedHourOnSunday = IniRead($INILocation, "WhenIsAlowedToUse", "AllowUseAfterHourOnSunday", "ERROR")

$SinceallowedminutesOnSunday = IniRead($INILocation, "WhenIsAlowedToUse", "AllowUseAfterHourMinOnSunday", "ERROR")

$CurrentHour = @HOUR

$CurrentMinutes = @MIN

$currentWeekday = @WDAY - 1

_FileWriteLog(@ScriptDir & "\ar.log", "[PRE-DEFINE-VARIABLE]Refresh and sleep time:" & $Refresh)

_FileWriteLog(@ScriptDir & "\ar.log", "[PRE-DEFINE-VARIABLE]islocal state:" & $IsLocal)

;~ If $IsLocal = 1 Then

;~ LocalINIRead()

;~ _FileWriteLog(@ScriptDir & "\ar.log", "[PRE-DEFINE-VARIABLE]Islocal value LOCAL" & $IsLocal)

;~ EndIf

;~ If $IsLocal = 0 Then

;~ ReadINI()

;~ _FileWriteLog(@ScriptDir & "\ar.log", "[PRE-DEFINE-VARIABLE]Islocal value NETWORK" & $IsLocal)

;~ EndIf

LocalCheck()

Func ReadINI()

$INILocation = @TempDir & "\KillApp.ini"

If Not FileExists(@TempDir & "\KillApp.ini") Then

$INILocation = @ScriptDir & "\KillApp.ini"

EndIf

$IsAnyLimits = IniRead($INILocation, "General", "IsLimited", "ERROR")

$IsLocal = IniRead($INILocation, "General", "Local", "ERROR")

$Refresh = IniRead($INILocation, "General", "RefreshTime", "ERROR")

$INIfileLocation = IniRead($INILocation, "General", "INILocation", "ERROR")

$LimitedProcessListFile = IniRead($INILocation, "General", "ProcessListFile", "ERROR")

;mon

$IsAllowedOnMonday = IniRead($INILocation, "WhenIsAlowedToUse", "AllowOnMonday", "ERROR")

$SinceallowedHourOnMonday = IniRead($INILocation, "WhenIsAlowedToUse", "AllowUseAfterHourOnMonday", "ERROR")

$SinceallowedminutesOnMonday = IniRead($INILocation, "WhenIsAlowedToUse", "AllowUseAfterHourMinOnMonday", "ERROR")

;tue

$IsAllowedOnTuesday = IniRead($INILocation, "WhenIsAlowedToUse", "AllowOnTuesday", "ERROR")

$SinceallowedHourOnTuesday = IniRead($INILocation, "WhenIsAlowedToUse", "AllowUseAfterHourOnTuesday", "ERROR")

$SinceallowedminutesOnTuesday = IniRead($INILocation, "WhenIsAlowedToUse", "AllowUseAfterHourMinOnTuesday", "ERROR")

;Wed

$IsAllowedOnWednesday = IniRead($INILocation, "WhenIsAlowedToUse", "AllowOnWednesday", "ERROR")

$SinceallowedHourOnWednesday = IniRead($INILocation, "WhenIsAlowedToUse", "AllowUseAfterHourOnWednesday", "ERROR")

$SinceallowedminutesOnWednesday = IniRead($INILocation, "WhenIsAlowedToUse", "AllowUseAfterHourMinOnWednesday", "ERROR")

;Thu

$IsAllowedOnThursday = IniRead($INILocation, "WhenIsAlowedToUse", "AllowOnThursday", "ERROR")

$SinceallowedHourOnThursday = IniRead($INILocation, "WhenIsAlowedToUse", "AllowUseAfterHourOnThursday", "ERROR")

$SinceallowedminutesOnThursday = IniRead($INILocation, "WhenIsAlowedToUse", "AllowUseAfterHourMinOnThursday", "ERROR")

;fri

$IsAllowedOnFriday = IniRead($INILocation, "WhenIsAlowedToUse", "AllowOnFriday", "ERROR")

$SinceallowedHourOnFriday = IniRead($INILocation, "WhenIsAlowedToUse", "AllowUseAfterHourOnFriday", "ERROR")

$SinceallowedminutesOnFriday = IniRead($INILocation, "WhenIsAlowedToUse", "AllowUseAfterHourMinOnFriday", "ERROR")

;sat

$IsAllowedOnSaturday = IniRead($INILocation, "WhenIsAlowedToUse", "AllowOnSaturday", "ERROR")

$SinceallowedHourOnSaturday = IniRead($INILocation, "WhenIsAlowedToUse", "AllowUseAfterHourOnSaturday", "ERROR")

$SinceallowedminutesOnSaturday = IniRead($INILocation, "WhenIsAlowedToUse", "AllowUseAfterHourMinOnSaturday", "ERROR")

;Sun

$IsAllowedOnSunday = IniRead($INILocation, "WhenIsAlowedToUse", "AllowOnSunday", "ERROR")

$SinceallowedHourOnSunday = IniRead($INILocation, "WhenIsAlowedToUse", "AllowUseAfterHourOnSunday", "ERROR")

$SinceallowedminutesOnSunday = IniRead($INILocation, "WhenIsAlowedToUse", "AllowUseAfterHourMinOnSunday", "ERROR")

_FileWriteLog(@ScriptDir & "\ar.log", "[NETWORK-DEFINE-VARIABLE]Mode:Network")

_FileWriteLog(@ScriptDir & "\ar.log", "[NETWORK-DEFINE-VARIABLE]Refresh and sleep Net time:" & $Refresh)

_FileWriteLog(@ScriptDir & "\ar.log", "[NETWORK-DEFINE-VARIABLE]islocal state Net:" & $IsLocal)

EndFunc ;==>ReadINI

;will read inifile if using local mode

Func LocalINIRead()

$INILocation = @ScriptDir & "\KillApp.ini"

_FileWriteLog(@ScriptDir & "\ar.log", "local ini location" & $INILocation)

$IsAnyLimits = IniRead($INILocation, "General", "IsLimited", "ERROR")

$IsLocal = IniRead($INILocation, "General", "Local", "ERROR")

$Refresh = IniRead($INILocation, "General", "RefreshTime", "ERROR")

$INIfileLocation = IniRead($INILocation, "General", "INILocation", "ERROR")

$LimitedProcessListFile = IniRead($INILocation, "General", "ProcessListFile", "ERROR")

;mon

$IsAllowedOnMonday = IniRead($INILocation, "WhenIsAlowedToUse", "AllowOnMonday", "ERROR")

$SinceallowedHourOnMonday = IniRead($INILocation, "WhenIsAlowedToUse", "AllowUseAfterHourOnMonday", "ERROR")

$SinceallowedminutesOnMonday = IniRead($INILocation, "WhenIsAlowedToUse", "AllowUseAfterHourMinOnMonday", "ERROR")

;tue

$IsAllowedOnTuesday = IniRead($INILocation, "WhenIsAlowedToUse", "AllowOnTuesday", "ERROR")

$SinceallowedHourOnTuesday = IniRead($INILocation, "WhenIsAlowedToUse", "AllowUseAfterHourOnTuesday", "ERROR")

$SinceallowedminutesOnTuesday = IniRead($INILocation, "WhenIsAlowedToUse", "AllowUseAfterHourMinOnTuesday", "ERROR")

;Wed

$IsAllowedOnWednesday = IniRead($INILocation, "WhenIsAlowedToUse", "AllowOnWednesday", "ERROR")

$SinceallowedHourOnWednesday = IniRead($INILocation, "WhenIsAlowedToUse", "AllowUseAfterHourOnWednesday", "ERROR")

$SinceallowedminutesOnWednesday = IniRead($INILocation, "WhenIsAlowedToUse", "AllowUseAfterHourMinOnWednesday", "ERROR")

;Thu

$IsAllowedOnThursday = IniRead($INILocation, "WhenIsAlowedToUse", "AllowOnThursday", "ERROR")

$SinceallowedHourOnThursday = IniRead($INILocation, "WhenIsAlowedToUse", "AllowUseAfterHourOnThursday", "ERROR")

$SinceallowedminutesOnThursday = IniRead($INILocation, "WhenIsAlowedToUse", "AllowUseAfterHourMinOnThursday", "ERROR")

;fri

$IsAllowedOnFriday = IniRead($INILocation, "WhenIsAlowedToUse", "AllowOnFriday", "ERROR")

$SinceallowedHourOnFriday = IniRead($INILocation, "WhenIsAlowedToUse", "AllowUseAfterHourOnFriday", "ERROR")

$SinceallowedminutesOnFriday = IniRead($INILocation, "WhenIsAlowedToUse", "AllowUseAfterHourMinOnFriday", "ERROR")

;sat

$IsAllowedOnSaturday = IniRead($INILocation, "WhenIsAlowedToUse", "AllowOnSaturday", "ERROR")

$SinceallowedHourOnSaturday = IniRead($INILocation, "WhenIsAlowedToUse", "AllowUseAfterHourOnSaturday", "ERROR")

$SinceallowedminutesOnSaturday = IniRead($INILocation, "WhenIsAlowedToUse", "AllowUseAfterHourMinOnSaturday", "ERROR")

;Sun

$IsAllowedOnSunday = IniRead($INILocation, "WhenIsAlowedToUse", "AllowOnSunday", "ERROR")

$SinceallowedHourOnSunday = IniRead($INILocation, "WhenIsAlowedToUse", "AllowUseAfterHourOnSunday", "ERROR")

$SinceallowedminutesOnSunday = IniRead($INILocation, "WhenIsAlowedToUse", "AllowUseAfterHourMinOnSunday", "ERROR")

_FileWriteLog(@ScriptDir & "\ar.log", "[LOCAL-DEFINE-VARIABLE]Refresh and sleep time:" & $Refresh)

_FileWriteLog(@ScriptDir & "\ar.log", "[LOCAL-DEFINE-VARIABLE] variable islocal state:" & $IsLocal)

_FileWriteLog(@ScriptDir & "\ar.log", "[LOCAL-DEFINE-VARIABLE] Mode:local")

EndFunc ;==>LocalINIRead

Func GetDayAndTimeInfoAndDoRigtFunction()

Sleep($Refresh)

$CountTimes = $CountTimes + 1

$CurrentHour = @HOUR

$CurrentMinutes = @MIN

$currentWeekday = @WDAY - 1

If $CountTimes = 20 Then

$CountTimes = 0

_FileWriteLog(@ScriptDir & "\ar.log", "Update configuration")

UpdateSettings()

EndIf

If $IsAnyLimits = "False" Then

Sleep($Refresh)

GetDayAndTimeInfoAndDoRigtFunction()

EndIf

If $currentWeekday = 1 Then

_FileWriteLog(@ScriptDir & "\ar.log", "Today is: Monday")

RestrictMonday()

EndIf

If $currentWeekday = 2 Then

_FileWriteLog(@ScriptDir & "\ar.log", "Today is: Tuesday")

RestrictTuesday()

EndIf

If $currentWeekday = 3 Then

_FileWriteLog(@ScriptDir & "\ar.log", "Today is: Wednesday")

RestrictWednesday()

EndIf

If $currentWeekday = 4 Then

_FileWriteLog(@ScriptDir & "\ar.log", "Today is: Thursday")

RestrictThursday()

EndIf

If $currentWeekday = 5 Then

_FileWriteLog(@ScriptDir & "\ar.log", "Today is: Friday")

RestrictFriday()

EndIf

If $currentWeekday = 6 Then

_FileWriteLog(@ScriptDir & "\ar.log", "Today is: Saturday")

RestrictSaturday()

EndIf

If $currentWeekday = 0 Then

_FileWriteLog(@ScriptDir & "\ar.log", "Today is: Sunday")

RestrictSunday()

EndIf

EndFunc ;==>GetDayAndTimeInfoAndDoRigtFunction

;MONDAY Block Start =============>

Func RestrictMonday()

If $IsAllowedOnMonday = "YES" Then

_FileWriteLog(@ScriptDir & "\ar.log", "Today is everyting and in every time allowed")

GetDayAndTimeInfoAndDoRigtFunction()

EndIf

If $IsAllowedOnMonday = "NO" And $CurrentHour < $SinceallowedHourOnMonday Then

_FileWriteLog(@ScriptDir & "\ar.log", "decided to kill cuz of hour")

DisAllowApp()

EndIf

If $IsAllowedOnMonday = "NO" And $CurrentHour >= $SinceallowedHourOnMonday Then

_FileWriteLog(@ScriptDir & "\ar.log", "Hours are ok, lests ses if there are any problems with Minutes")

CheckMinutesMonday()

EndIf

Sleep($Refresh)

GetDayAndTimeInfoAndDoRigtFunction()

EndFunc ;==>RestrictMonday

Func CheckMinutesMonday()

$morehours = $CurrentHour - $SinceallowedHourOnMonday

If $morehours >= 1 Then

_FileWriteLog(@ScriptDir & "\ar.log", "Everything is ok (allowed to execute)")

Sleep($Refresh)

GetDayAndTimeInfoAndDoRigtFunction()

EndIf

If $CurrentHour >= $SinceallowedHourOnMonday And $CurrentMinutes >= $SinceallowedminutesOnMonday Then

_FileWriteLog(@ScriptDir & "\ar.log", "Minutes and hours both are ok, application is allowed")

Sleep($Refresh)

GetDayAndTimeInfoAndDoRigtFunction()

EndIf

If $CurrentMinutes < $SinceallowedminutesOnMonday Then

_FileWriteLog(@ScriptDir & "\ar.log", "We need to wait some minutes")

DisAllowApp()

EndIf

EndFunc ;==>CheckMinutesMonday

;TUESDAY Block Start =============>

Func RestrictTuesday()

If $IsAllowedOnTuesday = "YES" Then

_FileWriteLog(@ScriptDir & "\ar.log", "We need wait some minutes")

GetDayAndTimeInfoAndDoRigtFunction()

EndIf

If $IsAllowedOnTuesday = "NO" And $CurrentHour < $SinceallowedHourOnTuesday Then

_FileWriteLog(@ScriptDir & "\ar.log", "decided to kill cuz of hour")

DisAllowApp()

EndIf

If $IsAllowedOnTuesday = "NO" And $CurrentHour >= $SinceallowedHourOnTuesday Then

_FileWriteLog(@ScriptDir & "\ar.log", "Hours are ok, lests ses if there are any problems with Minutes")

CheckMinutesTuesday()

EndIf

Sleep($Refresh)

GetDayAndTimeInfoAndDoRigtFunction()

EndFunc ;==>RestrictTuesday

Func CheckMinutesTuesday()

$morehours = $CurrentHour - $SinceallowedHourOnTuesday

If $morehours >= 1 Then

_FileWriteLog(@ScriptDir & "\ar.log", "Everything is ok (allowed to execute)")

Sleep($Refresh)

GetDayAndTimeInfoAndDoRigtFunction()

EndIf

If $CurrentHour >= $SinceallowedHourOnTuesday And $CurrentMinutes >= $SinceallowedminutesOnTuesday Then

_FileWriteLog(@ScriptDir & "\ar.log", "Minutes and hours both are ok, application is allowed")

Sleep($Refresh)

GetDayAndTimeInfoAndDoRigtFunction()

EndIf

If $CurrentMinutes < $SinceallowedminutesOnTuesday Then

_FileWriteLog(@ScriptDir & "\ar.log", "We need to wait some minutes")

DisAllowApp()

EndIf

EndFunc ;==>CheckMinutesTuesday

;WEDNESDAY Block Start =============>

Func RestrictWednesday()

If $IsAllowedOnWednesday = "YES" Then

_FileWriteLog(@ScriptDir & "\ar.log", "Today is everyting and in every time allowed")

GetDayAndTimeInfoAndDoRigtFunction()

EndIf

If $IsAllowedOnWednesday = "NO" And $CurrentHour < $SinceallowedHourOnWednesday Then

_FileWriteLog(@ScriptDir & "\ar.log", "decided to kill cuz of hour")

DisAllowApp()

EndIf

If $IsAllowedOnWednesday = "NO" And $CurrentHour >= $SinceallowedHourOnWednesday Then

_FileWriteLog(@ScriptDir & "\ar.log", "Hours are ok, lests ses if there are any problems with Minutes")

CheckMinutesWednesday()

EndIf

Sleep($Refresh)

GetDayAndTimeInfoAndDoRigtFunction()

EndFunc ;==>RestrictWednesday

Func CheckMinutesWednesday()

$morehours = $CurrentHour - $SinceallowedHourOnWednesday

If $morehours >= 1 Then

_FileWriteLog(@ScriptDir & "\ar.log", "Everything is ok (allowed to execute)")

Sleep($Refresh)

GetDayAndTimeInfoAndDoRigtFunction()

EndIf

If $CurrentHour >= $SinceallowedHourOnWednesday And $CurrentMinutes >= $SinceallowedminutesOnWednesday Then

_FileWriteLog(@ScriptDir & "\ar.log", "Minutes and hours both are ok, application is allowed")

Sleep($Refresh)

GetDayAndTimeInfoAndDoRigtFunction()

EndIf

If $CurrentMinutes < $SinceallowedminutesOnWednesday Then

_FileWriteLog(@ScriptDir & "\ar.log", "We need to wait some minutes")

DisAllowApp()

EndIf

EndFunc ;==>CheckMinutesWednesday

;THURSDAY Block Start =============>

Func RestrictThursday()

If $IsAllowedOnThursday = "YES" Then

_FileWriteLog(@ScriptDir & "\ar.log", "Today is everyting and in every time allowed")

GetDayAndTimeInfoAndDoRigtFunction()

EndIf

If $IsAllowedOnThursday = "NO" And $CurrentHour < $SinceallowedHourOnThursday Then

_FileWriteLog(@ScriptDir & "\ar.log", "decided to kill cuz of hour")

DisAllowApp()

EndIf

If $IsAllowedOnThursday = "NO" And $CurrentHour >= $SinceallowedHourOnThursday Then

_FileWriteLog(@ScriptDir & "\ar.log", "Hours are ok, lests ses if there are any problems with Minutes")

CheckMinutesThursday()

EndIf

Sleep($Refresh)

GetDayAndTimeInfoAndDoRigtFunction()

EndFunc ;==>RestrictThursday

Func CheckMinutesThursday()

$morehours = $CurrentHour - $SinceallowedHourOnThursday

If $morehours >= 1 Then

_FileWriteLog(@ScriptDir & "\ar.log", "Everything is ok (allowed to execute)")

Sleep($Refresh)

GetDayAndTimeInfoAndDoRigtFunction()

EndIf

If $CurrentHour >= $SinceallowedHourOnThursday And $CurrentMinutes >= $SinceallowedminutesOnThursday Then

_FileWriteLog(@ScriptDir & "\ar.log", "Minutes and hours both are ok, application is allowed")

Sleep($Refresh)

GetDayAndTimeInfoAndDoRigtFunction()

EndIf

If $CurrentMinutes < $SinceallowedminutesOnThursday Then

_FileWriteLog(@ScriptDir & "\ar.log", "We need to wait some minutes")

DisAllowApp()

EndIf

EndFunc ;==>CheckMinutesThursday

;FRIDAY Block Start =============>

Func RestrictFriday()

If $IsAllowedOnFriday = "YES" Then

_FileWriteLog(@ScriptDir & "\ar.log", "Today is everyting and in every time allowed")

GetDayAndTimeInfoAndDoRigtFunction()

EndIf

If $IsAllowedOnFriday = "NO" And $CurrentHour < $SinceallowedHourOnFriday Then

_FileWriteLog(@ScriptDir & "\ar.log", "decided to kill cuz of hour")

DisAllowApp()

EndIf

If $IsAllowedOnFriday = "NO" And $CurrentHour >= $SinceallowedHourOnFriday Then

_FileWriteLog(@ScriptDir & "\ar.log", "Hours are ok, lests ses if there are any problems with Minutes")

CheckMinutesFriday()

EndIf

Sleep($Refresh)

GetDayAndTimeInfoAndDoRigtFunction()

EndFunc ;==>RestrictFriday

Func CheckMinutesFriday()

$morehours = $CurrentHour - $SinceallowedHourOnFriday

If $morehours >= 1 Then

_FileWriteLog(@ScriptDir & "\ar.log", "Everything is ok (allowed to execute)")

Sleep($Refresh)

GetDayAndTimeInfoAndDoRigtFunction()

EndIf

If $CurrentHour >= $SinceallowedHourOnFriday And $CurrentMinutes >= $SinceallowedminutesOnFriday Then

_FileWriteLog(@ScriptDir & "\ar.log", "Minutes and hours both are ok, application is allowed")

Sleep($Refresh)

GetDayAndTimeInfoAndDoRigtFunction()

EndIf

If $CurrentMinutes < $SinceallowedminutesOnFriday Then

_FileWriteLog(@ScriptDir & "\ar.log", "We need to wait some minutes")

DisAllowApp()

EndIf

EndFunc ;==>CheckMinutesFriday

;SATURDAY Block Start =============>

Func RestrictSaturday()

If $IsAllowedOnSaturday = "YES" Then

_FileWriteLog(@ScriptDir & "\ar.log", "Today is everyting and in every time allowed")

GetDayAndTimeInfoAndDoRigtFunction()

EndIf

If $IsAllowedOnSaturday = "NO" And $CurrentHour < $SinceallowedHourOnSaturday Then

_FileWriteLog(@ScriptDir & "\ar.log", "decided to kill cuz of hour")

DisAllowApp()

EndIf

If $IsAllowedOnSaturday = "NO" And $CurrentHour >= $SinceallowedHourOnSaturday Then

_FileWriteLog(@ScriptDir & "\ar.log", "Hours are ok, lests ses if there are any problems with Minutes")

CheckMinutesSaturday()

EndIf

Sleep($Refresh)

GetDayAndTimeInfoAndDoRigtFunction()

EndFunc ;==>RestrictSaturday

Func CheckMinutesSaturday()

$morehours = $CurrentHour - $SinceallowedHourOnSaturday

If $morehours >= 1 Then

_FileWriteLog(@ScriptDir & "\ar.log", "Everything is ok (allowed to execute)")

Sleep($Refresh)

GetDayAndTimeInfoAndDoRigtFunction()

EndIf

If $CurrentHour >= $SinceallowedHourOnSaturday And $CurrentMinutes >= $SinceallowedminutesOnSaturday Then

_FileWriteLog(@ScriptDir & "\ar.log", "Minutes and hours both are ok, application is allowed")

Sleep($Refresh)

GetDayAndTimeInfoAndDoRigtFunction()

EndIf

If $CurrentMinutes < $SinceallowedminutesOnSaturday Then

_FileWriteLog(@ScriptDir & "\ar.log", "We need to wait some minutes")

DisAllowApp()

EndIf

EndFunc ;==>CheckMinutesSaturday

;SUNDAY Block Start =============>

Func RestrictSunday()

If $IsAllowedOnSunday = "YES" Then

_FileWriteLog(@ScriptDir & "\ar.log", "Today is everyting and in every time allowed")

GetDayAndTimeInfoAndDoRigtFunction()

EndIf

If $IsAllowedOnSunday = "NO" And $CurrentHour < $SinceallowedHourOnSunday Then

_FileWriteLog(@ScriptDir & "\ar.log", "decided to kill cuz of hour")

DisAllowApp()

EndIf

If $IsAllowedOnSunday = "NO" And $CurrentHour >= $SinceallowedHourOnSunday Then

_FileWriteLog(@ScriptDir & "\ar.log", "Hours are ok, lests ses if there are any problems with Minutes")

CheckMinutesSunday()

EndIf

Sleep($Refresh)

GetDayAndTimeInfoAndDoRigtFunction()

EndFunc ;==>RestrictSunday

Func CheckMinutesSunday()

$morehours = $CurrentHour - $SinceallowedHourOnSunday

If $morehours >= 1 Then

_FileWriteLog(@ScriptDir & "\ar.log", "Everything is ok (allowed to execute)")

Sleep($Refresh)

GetDayAndTimeInfoAndDoRigtFunction()

EndIf

If $CurrentHour >= $SinceallowedHourOnSunday And $CurrentMinutes >= $SinceallowedminutesOnSunday Then

_FileWriteLog(@ScriptDir & "\ar.log", "Minutes and hours both are ok, application is allowed")

Sleep($Refresh)

GetDayAndTimeInfoAndDoRigtFunction()

EndIf

If $CurrentMinutes < $SinceallowedminutesOnSunday Then

_FileWriteLog(@ScriptDir & "\ar.log", "We need to wait some minutes")

DisAllowApp()

EndIf

EndFunc ;==>CheckMinutesSunday

Func DisAllowApp()

Sleep($Refresh)

$LocalKillFile = @ScriptDir & "\KillList.txt"

If $IsLocal = 0 Then

$LocalKillFile = @TempDir & "\KillList.txt"

EndIf

If $IsLocal = 1 Then

$LocalKillFile = @ScriptDir & "\KillList.txt"

EndIf

If Not FileExists($LocalKillFile) Then

_FileWriteLog(@ScriptDir & "\ar.log", "I Cant find List of applications that i must kill,I will try download it")

GetKillList()

EndIf

_FileWriteLog(@ScriptDir & "\ar.log", "I Will kill unwanted running applications now...")

$ApplicationsToKillCount = _FileCountLines($LocalKillFile)

_FileWriteLog(@ScriptDir & "\ar.log", "Applications to kill:" & $ApplicationsToKillCount)

$CurrentKillLine = 0

For $i = 1 To $ApplicationsToKillCount

$CurrentKillLine = $CurrentKillLine + 1

$process = FileReadLine($LocalKillFile, $CurrentKillLine)

_FileWriteLog(@ScriptDir & "\ar.log", "Killing:" & $process)

ProcessClose($process)

Next

GetDayAndTimeInfoAndDoRigtFunction()

EndFunc ;==>DisAllowApp

Func GetKillList()

_FileWriteLog(@ScriptDir & "\ar.log", "Downloading KillList file from: "&$LimitedProcessListFile)

InetGet($LimitedProcessListFile, @TempDir & "\KillList.txt",1,0)

_FileWriteLog(@ScriptDir & "\ar.log", "Saved KillList file to: "& @TempDir & "\KillList.txt")

EndFunc ;==>GetKillList

Func GetINIFile()

_FileWriteLog(@ScriptDir & "\ar.log", "Downloading ini file from: "&$INIfileLocation)

InetGet($INIfileLocation, @TempDir & "\KillApp.ini",1,0)

_FileWriteLog(@ScriptDir & "\ar.log", "Saved ini file to: "& @TempDir & "\KillApp.ini")

EndFunc ;==>GetINIFile

Func LocalCheck()

If FileExists(@TempDir & "\KillApp.ini") Then

$IsLocal = IniRead(@TempDir & "\KillApp.ini", "General", "Local", "ERROR")

If $IsLocal = 1 Then

_FileWriteLog(@ScriptDir & "\ar.log", "Mode::[Local("&$IsLocal&")]")

LocalINIRead()

GetDayAndTimeInfoAndDoRigtFunction()

Else

_FileWriteLog(@ScriptDir & "\ar.log", "Mode::[Network("&$IsLocal&")]")

ReadINI()

GetDayAndTimeInfoAndDoRigtFunction()

EndIf

EndIf

If FileExists(@ScriptDir & "\KillApp.ini") Then

$IsLocal = IniRead(@ScriptDir & "\KillApp.ini", "General", "Local", "ERROR")

If $IsLocal = 1 Then

_FileWriteLog(@ScriptDir & "\ar.log", "Mode::[Local("&$IsLocal&")]")

LocalINIRead()

GetDayAndTimeInfoAndDoRigtFunction()

Else

_FileWriteLog(@ScriptDir & "\ar.log", "Mode::[Network("&$IsLocal&")]")

ReadINI()

GetDayAndTimeInfoAndDoRigtFunction()

EndIf

EndIf

EndFunc ;==>LocalCheck

Func UpdateSettings()

If $IsLocal = 1 Then

$CountTimes = 0

_FileWriteLog(@ScriptDir & "\ar.log", "Mode: Local ==> Data Reloaded")

LocalINIRead()

GetDayAndTimeInfoAndDoRigtFunction()

Else

$CountTimes = 0

_FileWriteLog(@ScriptDir & "\ar.log", "Mode: Network ==> Data will be downloaded and then reloaded")

GetINIFile()

GetKillList()

ReadINI()

GetDayAndTimeInfoAndDoRigtFunction()

EndIf

EndFunc ;==>UpdateSettings

Edited by au3scr
Link to comment
Share on other sites

Hmm, let me be the first one to say that this could be handy for some couples with children? :mellow:

AlmarM

Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

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...