예제 #1
1
 def start(self):
     """Register hotkeys and waits for exit"""
     # The main hot_key
     keyboard.add_hotkey('esc', self.toggle_clicking)
     # Hotkeys for changing speed
     keyboard.add_hotkey('right', self.change_speed, args=(-1,))
     keyboard.add_hotkey('left', self.change_speed, args=(1,))
     keyboard.add_hotkey('up', self.change_speed, args=(0,))
     keyboard.add_hotkey('down', self.change_speed, args=(0,))
     print("Stick Click is ready.")
     print("Press CTRL+ALT to exit.")
     print("Press ESC to start/stop clicking.")
     # Exit Hotkey
     keyboard.wait('ctrl+alt')
예제 #2
0
key.add_hotkey('ctrl+f1', login,
               suppress=key_suppress)  #login using config user and pass
key.add_hotkey('ctrl+f2', quickTest, suppress=key_suppress)  #TEST
key.add_hotkey('ctrl+f3', decrementLogiWait,
               suppress=key_suppress)  #-1 logistics to wait for
key.add_hotkey('ctrl+f4', incrementLogiWait,
               suppress=key_suppress)  #+1 logistics to wait for

key.add_hotkey('ctrl+f5', decrementRepair,
               suppress=key_suppress)  #-1 repair cycle skip
key.add_hotkey('ctrl+f6', incrementRepair,
               suppress=key_suppress)  #+1 repair cycle skip
key.add_hotkey('ctrl+f7', decrementBurn, suppress=key_suppress)  #-1 big cycle
key.add_hotkey('ctrl+f8', incrementBurn, suppress=key_suppress)  #+1 big cycle

key.add_hotkey('ctrl+f10', resetProgress,
               suppress=key_suppress)  #reset runs and cycles to 0
key.add_hotkey('ctrl+f11', testColorPerformance,
               suppress=key_suppress)  #performance test
key.add_hotkey('ctrl+f12', logiSync,
               suppress=key_suppress)  #get times for logi

key.add_hotkey('8', mouseShift, args=(0, -1))  #up
key.add_hotkey('4', mouseShift, args=(-1, 0))  #left
key.add_hotkey('6', mouseShift, args=(1, 0))  #right
key.add_hotkey('2', mouseShift, args=(0, 1))  #down

#print(key.read_key())
key.wait('esc')
예제 #3
0
import keyboard, os
print(keyboard.wait("a || b"))
os.system("pause")
예제 #4
0
def key_struck():
    kb.wait('esc')
    print('Esc pressed.\n')
예제 #5
0
 def run(self):
     import keyboard
     keyboard.wait()
예제 #6
0
          level,
          ', $',
          money,
          ', time ',
          minutes,
          ':',
          seconds,
          sep='')

    press(whip)
    sleep(1 / 60)
    release(whip)
    sleep(1)


print('click into spelunky, then press p to start the bot')
wait('p')
while 1:
    gs = gameState()
    if gs == 0:
        play()
    elif gs in [1, 2, 3]:
        loading()
    elif gs == 11:
        levelTransition()
    elif gs == 30:
        restart()
    else:
        print('error: unknown game state', gs)
        break
예제 #7
0
def listen(tecla):
    while True:
        keyboard.wait(tecla)
        print("- Tecla pressionada: ", tecla)
예제 #8
0
                (button[1] + 1, button[0]))
        else:
            if args.log:
                print((event.button, 1))
            c.execute('''INSERT INTO mouseclicks VALUES (?, ?)''',
                      (event.button, 1))
    if record:
        btn = f'M-{event.button}'
        if btn in current_recording:
            current_recording[btn] += 1
        else:
            current_recording[btn] = 1


keyboard.hook(on_key_press)
mouse.hook(on_mouse_press)

print('Logging has begun')
print(
    'Press ctrl+shift+a to start a seperate recording session that will be saved to a text file'
)

if args.backup:
    while True:
        time.sleep(args.backup * 60)
        shutil.copy('keydata.db',
                    f'{ensure_dir("backups")}/backup-{time.time()}.db')
        print('Made backup of database.')
else:
    keyboard.wait()
