Skip to content

Commit da8697d

Browse files
Merge pull request #239 from Siddhesh-Agarwal/master
Important fix and small improvement
2 parents 7966d4d + 4f78f57 commit da8697d

File tree

2 files changed

+14
-19
lines changed

2 files changed

+14
-19
lines changed

pywhatkit/__init__.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from pywhatkit.ascii_art import image_to_ascii_art
1212
from pywhatkit.handwriting import text_to_handwriting
1313
from pywhatkit.mail import send_hmail, send_mail
14-
from pywhatkit.misc import info, playonyt, search, show_history, web_screenshot
14+
from pywhatkit.misc import info, playonyt, search, show_history, take_screenshot
1515
from pywhatkit.sc import cancel_shutdown, shutdown
1616
from pywhatkit.whats import (
1717
open_web,
@@ -22,8 +22,9 @@
2222
sendwhats_image,
2323
)
2424

25-
if system().lower() in ("darwin", "windows"):
25+
_system = system().lower()
26+
if _system in ("darwin", "windows"):
2627
from pywhatkit.misc import take_screenshot
2728

28-
if system().lower() == "windows":
29+
if _system == "windows":
2930
from pywhatkit.remotekit import start_server

pywhatkit/core/core.py

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,7 @@
66
from webbrowser import open
77

88
import requests
9-
from pyautogui import (
10-
click,
11-
hotkey,
12-
locateOnScreen,
13-
moveTo,
14-
press,
15-
size,
16-
typewrite,
17-
)
9+
from pyautogui import click, hotkey, locateOnScreen, moveTo, press, size, typewrite
1810

1911
from pywhatkit.core.exceptions import InternetException
2012

@@ -31,12 +23,13 @@ def close_tab(wait_time: int = 2) -> None:
3123
"""Closes the Currently Opened Browser Tab"""
3224

3325
time.sleep(wait_time)
34-
if system().lower() in ("windows", "linux"):
26+
_system = system().lower()
27+
if _system in ("windows", "linux"):
3528
hotkey("ctrl", "w")
36-
elif system().lower() == "darwin":
29+
elif _system == "darwin":
3730
hotkey("command", "w")
3831
else:
39-
raise Warning(f"{system().lower()} not supported!")
32+
raise Warning(f"{_system} not supported!")
4033
press("enter")
4134

4235

@@ -96,7 +89,8 @@ def send_message(message: str, receiver: str, wait_time: int) -> None:
9689
def copy_image(path: str) -> None:
9790
"""Copy the Image to Clipboard based on the Platform"""
9891

99-
if system().lower() == "linux":
92+
_system = system().lower()
93+
if _system == "linux":
10094
if pathlib.Path(path).suffix in (".PNG", ".png"):
10195
os.system(f"copyq copy image/png - < {path}")
10296
elif pathlib.Path(path).suffix in (".jpg", ".JPG", ".jpeg", ".JPEG"):
@@ -105,7 +99,7 @@ def copy_image(path: str) -> None:
10599
raise Exception(
106100
f"File Format {pathlib.Path(path).suffix} is not Supported!"
107101
)
108-
elif system().lower() == "windows":
102+
elif _system == "windows":
109103
from io import BytesIO
110104

111105
import win32clipboard # pip install pywin32
@@ -120,7 +114,7 @@ def copy_image(path: str) -> None:
120114
win32clipboard.EmptyClipboard()
121115
win32clipboard.SetClipboardData(win32clipboard.CF_DIB, data)
122116
win32clipboard.CloseClipboard()
123-
elif system().lower() == "darwin":
117+
elif _system == "darwin":
124118
if pathlib.Path(path).suffix in (".jpg", ".jpeg", ".JPG", ".JPEG"):
125119
os.system(
126120
f"osascript -e 'set the clipboard to (read (POSIX file \"{path}\") as JPEG picture)'"
@@ -130,7 +124,7 @@ def copy_image(path: str) -> None:
130124
f"File Format {pathlib.Path(path).suffix} is not Supported!"
131125
)
132126
else:
133-
raise Exception(f"Unsupported System: {system().lower()}")
127+
raise Exception(f"Unsupported System: {_system}")
134128

135129

136130
def send_image(path: str, caption: str, receiver: str, wait_time: int) -> None:

0 commit comments

Comments
 (0)