def Cliq(x, y):
    #ctypes.windll.user32.SetCursorPos(x, y)
    win32api.SetCursorPos((x, y))
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, x, y, 0, 0)
    time.sleep(0.02)
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, x, y, 0, 0)
Esempio n. 2
0
def mousePos(x, y):
    win32api.SetCursorPos((x, y))
Esempio n. 3
0
def click(x,y):
    win32api.SetCursorPos((x,y))
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,x,y,0,0)
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,x,y,0,0)
                arr_F_Z[2] = arr_F_Z[1]
                arr_F_Y[1] = arr_F_Y[0]
                arr_F_Z[1] = arr_F_Z[0]
                arr_F_Z[0] = F_Z
                arr_F_Y[0] = F_Y

                arr_y[2] = arr_y[1]
                arr_x[2] = arr_x[1]
                arr_y[1] = arr_y[0]
                arr_x[1] = arr_x[0]
                arr_x[0] = x
                arr_y[0] = y

                avg_x = np.mean(arr_x)  #增加稳定性
                avg_y = np.mean(arr_y)
                win32api.SetCursorPos((int(avg_x), int(avg_y)))  #快的很

                # print("YY: ",arr_F_Y[2] - arr_F_Y[0])
                # print("ZZ: ",arr_F_Z[2] - arr_F_Z[0])
                if abs(arr_F_Y[2] - arr_F_Y[0]) > 160 and abs(arr_F_Z[2] -
                                                              arr_F_Z[0]) > 25:
                    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 200,
                                         200, 0, 0)
                    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 200, 200,
                                         0, 0)
                    #time.sleep(0.5)
                #mouse.moveTo(int(avg_x), int(avg_y),duration=0)#慢
                #print(mouse.position())

                #判断手势
Esempio n. 5
0
    posList.append(win32api.GetCursorPos()) #[p1,p4]
    p2 = (posList[1][0],posList[0][1])
    p3 = (posList[0][0],posList[1][1])
    posList.insert(1, p2)
    posList.insert(2, p3)
    p1 = posList[0]
    p4 = posList[3]
    #[p1,p2,p3,p4]

    x = round((p2[0]-p1[0])/OFFSET_G)
    y = round((p3[1]-p1[1])/OFFSET_S)

    for i in range(OFFSET_S+1):
        for j in range(OFFSET_G+1):
            pN = (p1[0]+x*j,p1[1]+y*i)
            new_posList.append(pN)
    input(">>> 시작하려면 엔터키를 누르세요 ~ :: ")
    print(">>> 클릭 시작")


    now = time.time()
    while True:
        for pos in new_posList:
            win32api.SetCursorPos(pos)
            for _ in range(CUR_REPEAT):
                win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
                win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
            time.sleep(MOUSE_DELAY)
            if time.time() - now > EXITTIME:
                exit(1)
        time.sleep(AREA_DELAY)
Esempio n. 6
0
#%%
import win32api, win32con
def click(x,y):
    win32api.SetCursorPos((x,y))
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,x,y,0,0)
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,x,y,0,0)



import time
import math



for j in range(10000):
    if j <=10000:
        for i in range(500):
            x = int(500+math.sin(math.pi*i/100)*500)
            y = int(500+math.cos(i)*100)
            win32api.SetCursorPos((x,y))
            time.sleep(.01)
        click(x,y)  
# %%


Esempio n. 7
0
def scroll_down():
    win32api.SetCursorPos((370, 250))
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
    win32api.SetCursorPos((370, 700))
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
Esempio n. 8
0
def resetCursor():
    halfScreenWidth = int(round(win32api.GetSystemMetrics(0) / 2))
    halfScreenHight = int(round(win32api.GetSystemMetrics(1) / 2))
    win32api.SetCursorPos((halfScreenWidth, halfScreenHight))
Esempio n. 9
0
def todo(go):
    action = go[2]
    if (action != 'move'):
        win32api.SetCursorPos(c)
        ctypes.windll.user32.mouse_event(0x0008, int(go[0]), int(go[1]), 0, 0)
        ctypes.windll.user32.mouse_event(0x0010, int(go[0]), int(go[1]), 0,
                                         0)  #right mouse up
    else:
        return

    def searchUntilCursor(maxserches, callback):
        searches = 0
        deg = 2 * math.pi * random.random()
        while searches < maxserches:
            sleep(0.05)
            searches += 1
            r = searchrad + (10 - 20 * random.random())
            #random_movement((int(c[0]),int(c[1])))
            cur = (int(c[0] + math.cos(deg) * r),
                   int(c[1] + math.sin(deg) * r))
            random_movement(cur)
            sleep(0.05)
            #check if cursor diff 9 normal 24 is clickable
            if (mem.readMemFloat(base + 0x1093224, [0, 0x18]) == 24):
                callback(cur)
                searches = 99999
            deg += .4  #~70deg

    def gather(cur):
        click(cur)
        harvesting = True
        gathers = 0
        while harvesting:
            sleep(0.2)
            gathers += 1
            if (mem.readMemFloat(base + 0x109060C,
                                 [0, 0x6f4, 0xd8, 0x1f4, 0x5c8, 0x318]) == 0
                    or gathers > 100):
                harvesting = False
                break

    def repair(cur):
        click(cur)
        sleep(2)
        repairall = (x + 110, y + 410)
        move_click(repairall)
        sleep(2)
        pay = (x + 740, y + 471)
        move_click(pay)
        sleep(1)

    def bank(cur):
        click(cur)
        sleep(1)
        #inventory 80px tiles
        #topleft 1590,540
        key.PressKey(0x2A)  #lshift
        sleep(0.05)
        cols = 4
        rows = 5
        xi = x + 1060
        yi = y + 425
        for i in range(rows):
            for j in range(cols):
                cur = (xi + j * 55, yi + i * 55)
                if (not (i == 0 and j < 2)):
                    move_click(cur)
                    sleep(0.2)
        key.ReleaseKey(0x2A)
        key.KeyStroke('escape')

    if (action == 'gather'):
        searchUntilCursor(12, gather)
    elif (action == 'repair'):
        searchUntilCursor(22, repair)
    elif (action == 'bank'):
        searchUntilCursor(80, bank)

    ctypes.windll.user32.mouse_event(0x0002, int(go[0]), int(go[1] + 200), 0,
                                     0)  #right mouse up
    ctypes.windll.user32.mouse_event(0x0004, int(go[0]), int(go[1] + 200), 0,
                                     0)  #right mouse dn

    ctypes.windll.user32.mouse_event(0x0008, int(go[0]), int(go[1] + 200), 0,
                                     0)  #right mouse dn
Esempio n. 10
0
def click(x, y, multi=1):
    for n in range(multi):
        win32api.SetCursorPos((x, y))
        win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, x, y, 0, 0)
        win32api.SetCursorPos((x, y))
        win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, x, y, 0, 0)
Esempio n. 11
0
def simClick():
    x, y = win32api.GetCursorPos()
    win32api.SetCursorPos((x, y))
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, x, y, 0, 0)
Esempio n. 12
0
 def dragEnd(self, x, y):
     win32api.SetCursorPos((x, y))
     win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, x, y, 0, 0)
Esempio n. 13
0
 def moveTo(self, x, y):
     win32api.SetCursorPos((x, y))
def RightCliq(x, y):
    win32api.SetCursorPos((x, y))
    win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTDOWN, x, y, 0, 0)
    time.sleep(0.015)
    win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTUP, x, y, 0, 0)
Esempio n. 15
0
def move_to(pos):
    win32api.SetCursorPos(pos)
Esempio n. 16
0
    _, frame = camera.read()

    hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)

    mask = cv2.inRange(hsv, colourBounds[0], colourBounds[1])
    mask = cv2.morphologyEx(mask, cv2.MORPH_OPEN, kernel)

    contours,hierarchy = cv2.findContours(mask, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)

    if len(contours) > 0:
        rects = map(lambda c : cv2.minAreaRect(c), contours)
        maxRect = max(rects, key=lambda r : r[1][0] * r[1][1])
        box = cv2.cv.BoxPoints(maxRect)
        box = np.int0(box)
        cv2.drawContours(frame,[box],0,(0,0,255),2)

        boxPos = (int(maxRect[0][0]), int(maxRect[0][1]))
        cv2.circle(frame, boxPos, 5, (255, 0, 0), 10)

        if prevBoxPos != None:
            delta = ((boxPos[0] - prevBoxPos[0]) * mouseAcc, (boxPos[1] - prevBoxPos[1]) * mouseAcc)
            win32api.SetCursorPos(tuple(map(operator.add, cursorPos, delta)))
        prevBoxPos = boxPos

    cv2.imshow("camera", frame)

    k = cv2.waitKey(5) & 0xFF
    if k == 27:
        break

cv2.destroyAllWindows()
Esempio n. 17
0
def moveMouse(x=(0, 0)):
    win32api.SetCursorPos(x)
Esempio n. 18
0
    win32api.keybd_event(9, 0, 0, 0)  # c
    win32api.keybd_event(9, 0, win32con.KEYEVENTF_KEYUP, 0)  # 释放按键
    win32api.keybd_event(18, 0, win32con.KEYEVENTF_KEYUP, 0)  # 释放按键
    time.sleep(0.3)


def zhantie():
    ###粘贴
    win32api.keybd_event(17, 0, 0, 0)  # ctrl
    win32api.keybd_event(86, 0, 0, 0)  # ctrl
    win32api.keybd_event(86, 0, win32con.KEYEVENTF_KEYUP, 0)  # 释放按键
    win32api.keybd_event(17, 0, win32con.KEYEVENTF_KEYUP, 0)  # 释放按键
    time.sleep(0.3)
    win32api.keybd_event(13, 0, 0, 0)  # enter
    win32api.keybd_event(13, 0, win32con.KEYEVENTF_KEYUP, 0)  # 释放按键
    time.sleep(0.3)


###全选
while n <= yeshu:
    quanxuanfuzhi()
    qiehuanchuangkou()
    zhantie()
    win32api.SetCursorPos([1550, 720])
    time.sleep(0.3)
    win32api.mouse_event(
        win32con.MOUSEEVENTF_LEFTUP | win32con.MOUSEEVENTF_LEFTDOWN, 0, 0, 0,
        0)
    time.sleep(3)
    n += 1