예제 #9
0
        if step[0] == 'keyreleased':
            t_offset = time.perf_counter() - offset_timer - st
            st = (float(step[-1]) - tlast - t_offset) / speed
            offset_timer = time.perf_counter()
            if st > 0:
                time.sleep(st)
            stt += t_offset
            autoit.send(step[1])
            tlast = float(step[-1])
            continue

        if step[0] == 'done':
            print('End playing')
            if debug_mode:
                print(time.perf_counter() - timer)
                print(stt)
            pass


# This makes the program asking for the file name every single time you open the program
file_name = input("Please specify the text file you want to replay from:")
# Alternatively you can add the line below to replace the input command
# file_name = "history.txt¡§
openfile("pynput_record", file_name)
l, t = load_replay()

print("Ready, press 'alt + .' to start")
keyboard.wait("alt+.")
# while True:
play(l, 1, t, True)
예제 #10
0
import pyautogui as auto
import keyboard

# im1 = auto.screenshot(region=(0,0, 300, 400))
# im1.save(r"hh.jpg")
#readme:
#此程序用于截取按键图片,使用步骤:
#输入文件路径和名字
#鼠标移动到目标区域左上角
#按空格
#鼠标移动到目标区域右下角
#按空格,完成截图
name = input("input name:")
loc = r"..\\imgs\\" + name + ".jpg"
loc = loc.replace(' ', '')
print("loc=" + loc)
keyboard.wait(' ')
pos1 = auto.position()
print("get 1/2")
print(pos1)
keyboard.wait(' ')
pos2 = auto.position()
print("get 2/2")
print(pos2)
auto.screenshot(region=(pos1.x, pos1.y, pos2.x - pos1.x,
                        pos2.y - pos1.y)).save(loc)
예제 #11
0
"""
Prints the scan code of all currently pressed keys.
Updates on every keyboard event.
"""
import sys
sys.path.append('..')
import keyboard

def print_pressed_keys(e):
	line = ', '.join(str(code) for code in keyboard._pressed_events)
	# '\r' and end='' overwrites the previous line.
	# ' '*40 prints 40 spaces at the end to ensure the previous line is cleared.
	print('\r' + line + ' '*40, end='')
	
keyboard.hook(print_pressed_keys)
keyboard.wait()
예제 #12
0
 def process():
     keyboard.wait('a', suppress=True)
     self.fail()
예제 #13
0
 def process():
     queue.put(keyboard.wait(queue.get(timeout=0.5), suppress=True) or True)
예제 #14
0
 def process():
     keyboard.wait()
     self.triggered = True
예제 #15
0
 def t():
     keyboard.wait("a")
     lock.release()
예제 #16
0
APP_ID = '17134093'
API_KEY = 'gDGaUOGMRX5cxqFOxgp5SGbm'
SECRET_KEY = '2YOAu5p6MEpq9iWKR3yKRERfxkduWFWN'

client = AipOcr(APP_ID, API_KEY, SECRET_KEY)
""" 读取图片 """


def get_file_content(filePath):
    with open(filePath, 'rb') as fp:
        return fp.read()


while 1:
    # 监听键盘按键
    keyboard.wait(hotkey='f1')
    keyboard.wait(hotkey='ctrl+c')

    time.sleep(0.1)

    # 保存件剪贴板的图片保存到本地
    image = ImageGrab.grabclipboard()
    image.save('./images/shoot.jpg')

    image = get_file_content('./images/shoot.jpg')
    """ 调用通用文字识别(高精度版) """
    text = client.basicAccurate(image)
    # print(text)
    result = text['words_result']

    for info in result:
예제 #17
0
nextQuiz = True
while nextQuiz:
    quizNum = str(
        input(
            "Enter the quiz number you want to attempt from the list below:\n1\n2\n3\n4\n5 "
        ))
    quizName = "Quiz" + quizNum
    print("Roll:", username)
    conn = sq3.connect("project1_quiz_cs384.db")
    dbentry = conn.execute(
        "SELECT Name FROM project1_registration WHERE Username=?",
        (username, ))
    fullname = (dbentry.fetchone())[0]
    conn.close()
    print("Name:", fullname)
    print("Press Ctrl+Alt+U to see the unattempted questions")
    print("Press Ctrl+Alt+G to go to your desired question")
    print("Press Ctrl+Alt+F to submit the quiz finally")
    print("Press Ctrl+Alt+E to export the database to csv")
    submitted = 0
    conductQuiz(quizName, username)
    nextQuiz = str(
        input(
            "Do you want to attempt more quiz?\nPress y if Yes or n if No: "))
    if nextQuiz == 'y':
        nextQuiz = True
    else:
        nextQuiz = False
