Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## By Cloaky
- import win32com.client
- import time
- ## Configurations ##
- #Sound
- PlaySounds = True
- OnlyWhenSilent = True
- SoundCallIncoming = "B:/Others/EventGhost/Sounds/CallIncoming.wav"
- SoundNewTextMessage = "B:/Others/EventGhost/Sounds/TextMessage.wav"
- SoundNewMail = "B:/Others/EventGhost/Sounds/NewMail.wav"
- #iTunes
- iTunesSoundVolumeLow = 0.50
- iTunesSoundVolumeStep = 5
- iTunesSoundVolumeStepDelay = 0.25
- #Logs
- LogEvents = False
- LogDirectory = "B:/Backup/iDevice/Logs/"
- #Others
- Password = "9999"
- EmailSender = "Cloaky"
- ForceClose = True
- ####################
- iTunesIsRunning = False
- Event = eg.event.suffix
- EventPart = Event.split('::')
- objWMIService = win32com.client.Dispatch("WbemScripting.SWbemLocator")
- objSWbemServices = objWMIService.ConnectServer('.',"root\cimv2")
- colItems = objSWbemServices.ExecQuery("Select * from Win32_Process")
- for objItem in colItems:
- if objItem.Name == "iTunes.exe":
- iTunes = win32com.client.gencache.EnsureDispatch("iTunes.Application")
- iTunesSoundVolumeLow *= iTunes.SoundVolume
- iTunesIsRunning = True
- break
- def PlaySound(Sound):
- if PlaySounds == True:
- if OnlyWhenSilent == False or OnlyWhenSilent == True and EventPart[1] == "Silent":
- LowiTunesVolume()
- eg.plugins.System.PlaySound(Sound, 1)
- if Sound != SoundCallIncoming:
- time.sleep(1)
- RaisingiTunesVolume()
- def LowiTunesVolume():
- if iTunesIsRunning == True and iTunes.PlayerState != 0:
- eg.globals.iTunesSoundVolume = iTunes.SoundVolume
- while iTunes.SoundVolume > iTunesSoundVolumeLow:
- iTunes.SoundVolume -= iTunesSoundVolumeStep
- time.sleep(iTunesSoundVolumeStepDelay)
- def RaisingiTunesVolume():
- if iTunesIsRunning == True and iTunes.PlayerState != 0:
- while iTunes.SoundVolume < eg.globals.iTunesSoundVolume:
- iTunes.SoundVolume += iTunesSoundVolumeStep
- time.sleep(iTunesSoundVolumeStepDelay)
- def LogEvent(Text):
- if LogEvents == True:
- File = open(LogDirectory + eg.Utils.time.strftime('%d-%m-%Y') + ".txt", 'a')
- File.write(eg.Utils.time.strftime('%H:%M:%S - ') + Text + '\n')
- File.close()
- if EventPart[2] == "CallIncoming":
- print eg.Utils.time.strftime('%H:%M:%S') + " - Incoming Call."
- PlaySound(SoundCallIncoming)
- LogEvent("Incoming Call (" + EventPart[3] + ")")
- elif EventPart[2] == "CallDialed":
- print eg.Utils.time.strftime('%H:%M:%S') + " - Outgoing Call."
- LowiTunesVolume()
- LogEvent("Outgoing Call (" + EventPart[3] + ")")
- elif EventPart[2] == "CallDeclined":
- print eg.Utils.time.strftime('%H:%M:%S') + " - Call Declined."
- RaisingiTunesVolume()
- LogEvent("Call Declined (" + EventPart[3] + ")")
- elif EventPart[2] == "CallAccept":
- print eg.Utils.time.strftime('%H:%M:%S') + " - Call Accepted."
- if iTunesIsRunning == True and iTunes.PlayerState != 0:
- eg.globals.iTunesPaused = 1
- iTunes.Pause()
- else:
- eg.globals.iTunesPaused = 0
- LogEvent("Call Accepted (" + EventPart[3] + ")")
- elif EventPart[2] == "CallEnd":
- print eg.Utils.time.strftime('%H:%M:%S') + " - Call Ended."
- if iTunesIsRunning == True and eg.globals.iTunesPaused == 1 and iTunes.PlayerState == 0:
- iTunes.Play()
- eg.globals.iTunesPaused = 0
- RaisingiTunesVolume()
- LogEvent("Call Ended (" + EventPart[3] + ")")
- elif EventPart[2] == "SMS":
- PlaySound(SoundNewTextMessage)
- LogEvent("New Text Message (" + EventPart[3] + ")")
- if EventPart[4] == Password + ":Lock":
- print eg.Utils.time.strftime('%H:%M:%S') + " - New Text Message, Locking Computer."
- eg.plugins.System.LockWorkstation()
- elif EventPart[4] == Password + ":Shut":
- eg.plugins.System.PowerDown(ForceClose)
- elif EventPart[4] == Password + ":Reboot":
- eg.plugins.System.Reboot(ForceClose)
- elif EventPart[2] == "Mail":
- PlaySound(SoundNewMail)
- LogEvent("New Mail (" + EventPart[3] + ")")
- if EventPart[3] == EmailSender:
- if EventPart[4] == Password + ":Lock":
- print eg.Utils.time.strftime('%H:%M:%S') + " - New Mail, Locking Computer."
- eg.plugins.System.LockWorkstation()
- elif EventPart[4] == Password + ":Shut":
- eg.plugins.System.PowerDown(ForceClose)
- elif EventPart[4] == Password + ":Reboot":
- eg.plugins.System.Reboot(ForceClose)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement