PyNexusAPI 1.0b0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
pynexusapi/__init__.py ADDED
@@ -0,0 +1,429 @@
1
+ import pyautogui as pag
2
+ import os
3
+ import sys
4
+ import subprocess
5
+ import webbrowser
6
+ import time
7
+ import datetime
8
+ import keyboard
9
+ import pyperclip
10
+ import win32clipboard
11
+ import win32con
12
+ import ctypes
13
+ from ctypes import wintypes
14
+ import warnings
15
+ import customtkinter as ctk
16
+
17
+ print("Thanks for using PyNexusAPI by PyNoob CaSP Software (C) 2026! This message can be deleted by going into project's file and just uhm like deleting it..")
18
+
19
+ class DROPFILES(ctypes.Structure):
20
+ _fields_ = [
21
+ ("pFiles", wintypes.DWORD),
22
+ ("pt", wintypes.POINT),
23
+ ("fNC", wintypes.BOOL),
24
+ ("fWide", wintypes.BOOL),
25
+ ]
26
+
27
+ # WARNING: This is BETA version of PyNexusAPI, please download any updates and don't complain, again it's beta >w<
28
+
29
+ osname = os.name
30
+ if osname == "nt":
31
+ osnam = "Windows"
32
+ elif osname == "posix":
33
+ osnam = "Linux"
34
+ else:
35
+ osnam = "Unknown OS"
36
+
37
+ # -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*--*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*--*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
38
+ # PyNexusAPI makes a massive bundle: - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
39
+ # Keyboard writing - pyAutoGUI - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
40
+ # More accurate writing - keyboard - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * -
41
+ # Easy control of OS - OS - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
42
+ # Mouse controls - pyAutoGUI - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * -
43
+ # Easy clipboard - pyperclip - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * -
44
+ # Harder, but better clipboard - win32clipboard - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
45
+ # Time - yes, time is already OK with time.sleep(), but .wait is more accurate than .sleep - * - * - * - * - * - * - * - * - *
46
+ # Screen - pyAutoGUI - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * -
47
+ # ... - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
48
+ # And also - PyNexusAPI is way more easier! For example, win32clipboard requeares commands like OpenClipboard, pyNexusAPI in other hand, doesn't!
49
+ # -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*--*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*--*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
50
+
51
+ class Keyboard:
52
+
53
+ @staticmethod
54
+ def FWrite(text):
55
+ keyboard.write(text)
56
+
57
+ @staticmethod
58
+ def FHold(key):
59
+ keyboard.press(key)
60
+
61
+ @staticmethod
62
+ def FRelease(key):
63
+ keyboard.release(key)
64
+
65
+ @staticmethod
66
+ def FClick(key):
67
+ keyboard.send(key)
68
+
69
+ @staticmethod
70
+ def Write(text, wait=0):
71
+ pag.write(text, interval=wait)
72
+
73
+ @staticmethod
74
+ def Hold(key):
75
+ pag.keyDown(key)
76
+
77
+ @staticmethod
78
+ def Release(key):
79
+ pag.keyUp(key)
80
+
81
+ @staticmethod
82
+ def Click(key):
83
+ pag.press(key)
84
+
85
+ @staticmethod
86
+ def Combination(key1, key2):
87
+ pag.hotkey(key1, key2)
88
+
89
+ class Mouse:
90
+
91
+ @staticmethod
92
+ def MoveTo(xc=500, yc=500, wait=0):
93
+ pag.moveTo(x=xc, y=yc, duration=wait)
94
+
95
+ @staticmethod
96
+ def LeftClick():
97
+ pag.click(button='primary')
98
+
99
+ @staticmethod
100
+ def RightClick():
101
+ pag.click(button='secondary')
102
+
103
+ @staticmethod
104
+ def Hold(button='primary'):
105
+ actual_button = button.strip().lower()
106
+ buttons = {
107
+ "right": lambda: pag.mouseDown(button='secondary'),
108
+ "left": lambda: pag.mouseDown(button='primary'),
109
+ "main": lambda: pag.mouseDown(button='primary'),
110
+ "primary": lambda: pag.mouseDown(button='primary'),
111
+ "secondary": lambda: pag.mouseDown(button='secondary')
112
+ }
113
+ btn = buttons.get(actual_button)
114
+ if btn:
115
+ btn()
116
+ else:
117
+ raise ValueError(f"'{button}' is not mapped for any known mouse button.")
118
+
119
+ @staticmethod
120
+ def Release(button='primary'):
121
+ actual_button = button.strip().lower()
122
+ buttons = {
123
+ "right": lambda: pag.mouseUp(button='secondary'),
124
+ "left": lambda: pag.mouseUp(button='primary'),
125
+ "main": lambda: pag.mouseUp(button='primary'),
126
+ "primary": lambda: pag.mouseUp(button='primary'),
127
+ "secondary": lambda: pag.mouseUp(button='secondary')
128
+ }
129
+ btn = buttons.get(actual_button)
130
+ if btn:
131
+ btn()
132
+ else:
133
+ raise ValueError(f"'{button}' is not mapped for any known mouse button.")
134
+
135
+ class Clipboard:
136
+ @staticmethod
137
+ def CopyText(text):
138
+ pyperclip.copy(text)
139
+
140
+ @staticmethod
141
+ def Paste():
142
+ keyboard.send("ctrl+v")
143
+
144
+ @staticmethod
145
+ def CopyAny(file_path):
146
+ abs_path = os.path.abspath(file_path)
147
+ if not os.path.exists(abs_path):
148
+ raise FileNotFoundError(f"Файл по пути '{abs_path}' не существует!")
149
+ file_str = abs_path + "\x00\x00"
150
+ file_bytes = file_str.encode("utf-16-le")
151
+ dropfiles = DROPFILES()
152
+ dropfiles.pFiles = ctypes.sizeof(DROPFILES)
153
+ dropfiles.fWide = True
154
+ placed_data = bytes(dropfiles) + file_bytes
155
+ win32clipboard.OpenClipboard()
156
+ try:
157
+ win32clipboard.EmptyClipboard()
158
+ hGlobal = ctypes.windll.kernel32.GlobalAlloc(win32con.GMEM_MOVEABLE, len(placed_data))
159
+ pGlobal = ctypes.windll.kernel32.GlobalLock(hGlobal)
160
+ ctypes.memmove(pGlobal, placed_data, len(placed_data))
161
+ ctypes.windll.kernel32.GlobalUnlock(hGlobal)
162
+ win32clipboard.SetClipboardData(win32con.CF_HDROP, hGlobal)
163
+ finally:
164
+ win32clipboard.CloseClipboard()
165
+
166
+ class OSC:
167
+
168
+ @staticmethod
169
+ def CMD():
170
+ current_os = os.name
171
+ if current_os == "nt":
172
+ subprocess.Popen("start cmd", shell=True)
173
+ elif current_os == "posix":
174
+ try:
175
+ subprocess.Popen(["open", "-a", "Terminal"])
176
+ except FileNotFoundError:
177
+ try:
178
+ subprocess.Popen(["gnome-terminal"])
179
+ except FileNotFoundError:
180
+ raise OSError("Unable to load or locate system terminal.")
181
+ else:
182
+ raise OSError(f"OS {current_os} is unknown")
183
+
184
+ @staticmethod
185
+ def PowerShell():
186
+ current_os = os.name
187
+ if current_os == "nt":
188
+ os.system("start powershell")
189
+ else:
190
+ raise OSError(f"OS {current_os} is not Microsoft Windows (nt)")
191
+
192
+ @staticmethod
193
+ def Shutdown(wait=0):
194
+ if os.name == "nt":
195
+ os.system(f"shutdown -s -t {wait}")
196
+ else:
197
+ if wait == 0:
198
+ os.system("shutdown -h now")
199
+ else:
200
+ minutes = max(1, wait // 60)
201
+ os.system(f"shutdown -h +{minutes}")
202
+
203
+ @staticmethod
204
+ def Restart(wait=0):
205
+ if os.name == "nt":
206
+ os.system(f"shutdown -r -t {wait}")
207
+ else:
208
+ if wait == 0:
209
+ os.system("shutdown -r now")
210
+ else:
211
+ minutes = max(1, wait // 60)
212
+ os.system(f"shutdown -r +{minutes}")
213
+
214
+ @staticmethod
215
+ def OpenURL(url):
216
+ webbrowser.open(url)
217
+
218
+ OSName = osnam
219
+
220
+ class Time:
221
+
222
+ @staticmethod
223
+ def Wait(seconds):
224
+ secs = str(seconds).strip()
225
+ if len(secs) == 0:
226
+ secs = 5.0
227
+ warnings.warn("Requested empty time in PyNexusAPI.Time.Wait(). Automatically converted to 5 seconds.", SyntaxWarning)
228
+ elif secs == "0" or secs == "0.0":
229
+ secs = 0.01
230
+ warnings.warn("Seconds can't be 0. Automatically converted to 0.01 second.", SyntaxWarning)
231
+ time.sleep(float(secs))
232
+
233
+ @staticmethod
234
+ def Update():
235
+ global now
236
+ now = datetime.datetime.now()
237
+ now = datetime.datetime.now()
238
+
239
+ class Screen:
240
+
241
+ @staticmethod
242
+ def Size():
243
+ return pag.size()
244
+
245
+ @staticmethod
246
+ def PixelColor(x, y):
247
+ return pag.pixel(x, y)
248
+
249
+ @staticmethod
250
+ def Screenshot(file_name="screenshot", file_type="png"):
251
+ pag.screenshot(f"{file_name}.{file_type}")
252
+
253
+ @staticmethod
254
+ def FindImage(image_path, confidence_level=0.9):
255
+ try:
256
+ position = pag.locateCenterOnScreen(image_path, confidence=confidence_level)
257
+ return position
258
+ except:
259
+ return None
260
+
261
+ class Windows:
262
+ if sys.platform != "win32":
263
+ raise OSError("Class PyNexusAPI.Windows can only be executed on Microsoft Windows")
264
+
265
+ @staticmethod
266
+ def GetActiveTitle():
267
+ hwnd = ctypes.windll.user32.GetForegroundWindow()
268
+ length = ctypes.windll.user32.GetWindowTextLengthW(hwnd)
269
+ buff = ctypes.create_unicode_buffer(length + 1)
270
+ ctypes.windll.user32.GetWindowTextW(hwnd, buff, length + 1)
271
+ return buff.value
272
+
273
+ @staticmethod
274
+ def Close(window_title):
275
+ hwnd = ctypes.windll.user32.FindWindowW(None, window_title)
276
+ if hwnd:
277
+ ctypes.windll.user32.PostMessageW(hwnd, 0x0010, 0, 0)
278
+ else:
279
+ raise LookupError(f"Window with title '{window_title}' not found.")
280
+
281
+ @staticmethod
282
+ def Minimize(window_title):
283
+ hwnd = ctypes.windll.user32.FindWindowW(None, window_title)
284
+ if hwnd:
285
+ ctypes.windll.user32.ShowWindow(hwnd, 6)
286
+ else:
287
+ raise LookupError(f"Window with title '{window_title}' not found.")
288
+
289
+ @staticmethod
290
+ def Maximize(window_title):
291
+ hwnd = ctypes.windll.user32.FindWindowW(None, window_title)
292
+ if hwnd:
293
+ ctypes.windll.user32.ShowWindow(hwnd, 3)
294
+ else:
295
+ raise LookupError(f"Window with title '{window_title}' not found.")
296
+
297
+ @staticmethod
298
+ def Hide(window_title):
299
+ hwnd = ctypes.windll.user32.FindWindowW(None, window_title)
300
+ if hwnd:
301
+ ctypes.windll.user32.ShowWindow(hwnd, 0)
302
+ else:
303
+ raise LookupError(f"Window with title '{window_title}' not found.")
304
+
305
+ @staticmethod
306
+ def Show(window_title):
307
+ hwnd = ctypes.windll.user32.FindWindowW(None, window_title)
308
+ if hwnd:
309
+ ctypes.windll.user32.ShowWindow(hwnd, 5)
310
+ else:
311
+ raise LookupError(f"Window with title '{window_title}' not found.")
312
+
313
+ class macOS:
314
+ if sys.platform != "darwin":
315
+ raise OSError("Class PyNexusAPI.macOS can only be executed on macOS.")
316
+
317
+ @staticmethod
318
+ def Close(app_name):
319
+ cmd = f"osascript -e 'tell application \"{app_name}\" to quit'"
320
+ os.system(cmd)
321
+
322
+ @staticmethod
323
+ def Minimize(app_name):
324
+ cmd = f"osascript -e 'tell application \"Finder\" to set collapsed of window 1 of process \"{app_name}\" to true'"
325
+ os.system(cmd)
326
+
327
+ @staticmethod
328
+ def Maximize(app_name):
329
+ cmd = f"osascript -e 'tell application \"{app_name}\" to set bounds of window 1 to {{0, 0, 1920, 1080}}'"
330
+ os.system(cmd)
331
+
332
+ @staticmethod
333
+ def Notification(title, message):
334
+ cmd = f"osascript -e 'display notification \"{message}\" with title \"{title}\"'"
335
+ os.system(cmd)
336
+
337
+
338
+ class Linux:
339
+ if os.name != "posix" or sys.platform == "darwin":
340
+ raise OSError("Class PyNexusAPI.Linux can only be executed on Linux.")
341
+
342
+ @staticmethod
343
+ def _check_wmctrl():
344
+ if os.system("command -v wmctrl > /dev/null 2>&1") != 0:
345
+ raise RuntimeError("Please install 'wmctrl' to control windows on Linux (sudo apt install wmctrl)")
346
+
347
+ @staticmethod
348
+ def Close(window_title):
349
+ Linux._check_wmctrl()
350
+ os.system(f"wmctrl -c '{window_title}'")
351
+
352
+ @staticmethod
353
+ def Minimize(window_title):
354
+ Linux._check_wmctrl()
355
+ os.system(f"wmctrl -r '{window_title}' -b add,shaded")
356
+
357
+ @staticmethod
358
+ def Maximize(window_title):
359
+ Linux._check_wmctrl()
360
+ os.system(f"wmctrl -r '{window_title}' -b add,maximized_vert,maximized_horz")
361
+
362
+ @staticmethod
363
+ def Notification(title, message):
364
+ os.system(f"notify-send '{title}' '{message}'")
365
+
366
+ class Log:
367
+ _orig_print = print
368
+ _log_file = "latest.log"
369
+
370
+ @staticmethod
371
+ def Hook(file_name="latest.log"):
372
+ Log._log_file = file_name
373
+ def log_print(*args, **kwargs):
374
+ Log._orig_print(*args, **kwargs)
375
+ separator = kwargs.get("sep", " ")
376
+ end_char = kwargs.get("end", "\n")
377
+ log_string = separator.join(str(arg) for arg in args) + end_char
378
+
379
+ try:
380
+ with open(Log._log_file, "a", encoding="utf-8") as f:
381
+ f.write(log_string)
382
+ except Exception as e:
383
+ try:
384
+ Log._orig_print(f"[PyNexusAPI.Log] Error: Unable to log: {e}")
385
+ except:
386
+ pass
387
+ import builtins
388
+ builtins.print = log_print
389
+
390
+ @staticmethod
391
+ def Unhook():
392
+ import builtins
393
+ builtins.print = Log._orig_print
394
+
395
+ class App:
396
+ def __init__(self, title="PyNexusAPI Window", size="600x400", theme="dark"):
397
+ ctk.set_appearance_mode(theme)
398
+ ctk.set_default_color_theme("dark-blue")
399
+ self.window = ctk.CTk()
400
+ self.window.title(title)
401
+ self.window.geometry(size)
402
+
403
+ @staticmethod
404
+ def AddText(self, text, font_size=16, pady=10):
405
+ label = ctk.CTkLabel(self.window, text=text, font=("Arial", font_size))
406
+ label.pack(pady=pady)
407
+ return label
408
+
409
+ @staticmethod
410
+ def AddButton(self, text, command, pady=10):
411
+ btn = ctk.CTkButton(self.window, text=text, command=command)
412
+ btn.pack(pady=pady)
413
+ return btn
414
+
415
+ @staticmethod
416
+ def AddInput(self, placeholder="Input something...", width=250, pady=10):
417
+ entry = ctk.CTkEntry(self.window, placeholder_text=placeholder, width=width)
418
+ entry.pack(pady=pady)
419
+ return entry
420
+
421
+ @staticmethod
422
+ def AddCheckbox(self, text, command=None, pady=10):
423
+ checkbox = ctk.CTkCheckBox(self.window, text=text, command=command)
424
+ checkbox.pack(pady=pady)
425
+ return checkbox
426
+
427
+ @staticmethod
428
+ def Run(self):
429
+ self.window.mainloop()
@@ -0,0 +1,28 @@
1
+ Metadata-Version: 2.4
2
+ Name: PyNexusAPI
3
+ Version: 1.0b0
4
+ Summary: A massive bundle bridge for lazy developers to control OS, GUI, Keyboard and Mouse
5
+ Author: Noob3ButUkr
6
+ Classifier: Programming Language :: Python :: 3
7
+ Classifier: Operating System :: Microsoft :: Windows
8
+ Classifier: Operating System :: MacOS
9
+ Classifier: Operating System :: POSIX :: Linux
10
+ Requires-Python: >=3.7
11
+ Description-Content-Type: text/markdown
12
+ Requires-Dist: pyautogui
13
+ Requires-Dist: keyboard
14
+ Requires-Dist: pyperclip
15
+ Requires-Dist: customtkinter
16
+ Requires-Dist: pywin32; platform_system == "Windows"
17
+ Dynamic: author
18
+ Dynamic: classifier
19
+ Dynamic: description
20
+ Dynamic: description-content-type
21
+ Dynamic: requires-dist
22
+ Dynamic: requires-python
23
+ Dynamic: summary
24
+
25
+ \# PyNexusAPI (no not GD nexus, it would be Pyfnm04API then.)
26
+
27
+ The ultimate bridge between lazy developers and low-level libraries, designed for good..
28
+
@@ -0,0 +1,5 @@
1
+ pynexusapi/__init__.py,sha256=UGYz8L90YKODMODup58IheG-D09yVrcifh2OzaSHmDc,14910
2
+ pynexusapi-1.0b0.dist-info/METADATA,sha256=wQnpIO4fuef6lUDimxx1Kd5ZOs8Me0eAE8mkFqFszrY,909
3
+ pynexusapi-1.0b0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
4
+ pynexusapi-1.0b0.dist-info/top_level.txt,sha256=YwhW4mLTMMA9n-gDdsRbPRbBgpwtAXiwCTdhP5uPMuE,11
5
+ pynexusapi-1.0b0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (82.0.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1 @@
1
+ pynexusapi