print("\nPress esc to exit")
keyboard.wait('esc')
keyboard.unhook_all()
예제 #18
0
        # set all positions to initial value
        for m_id in range(9):
            gripper[m_id].move_to_pos(pos_offset[m_id])


# def exit_routine():
# 	print("exit routine")
# 	gripper[0].ser.close()
# 	sys.exit(0)
# quit()

# hotkey definition
# keyboard.hook(handle_offset)
keyboard.hook(handle_motor_pos)
keyboard.add_hotkey('[', to_calibration)
keyboard.add_hotkey(']', to_teleoperation)
keyboard.add_hotkey('enter', to_next_motor)
# keyboard.add_hotkey('z', exit_routine)

# Initialize all motors
for ii in range(9):
    # the serail port shouldn't matter here
    new_motor = SBMotor('/dev/tty.usbmodem51011901', ii, motor_cpr, com_baud)
    gripper.append(new_motor)

# Set dynamixel current
for ii_d in range(3):
    gripper[ii_d].set_current(dynamixel_current)

keyboard.wait('.')
예제 #19
0
파일: OCR.py 프로젝트: liang-lpl/python
import keyboard
from PIL import ImageGrab
import time
from aip import AipOcr

app_id = ''
api_key = ''
secret_key = ''

client = AipOcr(app_id, api_key, secret_key)

while True:

    keyboard.wait(hotkey='alt+a')
    keyboard.wait(hotkey='ctrl+s')
    time.sleep(0.1)

    image = ImageGrab.grabclipboard()
    image.save('image_001.jpg')

    with open('image_001.jpg', 'rb') as file:
        image = file.read()
        result = client.basicAccurate(image)
        result = result['words_result']
        for i in result:
            print(i['words'])
            with open('word.txt', 'a+', encoding='UTF-8') as text:
                text.writelines('%s\n' % i['words'])

    hotkey = keyboard.read_hotkey()
    if hotkey == 'q':
예제 #20
0
def wait(hotkey=None, suppress=False, trigger_on_release=False):
	kb.wait(hotkey, suppress, trigger_on_release)
예제 #21
0
import win32api, win32con

def click(x,y):
    win32api.SetCursorPos((x,y))
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,0,0)
    time.sleep(0.01) #This pauses the script for 0.01 seconds
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,0,0)

Points=[]
print("-------*******------")
print("Auto game piano click")
input("Continue [Enter]")
print("chọn vị trí click")
for i in range(4):
    print("chọn vị trí(%d): "%(i+1),end='')
    keyboard.wait('enter')
    Points  += [pyautogui.position()]
    print(Points[i])
print("Are you ready!")
keyboard.wait('enter')
print("START...")
running = True
while keyboard.is_pressed('esc') == False:    
    if running :
        for i in range(4):
            X,Y=Points[i]
            #RGB(24,20,70)
            if pyautogui.pixel(X,Y)[2] < 80:
                click(X,Y)
                #print("click ",i)
        
