401 - 450 Flashcards
pyautogui.countdown()
обратный отщет в секундах.
print(pyautogui.countdown(10)) 10 9 8 7 6 5 4 3 2 1 None
Z-score
is a numerical measurement that describes a value’s relationship to the mean of a group of values. Z-score is measured in terms of standard deviations from the mean. If a Z-score is 0, it indicates that the data point’s score is identical to the mean score.
scipy.stats.zscore
function computes the relative Z-score of the input data, relative to the sample mean and standard deviation.
df[(np.abs(stats.zscore(df)) < 3).all(axis=1)]
from scipy import stats arr1 = [[20, 2, 7, 1, 34], [50, 12, 12, 34, 4]] print(stats.zscore(arr1)) 👉 [[-1. -1. -1. -1. 1.] [ 1. 1. 1. 1. -1.]]
arr1 = [[20, 2, 7, 1, 34], [50, 12, 12, 34, 4]] print(stats.zscore(arr1, axis = 1)) 👉 [[ 0.57251144 -0.85876716 -0.46118977 -0.93828264 1.68572813] [ 1.62005758 -0.61045648 -0.61045648 0.68089376 -1.08003838]]
arr2 = [[50, 12, 12, 34, 4], [12, 11, 10, 34, 21]] print (stats.zscore(arr2, axis = 1)) 👉 [[ 1.62005758 -0.61045648 -0.61045648 0.68089376 -1.08003838] [-0.61601725 -0.72602033 -0.83602341 1.80405051 0.37401047]]
pyautogui.FAILSAFE
When fail-safe mode is True, moving the mouse to the upper-left will raise a pyautogui.FailSafeException that can abort your program
pyautogui.FAILSAFE = True
pyautogui.dragTo(x, y, duration=num_seconds)
drag mouse to XY
pyautogui.dragRel(xOffset, yOffset, duration=num_seconds)
drag mouse relative to its
current position
pyautogui.getActiveWindowTitle()
получить имя активной программы(титель)
print(pyautogui.getActiveWindowTitle()) 👉 untitled1 – C:\Users\Viktor\Desktop\Test.py IntelliJ IDEA
pyautogui.getAllTitles()
get all Titles of open programs
pyautogui.getAllWindows()
получить индефикаторы всех запущенных программ
print(pyautogui.getAllWindows()) [Win32Window(hWnd=69814), Win32Window(hWnd=65780), Win32Window(hWnd=72764), Win32Window(hWnd=138294), Win32Window(hWnd=72752), Win32Window(hWnd=203818), Win32Window(hWnd=138278), Win32Window(hWnd=138248), Win32Window(hWnd=138246), Win32Window(hWnd=138252), Win32Window(hWnd=203786), Win32Window(hWnd=138260), Win32Window(hWnd=138258), Win32Window(hWnd=138264), Win32Window(hWnd=138262), Win32Window(hWnd=138268), Win32Window(hWnd=138266), Win32Window(hWnd=138272), Win32Window(hWnd=138270), Win32Window(hWnd=138276), Win32Window
pyautogui.getActiveWindow()
получить позицию и название активного окна.
print(pyautogui.getActiveWindow()) <Win32Window left="5653", top="2045", width="1919", height="1995", title="untitled1 – C:\Users\Viktor\Desktop\Test.py IntelliJ IDEA">
pyautogui.getWindowsAt()
получить ендификатор окна программы в определенных координатах
print(pyautogui.getWindowsAt())
👉 [Win32Window(hWnd=532000), Win32Window(hWnd=131408)]
pyautogui.getWindowsWithTitle()
получить эндификатор программы с определленным заголловком(титле)
pyautogui.getWindowsWithTitle("Everything") 👉 [Win32Window(hWnd=532000)]
pyautogui.hotkey()
Keyboard hotkeys like Ctrl-S or Ctrl-Shift-1 can be done by passing a list of key names to hotkey()
>>> pyautogui.hotkey('ctrl', 'c') # ctrl-c to copy >>> pyautogui.hotkey('ctrl', 'v') # ctrl-v to paste
pyautogui.keyDown(key_name)
pyautogui.keyUp(key_name)
Individual button down and up events can be called separately
Message Box Functions
pyautogui.alert()
pyautogui.confirm()
pyautogui.prompt()
pyautogui.alert('This displays some text with an OK button.')
pyautogui.confirm('This displays text and has an OK and Cancel button.') 'OK'pyautogui.confirm('This displays text and has an OK and Cancel button.') 'OK'
pyautogui.prompt('This lets the user type in a string and press OK.') 'This is what I typed in.'
pyautogui.mouseDown(x=moveToX, y=moveToY, button=’left’)
pyautogui.mouseUp(x=moveToX, y=moveToY, button=’left’)
Individual button down and up events can be called separatelycan be called separately
pyautogui.moveRel(xOffset, yOffset, duration=num_seconds)
move mouse relative to its current position
pyautogui.moveRel(xOffset, yOffset, duration=num_seconds)
pyautogui.moveTo(x, y, duration=num_seconds)pyautogui.moveTo(x, y, duration=num_seconds)
move mouse to XY coordinates over num_second seconds
pyautogui.moveTo(x, y, duration=num_seconds)
The pyautogui.easeOutQuad is the reverse: the mouse cursor starts moving fast but slows down as it approaches the destination. The pyautogui.easeOutElastic will overshoot the destination and “rubber band” back and forth until it settles at the destination. pyautogui.moveTo(100, 100, 2, pyautogui.easeInQuad) # start slow, end fast pyautogui.moveTo(100, 100, 2, pyautogui.easeOutQuad) # start fast, end slow pyautogui.moveTo(100, 100, 2, pyautogui.easeInOutQuad) # start and end fast, slow in middle pyautogui.moveTo(100, 100, 2, pyautogui.easeInBounce) # bounce at the end pyautogui.moveTo(100, 100, 2, pyautogui.easeInElastic) # rubber band at the end
pyautogui.PAUSE
Set up pause after each PyAutoGUI cal
~~~
pyautogui.PAUSE = 2.5
~~~
pyautogui.getpixel()
obtain the RGB color of a pixel in a screenshot, use the Image object’s.
import pyautogui im = pyautogui.screenshot() im.getpixel((100, 200)) 👉 (130, 135, 144)