Esempio n. 19
0
    c_y_pos = 215
    win32gui.EnumWindows(get_id, 0)
    main_id_need2 = main_id_need

    #Multiple nesting, bad code!!!
    for hwnd in main_id_need2:
        try:
            win32gui.SetWindowPos(hwnd, win32con.HWND_TOPMOST, w_x_pos, 0, 380,
                                  760, win32con.SWP_SHOWWINDOW)
        except Exception as e:
            import sys
            print('Exception! make sure your QQ or YY is loading')
            sys.exit()

        soft_window_size = win32gui.GetWindowRect(hwnd)
        print(soft_window_size)
        for _ in range(2):
            for _ in range(3):
                win32api.SetCursorPos((145, c_y_pos))
                double_click()
                c_y_pos += 60
            window_id_need = []
            time.sleep(1)
            win32gui.EnumWindows(get_id, 0)
            print(window_id_need)
            for w_hwnd in window_id_need:
                send_message(w_hwnd)
            scroll_down()
        w_x_pos += 290
        print('done')
        break
Esempio n. 20
0
import win32api
import win32con
import win32gui
import os
from time import sleep

command = 'taskkill /F /IM chrome.exe'
# 比如这里关闭QQ进程
# os.popen(command)
print(os.popen(command).read())
'''
classname = "Chrome_WidgetWin_1"
titlename = "新标签页 - Google Chrome"
#获取句柄
hwnd = win32gui.FindWindow(classname, titlename)
#获取窗口左上角和右下角坐标
left, top, right, bottom = win32gui.GetWindowRect(hwnd)

def get_child_windows(parent):

#获得parent的所有子窗口句柄
#返回子窗口句柄列表

    if not parent:
        return
    hwndChildList = []
    win32gui.EnumChildWindows(parent, lambda hwnd, param: param.append(hwnd),  hwndChildList)
    return hwndChildList

#获取某个句柄的类名和标题
title = win32gui.GetWindowText(hwnd)
Esempio n. 21
0
def right(x, y):
    win32api.SetCursorPos((x, y))
    win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTDOWN, x, y, 0, 0)
    win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTUP, x, y, 0, 0)
Esempio n. 22
0
def mousePos(cord):
    win32api.SetCursorPos((x_pad + cord[0], y_pad + cord[1]))
Esempio n. 23
0
 def click(self, pos):
     win32api.SetCursorPos(pos)
     win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,0,0)
     win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,0,0)
Esempio n. 24
0
import time

# 获取句柄
hwnd = win32gui.FindWindow(None, u"腾讯课堂")
count = 0
while (1):
    # 显示隐藏窗口
    win32gui.ShowWindow(hwnd, win32con.SW_RESTORE)
    time.sleep(0.5)
    # 移动窗口并重绘
    win32gui.MoveWindow(hwnd, 262, 112, 1248, 780, True)
    # 焦点关注
    win32gui.SetForegroundWindow(hwnd)
    #获取当前鼠标焦点
    POS = win32gui.GetCursorPos()
    POS = list(POS)
    # 鼠标聚焦
    win32api.SetCursorPos((1103, 784))
    # 鼠标左键按下
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 1103, 784)
    # 鼠标左键拾起
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 1103, 784)
    # 计算点击次数
    count += 1
    print("执行次数----", count)
    # 隐藏窗口
    win32gui.ShowWindow(hwnd, win32con.SW_HIDE)
    # 还原鼠标位置
    win32api.SetCursorPos((POS[0], POS[1]))
    time.sleep(5)
Esempio n. 25
0
def mousePos(x_pad, y_pad, cord):
    print("Going to " + str(cord[0]) + "," + str(cord[1]))
    x = cord[0]
    y = cord[1]
    win32api.SetCursorPos((x, y))
Esempio n. 26
0
def LeftClick(x, y):
    win32api.SetCursorPos((x, y))
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, x, y, 0, 0)
    time.sleep(0.15)
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, x, y, 0, 0)
Esempio n. 27
0
import win32con
import win32api
import time

# 设置鼠标的位置
win32api.SetCursorPos([20, 40])
time.sleep(0.1)

# 相当于双击
# 鼠标左键按下
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0, 0)
# 鼠标左键抬起
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0)
# 鼠标左键按下
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0, 0)
# 鼠标左键抬起
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0)
Esempio n. 28
0
def mousePos(cord):
    win32api.SetCursorPos((cord[0], cord[1]))
Esempio n. 29
0
def left_click(x, y, window):
    point = y << 15 | x
    win32api.SetCursorPos((x, y))
    window.SendMessage(win32con.WM_LBUTTONDOWN, win32con.MK_LBUTTON, point)
    time.sleep(.05)
    window.SendMessage(win32con.WM_LBUTTONUP, 0, point)
Esempio n. 30
0
def click(x,y):
    win32api.SetCursorPos((x,y))
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,0,0)
    time.sleep (0.01)
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,0,0)