예제 #22
0
def online_main(screen_index, test, cfg_file=None, model_date=None):
    if cfg_file is not None:
        merge_cfg_from_file(cfg_file)
    # q_result: controller -> screen (sending judgement result and start/quit signal)
    # q_stim: screen -> controller (sending event order)
    q_result = Queue()
    q_stim = Queue()
    # create stimulator object
    stim_string = cfg.exp_config.train_string if not test else cfg.exp_config.test_string
    kwargs = {
        'q_stim': q_stim,
        'q_result': q_result,
        'screen_index': screen_index,
        'stim_string': stim_string,
        'amp': cfg.amp_info.amp,
        'trigger_type': cfg.amp_info.trigger_type,
        'stim_dir': cfg.exp_config.stim_dir
        if not cfg.exp_config.bidir else None  # None for bidir
    }

    print('Configuration finished. Start process.')
    # start process
    process = Process(target=Stimulator.run_exp, kwargs=kwargs)
    process.start()

    # main process
    if test:
        # testing mode
        # create data_client object
        n_channel = len(cfg.subj_info.montage)
        if cfg.amp_info.amp == 'neuracle':
            from Online import Neuracle

            data_client = Neuracle.Neuracle(
                n_channel=n_channel + 1,  # +1 for trigger channel
                samplerate=cfg.amp_info.samplerate)

        else:
            raise ValueError("Unexpected amplifier type")

        controller = Controller.TestingController(q_stim=q_stim,
                                                  q_result=q_result,
                                                  dataclient=data_client,
                                                  model_date=model_date,
                                                  stim_string=stim_string)
    else:
        # training mode
        controller = Controller.TrainingController(q_stim=q_stim,
                                                   q_result=q_result,
                                                   stim_string=stim_string)
    # write exp config info to log file
    controller.write_exp_log()
    # waiting start signal
    keyboard.wait('s')
    # put starting signal into q_result
    q_result.put(-2)
    # set quit hotkey
    keyboard.add_hotkey('q', quit_process)
    while controller.char_cnt < len(
            controller.stim_string) and not Controller.quit_flag:
        controller.run()
        time.sleep(0.05)
    # close events file io
    controller.close()
    if test:
        # writing down itr
        print('accu: %.2f, average time: %.2f, itr: %.2f' % controller.itr())
        # turn off data client thread
        data_client.close()
    # terminate process
    if Controller.quit_flag:
        process.terminate()
    process.join()
"""
    나도코딩
    활용편2
    https://youtu.be/bKPIcoou9N8
"""

import time
import keyboard
from PIL import ImageGrab


def screenshot():
    curr_time = time.strftime(
        "_%Y%m%d_%H%M%S")  # 2020년 6월 1일 10시 20분 30초 --> _20200601_102030
    img = ImageGrab.grab()
    img.save("image{}.png".format(curr_time))


keyboard.add_hotkey("tbF9", screenshot)

keyboard.wait("esc")
 def start(self):
     # Configure on release handler:
     keyboard.on_release(callback=self.on_key_up)
     self.report_keystrokes()
     # It will go until Ctrl+C is hit.
     keyboard.wait()
예제 #25
0
 def start_keyboard_logging(self):
     keyboard.hook(self.print_pressed_keys)
     self.hooked = False
     self.install_hotkeys()
     keyboard.wait()
예제 #26
0
 def listen(self):
     art.tprint('GoogleZri')
     print('Press ' + self.hotkey + ' to Google any selected text.')
     keyboard.wait()
예제 #27
0
# -*- coding:utf-8 -*-
import pyperclip as ppc
import keyboard
import re
import time

def getRidOf_n():
    s = ppc.paste()
    print('处理前:')
    print(s)
    print('')
    s = s.replace('w.r.t','with respect to')
    s = re.sub(r'-\n','',s)
    s = re.sub(r'[\r\b]','',s)
    s = re.sub(r'[\n\t]',' ',s)
    # s = re.sub(r'[^A-Za-z0-9- .,!?(%)\[\]:;\'\"αβγ]','',s)
    s = re.sub(r'[ ]+',' ',s)
    ppc.copy(s)
    print('处理后:')
    print(ppc.paste())
    print('(内容已复制到剪贴板)')
    
keyboard.add_hotkey('ctrl+space',getRidOf_n)

keyboard.wait('ctrl+8')
예제 #28
0
import win32con
import readFromJson
import feedback


def getText():
    w.OpenClipboard()
    d = w.GetClipboardData(win32con.CF_TEXT)
    w.CloseClipboard()
    return (d).decode('GBK')


