You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.3 KiB
39 lines
1.3 KiB
import win32clipboard
|
|
import keyboard # keyboard functions
|
|
import time # Some operations need wait
|
|
import random # random number for test
|
|
# set clipboard data
|
|
def TextSet(inTextStr):
|
|
win32clipboard.OpenClipboard()
|
|
win32clipboard.EmptyClipboard()
|
|
win32clipboard.SetClipboardText(inTextStr)
|
|
win32clipboard.CloseClipboard()
|
|
|
|
# get clipboard data
|
|
def TextGet():
|
|
win32clipboard.OpenClipboard()
|
|
data = win32clipboard.GetClipboardData()
|
|
win32clipboard.CloseClipboard()
|
|
return data
|
|
# Test in has text cursor and ready to apply
|
|
def InputIsFocused():
|
|
keyboard.press_and_release("ctrl+a")
|
|
keyboard.press_and_release("backspace") # remove old text
|
|
lTextForTest = str(random.randrange(100,99999))
|
|
keyboard.write(lTextForTest)
|
|
keyboard.press_and_release("ctrl+a")
|
|
keyboard.press_and_release("ctrl+c")
|
|
time.sleep(2)
|
|
keyboard.press_and_release("backspace") # remove old text
|
|
lClipboardText = TextGet()
|
|
lResult = lClipboardText == lTextForTest
|
|
return lResult
|
|
# Check if cmd is opened
|
|
def CMDIsOpen():
|
|
lTextForTest = str(random.randrange(100,99999))
|
|
keyboard.write(lTextForTest+" |clip")
|
|
keyboard.press_and_release("enter")
|
|
time.sleep(2)
|
|
lClipboardText = TextGet()
|
|
lResult = lClipboardText == lTextForTest
|
|
return lResult |