def copyGfCSA():
    while keyboard.is_pressed("alt") or keyboard.is_pressed("l"):
        time.sleep(0.1)
    win32api.keybd_event(17, 0, 0, 0)  #ctrl
    win32api.keybd_event(67, 0, 0, 0)  #c
    win32api.keybd_event(67, 0, win32con.KEYEVENTF_KEYUP, 0)  #释放按键
    win32api.keybd_event(17, 0, win32con.KEYEVENTF_KEYUP, 0)
    time.sleep(0.1)
    processedText = getText().strip()
    readFromJson.saveSentence(processedText,
                              transEntoCh.translate(processedText))
    feedback.toastWinInfo("mtgs.ico", 10,
                          True)  # TODO: custom your feedback here


if __name__ == "__main__":
    keyboard.add_hotkey('ctrl+alt+l', copyGfCSA, [], False)
    keyboard.wait('tab+esc')
예제 #29
0
import keyboard
import time
from PIL import ImageGrab


def screenshot():
    # xxxx년 x월 x일 x시 x초.. -> _20210527_102030
    curr_time = time.strftime("_%Y%m%d_%H%M%S")
    img = ImageGrab.grab()
    img.save("Image{}.png".format(curr_time))


keyboard.add_hotkey("F9", screenshot)  # 사용자가 F9키를 누르면 스크린샷 저장


keyboard.wait("esc")  # 사용자가 ESC를 누를 때 까지 프로그램 수행
예제 #30
0
login_form.send_keys('1')
login_form.send_keys(Keys.ENTER)
try:
    login_form = driver.find_element_by_xpath("//*[@id='BirthYear']")
    login_form.send_keys('1980')
except:
    driver.find_element_by_xpath("//*[@id='BirthYear']/option[20]").click()
driver.find_element_by_xpath("//*[@id='BirthMonth']/option[2]").click()
driver.find_element_by_xpath("//*[@id='BirthDay']/option[20]").click()
driver.find_element_by_xpath("//*[@id='iSignupAction']").click()
headers = {'user-agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36'}
def send_verification_code():
    c = {'email':email_name}
    requests.post('https://xxjc.vip/auth/send',data=c,headers=headers,verify = False)
print('OK!')
keyboard.wait(']')
send_verification_code()
z = input('emailcode:')
def login():
    d = {'email':email_name,'name':email_name,'passwd':email_name,'repasswd':email_name,'wechat':email_name,'imtype':'1','code':'0','emailcode':z}
    requests.post('https://xxjc.vip/auth/register',headers=headers,data=d,verify = False)
    s = {'email':email_name,'passwd':email_name,'code':''}
    f = requests.post('https://xxjc.vip/auth/login',headers=headers,data=s,verify = False)
    i = requests.get('https://xxjc.vip/user',headers=headers,cookies=f.cookies,verify = False)
    html = i.text
    url = re.findall('<input type="text" class="input form-control form-control-monospace cust-link col-xx-12 col-sm-8 col-lg-7" name="input1" readonly value="(.*?)" readonly="true">',html)
    ssrjson = url[0]
    a = '{\"configs\" : [ 			{ 				\"remarks\" : \"\", 				\"id\" : \"7DD53D24B7DA27E51453A9FD81EEF215\", 				\"server\" : \"server host\", 				\"server_port\" : 8388, 				\"server_udp_port\" : 0, 				\"password\" : \"0\", 				\"method\" : \"aes-256-cfb\", 				\"protocol\" : \"origin\", 				\"protocolparam\" : \"\", 				\"obfs\" : \"plain\", 				\"obfsparam\" : \"\", 				\"remarks_base64\" : \"\", 				\"group\" : \"FreeSSR-public\", 				\"enable\" : true, 				\"udp_over_tcp\" : false 			} 		], 		\"index\" : 0, 		\"random\" : true, 		\"sysProxyMode\" : 3, 		\"shareOverLan\" : true, 		\"localPort\" : 1080, 		\"localAuthPassword\" : \"o3-VjtCQCBLlVletTSc2\", 		\"dnsServer\" : \"\", 		\"reconnectTimes\" : 2, 		\"balanceAlgorithm\" : \"LowException\", 		\"randomInGroup\" : false, 		\"TTL\" : 0, 		\"connectTimeout\" : 5, 		\"proxyRuleMode\" : 2, 		\"proxyEnable\" : false, 		\"pacDirectGoProxy\" : false, 		\"proxyType\" : 0, 		\"proxyHost\" : \"\", 		\"proxyPort\" : 0, 		\"proxyAuthUser\" : \"\", 		\"proxyAuthPass\" : \"\", 		\"proxyUserAgent\" : \"\", 		\"authUser\" : \"\", 		\"authPass\" : \"\", 		\"autoBan\" : false, 		\"sameHostForSameTarget\" : false, 		\"keepVisitTime\" : 180, 		\"isHideTips\" : false, 		\"nodeFeedAutoUpdate\" : true, 		\"serverSubscribes\" : [ 			{ 				\"URL\" : \"'+ssrjson+'\", 				\"Group\" : \"\", 				\"LastUpdateTime\" : 0 			} 		], 		\"token\" : {  		}, 		\"portMap\" : {  		} 	}'
    with open('gui-config.json', 'w') as f:
        f.write(a)
def seed():
예제 #31
0
    def start_bot(self):
        print("Press Ctrl-C to quit.")
        print("Hold P to pause.")
        print("Hold I to get info.")
        try:
            while True:
                while True:
                    cooldown_mark = time.time()

                    farm_period = FARM_PERIOD_VALUE - (cooldown_mark -
                                                       self.farm_period_mark)
                    hire_last_hero_cooldown = HIRE_LAST_HERO_COOLDOWN_VALUE - (
                        cooldown_mark - self.hire_last_hero_cooldown_mark)
                    rgb = get_color(self.positions["farm_mode"][0],
                                    self.positions["farm_mode"][1])
                    r = rgb[0]
                    if not self.farm_mode and r == 255:
                        if hire_last_hero_cooldown <= 0:
                            print(
                                "Progress stopped. Hiring last hero and assigning auto-clickers"
                            )
                            reset_auto_clickers()
                            time.sleep(1)
                            set_auto_clickers_to_damage()
                            time.sleep(1)
                            set_auto_clicker_hire_hero(
                                self.positions["hero_last_hireable"])
                            self.hire_last_hero_cooldown_mark = time.time()
                            time.sleep(1)
                        else:
                            print(
                                f"Farm mode enabled, waiting {FARM_PERIOD_VALUE} to disable."
                            )
                            self.farm_mode = True
                            if (cooldown_mark - self.farm_period_mark
                                ) <= BOSS_FIGHT_FAIL_INTERVAL:
                                self.boss_fight_fails += 1
                                if self.boss_fight_fails >= BOSS_FIGHT_FAILS_LIMIT:
                                    print(
                                        "Progress is not possible. Preparing to ascend"
                                    )
                                    self.ascend()
                                print(
                                    "Progress stopped. Interval of {:.2f}s. Count: {}. {} consecutive fails remaining to ascend"
                                    .format(
                                        cooldown_mark - self.farm_period_mark,
                                        self.boss_fight_fails,
                                        BOSS_FIGHT_FAILS_LIMIT -
                                        self.boss_fight_fails,
                                    ))
                                print("Upgrading all heroes")
                                upgrade_all()
                            else:
                                self.boss_fight_fails = 0
                            self.farm_period_mark = time.time()
                    elif self.farm_mode and farm_period <= 0:
                        print("Farm mode disabled")
                        pyautogui.click(
                            x=self.positions["farm_mode"][0],
                            y=self.positions["farm_mode"][1],
                        )
                        self.farm_mode = False

                    try:  # used try so that if user pressed other than the given key error will not be shown
                        if keyboard.is_pressed("p"):  # if key 'p' is pressed
                            print("Bot stopped, press R to resume")
                            break  # finishing the loop
                        elif keyboard.is_pressed("i"):
                            self.output_cooldowns()
                        else:
                            pass
                    except:
                        pass  # if user pressed other than the given key the loop will break

                    self.pickup_gold()

                    self.clickstorm_cooldown = POWERS[1]["cooldown_value"] - (
                        cooldown_mark - POWERS[1]["cooldown_mark"])
                    self.powersurge_cooldown = POWERS[2]["cooldown_value"] - (
                        cooldown_mark - POWERS[2]["cooldown_mark"])
                    self.lucky_strikes_cooldown = POWERS[3][
                        "cooldown_value"] - (cooldown_mark -
                                             POWERS[3]["cooldown_mark"])
                    self.metal_detector_cooldown = POWERS[4][
                        "cooldown_value"] - (cooldown_mark -
                                             POWERS[4]["cooldown_mark"])
                    self.golden_clicks_cooldown = POWERS[5][
                        "cooldown_value"] - (cooldown_mark -
                                             POWERS[5]["cooldown_mark"])
                    self.super_clicks_cooldown = POWERS[6][
                        "cooldown_value"] - (cooldown_mark -
                                             POWERS[6]["cooldown_mark"])
                    self.dark_ritual_cooldown = POWERS[7]["cooldown_value"] - (
                        cooldown_mark - POWERS[7]["cooldown_mark"])
                    self.energize_cooldown = POWERS[8]["cooldown_value"] - (
                        cooldown_mark - POWERS[8]["cooldown_mark"])
                    self.reload_cooldown = POWERS[9]["cooldown_value"] - (
                        cooldown_mark - POWERS[9]["cooldown_mark"])

                    self.check_and_use_power(
                        1,
                        self.clickstorm_cooldown,
                        self.energize_cooldown,
                        self.reload_cooldown,
                    )
                    self.check_and_use_power(
                        2,
                        self.powersurge_cooldown,
                        self.energize_cooldown,
                        self.reload_cooldown,
                    )
                    self.check_and_use_power(
                        3,
                        self.lucky_strikes_cooldown,
                        self.energize_cooldown,
                        self.reload_cooldown,
                    )
                    self.check_and_use_power(
                        4,
                        self.metal_detector_cooldown,
                        self.energize_cooldown,
                        self.reload_cooldown,
                    )
                    self.check_and_use_power(
                        5,
                        self.golden_clicks_cooldown,
                        self.energize_cooldown,
                        self.reload_cooldown,
                    )
                    self.check_and_use_power(
                        6,
                        self.super_clicks_cooldown,
                        self.energize_cooldown,
                        self.reload_cooldown,
                    )

                    if self.dark_ritual_cooldown <= 0 and self.reload_cooldown <= 0:
                        time.sleep(
                            5
                        )  # Garante que o poder esteja carregado por conta do lag no jogo
                        pyautogui.click(
                            x=self.positions["powers"][0],
                            y=self.positions["powers"][POWERS[7]["position"]],
                        )
                        POWERS[7]["cooldown_mark"] = time.time()
                        POWERS[7]["cooldown_value"] = (
                            POWERS[7]["cooldown_initial"] - 3600
                        )  # Reload effect
                        pyautogui.click(
                            x=self.positions["powers"][0],
                            y=self.positions["powers"][POWERS[9]["position"]],
                        )  # Reload
                        POWERS[9]["cooldown_mark"] = time.time()
                keyboard.wait("r")
                print("Bot resumed")
        except KeyboardInterrupt:
            print("\n")
            print("Exiting...")
예제 #32
0
def init_server(sock, target_ip):
    keyboard.on_press(lambda event: sock.sendto(
        str.encode(event.name), (target_ip, PORT))
    )
    keyboard.wait()
예제 #33
0
MODEL = 'M800'
COLOR = 'ffffff'
DELAY = 0.1

from steelkeys.keyboard import Keyboard

kb = Keyboard(MODEL)

try:
    kb.open()
except:
    print('Can not access keyboard')
    sys.exit(1)

kb.disable()

print('Press space to start')

keyboard.wait('space')

for key in kb.listKeys():
    print(key)

    kb.pushConfig({key: {'color': COLOR}})

    sleep(DELAY)

    print('Press space to continue')

    keyboard.wait('space')
예제 #34
0
import keyboard
#samplerate needs to be 44100 for google to accept it
samplerate = 44100  # Hertz
duration = 5  # seconds
filename = 'output.wav'
#need to be mono channel (1)

while True:

    print(
        "You can now minimize the terminal script window and use F11 to make the program start listening or \nPress CTRL+C to exit the program \nHint: To say 'google-chrome-stable' say google dash chrome dash stable \nThis currently does not support commands with multiple words unless they're separated by a dash, slash or dot"
    )

    print("Press F11 to start listening")
    keyboard.add_hotkey('F11', print, args=['F11 was pressed!'])
    keyboard.wait('F11')

    recording = sd.rec(int(samplerate * duration),
                       samplerate,
                       channels=1,
                       blocking=True)
    sf.write(filename, recording, samplerate)

    #initializes new client
    client = speech.SpeechClient()

    #gets the filepath of the filename
    file_name = os.path.dirname(filename)

    # Loads the audio into memory
    with io.open(filename, 'rb') as audio_file:
# Using Keyboard module in Python
import keyboard

# It writes the content to output
keyboard.write("GEEKS FOR GEEKS\n")

# It writes the keys r, k and endofline
keyboard.press_and_release('shift + r, shift + k, \n')
keyboard.press_and_release('R, K')

# it blocks until ctrl is pressed
keyboard.wait('Ctrl')
예제 #36
0
coin = MAME_5


#testa se a direcao atual é exatamente o inverso da direcao anterior
def dilema(direcao, direcaoAnterior):
    if ((direcao == up and direcaoAnterior == down)
            or (direcao == down and direcaoAnterior == up)
            or (direcao == left and direcaoAnterior == right)
            or (direcao == right and direcaoAnterior == left)):
        return True
    else:
        return False


print("PRESSIONE 'i' PARA INICIAR O ALGORITMO!")
keyboard.wait('i')

# imagens
img_verde = cv2.imread('imgs2/stank_verde.jpg', 0)
img_vermelho = cv2.imread('imgs2/stank_vermelho.jpg', 0)

#imagens dependentes de cor
img_amarelo_up = cv2.imread('imgs2/stank_amarelo_up.jpg', 1)
img_amarelo_left = cv2.imread('imgs2/stank_amarelo_left.jpg', 1)
img_amarelo_down = cv2.imread('imgs2/stank_amarelo_down.jpg', 1)
img_amarelo_right = cv2.imread('imgs2/stank_amarelo_right.jpg', 1)

cont = 0
direcaoAnterior = 0
posicaoAnteriorTanque = 0
alvoAtual = 0
예제 #37
0
파일: myKeyLogger.py 프로젝트: njyaron/SMOP
        print("starting to record in " + DIRECTORY_PATH)
        start_record(add_event)
        saver = SaverThread(recorded)
        saver.daemon = True
        saver.start()
        #wait for special recording instruction
        while True: 
            code_name = input(SPECIAL_MSG)
            if code_name in SPECIAL_CODES:
                # get text index (the index of the text, since there are 
                # many of same cartegory (UNIFORM, INDIVIDUAL)
                text_index = input("Enter the text index: ")
                print(STARTED_RECORDING_SPECIAL)
                #record special until two escape presses are pressed
                start_record(add_event_special)
                keyboard.wait('esc, esc')
                end_record(add_event_special)
                #store the needed data in a file and clear recorded_special
                data = (code_name, text_index, recorded_special)
                filename = get_next_filename(prefix=code_name)
                pickle.dump(data, open(filename, 'wb+'))
                recorded_special.clear()
            elif code_name == "EXIT":
                break
            else:
                print(UNAUTORIZED_CODE_MSG)
    except KeyboardInterrupt:
        print("Finishing to record")
    finally:
		#save data and finish
        saver.save_data()
예제 #38
0
#quick and dirty push-to-talk example for Ubuntu 16.04, by Abd Azrad 

import keyboard
import subprocess

is_muted = False

def unmute():
	global is_muted
	if not is_muted: # if mic is already enabled
		return # do nothing
	is_muted = False
	subprocess.call('amixer set Capture cap', shell=True) # unmute mic

def mute():
	global is_muted
	is_muted = True
	subprocess.call('amixer set Capture nocap', shell=True) # mute mic

if __name__ == "__main__":
	is_muted = True
	mute() # mute on startup

	keyboard.add_hotkey('win', unmute) # unmute on keydown
	keyboard.add_hotkey('win', mute, trigger_on_release=True) # mute on keyup

	keyboard.wait() # wait forever