Пример #1
0
 def play_record(self):
     start_position = get_mouse_position()
     print(f"Executing moves: {self.moves}")
     while self.moves:
         mv = self.moves.pop(0)
         Sleep(SLEEP_BETWEEN_CLICKS)
         click_pixel(*mv)
     set_mouse_position(start_position)
     Sleep(SLEEP_BETWEEN_COMPUTER)
     self.__switch__(True)
Пример #2
0
    def runOdis(self):
        '''
                运行Odis Webservice
        '''
        # WebserviceCommand1='de.volkswagen.odis.vaudas.vehiclefunction.automation.webservice.enabled=True'
        # WebserviceCommand2='de.volkswagen.odis.vaudas.vehiclefunction.automation.webservice.port='+ WebservicePort

        print("... initializing ODISInf")
        sErrorMessage = ''
        self.sInstDir = self.__getInstDir()
        print("... checking ODIS process")
        if not self.__procExist():
            print("... ODIS websevice process not found, starting new")
            print("... checking registry for ODIS home")
            if self.sInstDir != None:
                sCommand = path.join(self.sInstDir, "OffboardDiagLauncher.exe")
                # sConfigfile = path.join(self.sInstDir, "\configuration\config.ini")
                # print("... ODIS path: %s", sCommand)
                # print("... Config path: %s", sConfigfile)
            else:
                sErrorMessage = 'no ODIS installation found'
                print('no ODIS installation found')
                return sErrorMessage

            sCommandAttribute = '-configuration configuration\\webservice.ini'
            print("... executing command: %s %s" %
                  (sCommand, sCommandAttribute))
            sCommandAttribute = '"' + sCommand + '"' + ' ' + sCommandAttribute
            hProcess, hThread, processId, threadId = CreateProcess(
                sCommand, sCommandAttribute, None, None, 0, 0, None, None,
                STARTUPINFO())
            Sleep(30000)
            print 'ODIS started...', hProcess, hThread, processId, threadId
            i = 0
            while True:
                try:
                    client = Client('http://localhost:' + WebservicePort +
                                    '/OdisAutomationService?wsdl')
                    client.set_options(timeout=3600)
                    self.aService = client.service
                    break
                except URLError:
                    if i < 20:
                        print(
                            'failed to establish the ODIS webservice connection, try again in 10s'
                        )
                        i += 1
                        Sleep(5000)
                    else:
                        sErrorMessage = 'failed to connect to ODIS webservice'
                        print(sErrorMessage)
                        return sErrorMessage
Пример #3
0
    def initTester(self, dConfig):
        log.debug("... initializing ODISInf")
        sErrorMessage = ''
        self.sInstDir = self.__getInstDir()
        log.debug("... checking ODIS process")      
        if not self.__procExist():
            log.debug("... ODIS websevice process not found, starting new")
            
            log.debug("... checking registry for ODIS home")
                            

            if self.sInstDir != None:
                sCommand = path.join(self.sInstDir, "OffboardDiagLauncher.exe")
            else:
                sErrorMessage = 'no ODIS installation found'
                return sErrorMessage

            sCommandAttribute = '-configuration configuration\\webservice.ini'
            log.debug("... executing command: %s %s", sCommand, sCommandAttribute)
            sCommandAttribute = '"' + sCommand + '"' + ' ' + sCommandAttribute
            hProcess, hThread, processId, threadId = CreateProcess(sCommand, sCommandAttribute, None, None, 0, 0, None, None, STARTUPINFO())
            Sleep(60000)
        
        i = 0
        while True:
            try:
                client = Client('http://localhost:8081/OdisAutomationService?wsdl')
                client.set_options(timeout=3600)
                self.aService = client.service
                
                break
            except URLError:
                if i < 20:
                    log.debug('failed to establish the ODIS webservice connection, try again in 10s')
                    i += 1
                    Sleep(5000)
                else:
                    sErrorMessage = 'failed to connect to ODIS webservice'
                    log.error(sErrorMessage)
                    return sErrorMessage
        
        log.debug('... set vehicle project to "%s"', dConfig['sVehicleProject'])
        try:
            self.aTraceState=client.factory.create('traceSTATE')           
            self.aService.setVehicleProject(dConfig['sVehicleProject'])
            sErrorMessage = self.switchECU(dConfig)
            if(sErrorMessage != ''):
                self.deInitTester()
            self.__backupOldProtocolAndTraceFiles()
        except WebFault, e:
            sErrorMessage = self.__encodeStr(e.fault.faultstring)
            log.error(sErrorMessage)
Пример #4
0
    def initProject(self, dConfig):
        i = 0
        sErrorMessage = ''
        while True:
            try:
                client = Client('http://localhost:' + WebservicePort +
                                '/OdisAutomationService?wsdl')
                client.set_options(timeout=3600)
                break
            except URLError:
                if i < 20:
                    print(
                        'failed to establish the ODIS webservice connection, try again in 10s'
                    )
                    i += 1
                    Sleep(5000)
                else:
                    sErrorMessage = 'failed to connect to ODIS webservice'
                    print(sErrorMessage)
                    return sErrorMessage

        print('... set vehicle project to ' + dConfig['sVehicleProject'])
        try:
            self.aTraceState = client.factory.create('traceSTATE')
            self.aService.setVehicleProject(dConfig['sVehicleProject'])
        except WebFault, e:
            sErrorMessage = self.__encodeStr(e.fault.faultstring)
            print(sErrorMessage)
Пример #5
0
 def record_simon(self):
     for i, pos in enumerate(self.buttons):
         curr_color = get_pixel_color(*pos)
         if self.base_colors[i] != curr_color:
             self.moves.append(pos)
             print(f"Recorded {i + 1} button")
             Sleep(SLEEP_BETWEEN_COMPUTER)
    def _get_echo_comment(self, post_urls):
        options = webdriver.FirefoxOptions()
        options.set_preference("dom.push.enabled", False)  # Setting firefox options to disable push notifications
        # driver = webdriver.Firefox(executable_path=r'D:\chrome-driver\geckodriver.exe', firefox_options=options)
        driver = webdriver.Firefox(executable_path=r'C:\Python27\geckodriver.exe', firefox_options=options)
        driverWait = WebDriverWait(driver, 4)  # Waiting threshold for loading page is 10 seconds

        # while len(post_urls):
        #     temp_post_urls = post_urls
        for post_url in post_urls:
            driver.get(post_url)
            Sleep(5000)
            comments = driver.find_elements_by_xpath(
                "//div[@class='css-1dbjc4n']/div[@class='css-1dbjc4n r-6337vo']/div/*/*/*/*/div")
            if len(comments) > 2:
                try:
                    comments_page = driver.find_element_by_xpath("//div[@class='css-901oao r-hkyrab r-1qd0xha r-a023e6 r-16dba41 r-ad9z0x r-bcqeeo r-bnwqim r-qvutc0']")
                except:
                    continue
                comment_text = comments_page.text
                yield (post_url, comment_text)
            # temp_post_urls.remove(post_url)
            # post_urls = temp_post_urls
            # Sleep(10000)
        driver.quit()
Пример #7
0
 def closeOdis(self):
     c = wmi.WMI()
     for proc in c.Win32_Process(Name='OffboardDiagLauncher.exe'):
         cmdline = proc.CommandLine
         if cmdline.find('webservice.ini') != -1:
             proc.Terminate()
             Sleep(1000)
Пример #8
0
def ThreadTwo(Lock):
    print "Thread two waiting ..."

    # Try to acquire the lock. As long as this thread could not acquire the lock it stops.
    Lock.acquire()

    # The operations should be surrounded by a try except block to be sure that the lock will be released.
    try:
        # Print message that the thread is running.
        print "Thread two running ..."

        # Print the numbers from 0 to 9 with a sleeping time of 100 ms in between.
        for Index in range(10):
            print "Thread two at index: %i" % Index
            Index = Index + 1
            Sleep(100)

        # Print message that the thread has stopped.
        print "Thread two stopped!"

    except:
        pass

    finally:
        # Release the lock and let other threads run.
        Lock.release()
Пример #9
0
def HWP_JPG_CHANGE_UPGRADE(full_filename):
    global hwp
    global count
    count = 0
    print("파일 복사중 위치 : " + full_filename)
    os.chdir(full_filename)

    # 디렉토리에 있는 모든 파일들을 불러와
    file_list = os.listdir(full_filename)
    # hwp,HWP 확장자로 구성되어있는 내용들만 리스트로 얻어옴
    file_list_hwp = [
        file for file in file_list
        if file.endswith(".hwp") or file.endswith(".HWP")
    ]

    print(len(file_list_hwp))

    for i in file_list_hwp:
        print(count)
        hwp_name = os.path.splitext(i)  #파일 확장자를 분리 시켜줌 ex) 1234.hwp -> .hwp

        # 첫번째 문서가 시작된다면 ,
        if count == 0:
            hwp = win32.gencache.EnsureDispatch('HWPFrame.HwpObject')  # 한/글 열기
            hwp.RegisterModule("FilePathCheckDLL",
                               "FilePathCheckerModuleExample")  # 보안창 닫기
            # hwp.RegisterModule("FilePathCheckDLL", "AutomationModule")
            hwnd = win32gui.FindWindow(None, '빈 문서 1 - 한글')  # 해당 윈도우의 핸들값 찾기
            win32gui.ShowWindow(hwnd, 0)  # 0은 숨기기, 5는 보이기, 3은 풀스크린 등

        # 이중 방어막 의미 없는 조건문 입니다
        if hwp_name[-1] in ".hwp" or hwp_name[-1] in ".HWP":
            if hwp_name[-1] != "":  # 디렉토리 인지 아닌지 체크하기 위해

                BASE_DIR = full_filename

                print(full_filename + "\\" + i + "작업중 ")
                hwp.Open(os.path.join(BASE_DIR, i))  # 한/글로 열어서
                hwp.HAction.GetDefault('FileSaveAs_S',
                                       hwp.HParameterSet.HFileOpenSave.HSet)
                hwp.HParameterSet.HFileOpenSave.filename = os.path.join(
                    BASE_DIR, i.replace('.hwp', '.JPG'))

                hwp.HParameterSet.HFileOpenSave.Format = 'JPG'

                hwp.HAction.Execute('FileSaveAs_S',
                                    hwp.HParameterSet.HFileOpenSave.HSet)
                print(full_filename + "\\" + i + "변환완료")
                count = count + 1
                Sleep(100)

        # 마지막 문서를 변환을 하고 한글 종료 시킴   , 이렇게 하지 않는다면 폴더 접근시에 한글이 열렸다 닫혔다 하기 때문에 안에서 처리 했습니다
        if count == len(file_list_hwp):
            print("한글 종료")
            win32gui.ShowWindow(hwnd, 5)
            hwp.XHwpDocuments.Close(
                isDirty=False)  # 열려있는 문서가 있다면 닫아줘(저장할지 물어보지 말고)
            hwp.Quit()  # 한/글 종료
def ThreadFunction():
    # Do the thread loop and identify the print output by the thread name.
    print "Thread running ... %s" % threading.currentThread().getName()
    
    # Print the numbers from 0 to 9 with a sleeping time of 100 ms in between.
    for Index in range(10):
        print "%s at index  %d" % (threading.currentThread().getName(), Index)
        Index = Index + 1
        Sleep(100)
Пример #11
0
def PrintDOMElements(application):
    print "These are the text element in the DOM:\n",
    # Wait for the document to finish loading
    READYSTATE_COMPLETE = 4
    while application.ReadyState != READYSTATE_COMPLETE:
        Sleep(100)
    for element in application.Document.documentElement.all:
        if element.toString() != "[object]":
            print "%s\n" % element,
def ThreadStopFunc():
    # Use the global variable STOP.
    global STOP
    
    # Wait for five seconds.
    Sleep(5000)
    
    # Stop the other thread by setting the global variable.
    print "Stopping Thread"
    STOP = 1
def WaitForAllThreads():
    # Retrieve all created threads.
    Threads = threading.enumerate()
    
    while threading.activeCount() > 1:
            
        # Pump all waiting messages of the current thread.
        pythoncom.PumpWaitingMessages()
        
        Sleep(100)
Пример #14
0
 def __procExist(self):
     exist = False
     c = wmi.WMI()
     for proc in c.Win32_Process(Name='OffboardDiagLauncher.exe'):
         cmdline = proc.CommandLine
         if cmdline.find('webservice.ini') != -1:
             exist = True
         else:
             proc.Terminate()
             # break
             Sleep(5000)
     
     return exist
Пример #15
0
def OpenNameEventSet(name, loop=1):
    # print("open event = [" + name + "]")
    event = None
    for i in range(0, loop):
        # 打开
        event = win32event.OpenEvent(0x1F0003, False, name)
        if event is not None:
            break
        # 打不开就sleep 然后再打开
        Sleep(500)
    if event is None:
        return False
    win32event.SetEvent(event)
    CloseHandle(event)
    return True
Пример #16
0
def ThreadFunc():
    # Use the global variable STOP.
    global STOP

    # Start the loop which would block the main thread.
    # This loop should check always the global variable.
    Index = 0

    while STOP == 0:
        print "Current counter for stop function %d\n" % Index,
        Index = Index + 1
        # Stop this thread to let other threads run.
        # If you don't include the Sleep function the other threads aren't given time to run.
        Sleep(100)

    print "Thread Stopped\n",
Пример #17
0
def ping (host):
  idx = 100
  ip = lookup_host (host, None)
  num = 0
  if ip == 0:
    err = cvar.dom_errno
    print ('%sUnknown host %s, dom_errno: %d: %s%s' % (FG_YELLOW, host, err, dom_strerror(err), FG_NORMAL))
    return

  while num < 5:
    if _ping(ip, idx, None, 0):
      print ("sent PING # %lu " % idx)
    idx += 1
    num += 1
    tcp_tick (None)
    if _chk_ping(ip,None) != -1:
      print ('%sGot ICMP echo%s' % (FG_YELLOW, FG_NORMAL))
    Sleep (1000)
Пример #18
0
def poll_clusters_freed(volume_handle, total_clusters, orig_extents):
    polling_duration_seconds = 7
    attempts_per_second = 10

    if not orig_extents:
        return True

    for _ in xrange(polling_duration_seconds * attempts_per_second):
        volume_bitmap, bitmap_size = get_volume_bitmap(volume_handle,
                                                       total_clusters)
        count_free, count_allocated = check_extents(orig_extents,
                                                    volume_bitmap)
        # Some inexact measure to determine if our clusters were freed
        # by the OS, knowing that another process may grab some clusters
        # in between our polling attempts.
        if count_free > count_allocated:
            return True
        Sleep(1000 / attempts_per_second)

    return False
Пример #19
0
def ping(host):
    idx = 100
    ip = w32.lookup_host(host, None)
    num = 0
    if ip == 0:
        err = w32.cvar.dom_errno
        print("%sUnknown host %s, dom_errno: %d: %s%s" %
              (Colour.YELLOW, host, err, dom_strerror(err), Colour.RESET))
        return

    while num < 5:
        try:
            if w32._ping(ip, idx, None, 0):
                print("sent PING # %lu " % idx)
        except TypeError as e:
            print("except: %s " % e)
        idx += 1
        num += 1
        w32.tcp_tick(None)
        if w32._chk_ping(ip, None) != -1:
            print("%sGot ICMP echo%s" % (Colour.YELLOW, Colour.RESET))
        Sleep(1000)
Пример #20
0
    windll.user32.mouse_event(RIGHTUP,0,0,0,0)

def righthold():
    windll.user32.mouse_event(RIGHTDOWN,0,0,0,0)

def rightrelease():
    windll.user32.mouse_event(RIGHTUP,0,0,0,0)


def middleclick():
    windll.user32.mouse_event(MIDDLEDOWN,0,0,0,0)
    windll.user32.mouse_event(MIDDLEUP,0,0,0,0)

def middlehold():
    windll.user32.mouse_event(MIDDLEDOWN,0,0,0,0)

def middlerelease():
    windll.user32.mouse_event(MIDDLEUP,0,0,0,0)

from win32com.client import Dispatch
from win32api import Sleep

shell = Dispatch("WScript.Shell")

if __name__ == '__main__':
    while True:
        Sleep(5000)
        #shell.SendKeys("{UP}")
        rightclick()
        Sleep(2000)
        shell.SendKeys("{ENTER}")
Пример #21
0
from win32com.client import Dispatch
from win32api import Sleep

while True:
    Sleep(30000)
    shell.SendKeys("{UP}")
    Sleep(1000)
    shell.SendKeys("{ENTER}")
Пример #22
0
from win32api import Sleep, GetAsyncKeyState
from keyboard import press_and_release
from pyperclip import copy
from sys import exit
from random import randint, seed
Sleep(2000)
run = 1
xree = input("Watcha spamming?: ")
copy(xree)
print("""
Have fun ;)
(you can click on Discord now. Press esc to stop the spam)
""")
while True:
    #seed()
    #copy(randint(1, 100))
    press_and_release("ctrl+v")
    press_and_release("enter")
    Sleep(1000)
    if GetAsyncKeyState(0x1B):
        exit()
            
Пример #23
0
def main():

    settings = open('settings.txt').read().split('\n')
    client_str = settings[0].split(':')[1]
    delay = int(settings[1].split(':')[1]) * 1000

    if settings[2].split(':')[1] == 'True':
        is_yt = True
    else:
        is_yt = False
    if settings[3].split(':')[1] == 'True':
        is_anime = True
    else:
        is_anime = False
    if settings[4].split(':')[1] == 'True':
        is_ide = True
    else:
        is_ide = False
    if settings[5].split(':')[1] == 'True':
        is_vk_online = True
    else:
        is_vk_online = False

    user_id = settings[6].split(':')[1]

    disc = None

    while True:
        try:
            disc = DiscAPI('697438501473615942')
            disc.connect()
            break
        except Exception as e:
            print(e)
            continue

    vk_session = None
    if is_vk_online:
        vk_session = \
            vk.create_session('', '')
    is_disc_closed = False
    title = ''
    while True:
        try:
            if is_vk_online:
                user = vk.get_user(user_id, vk_session['session'])
                print(user)
                print(user[0]['online'])
                if user[0]['online']:
                    disc.update(DiscAPI.ContentType.VK_Online, True)
                else:
                    disc.update(DiscAPI.ContentType.VK_Online, False)

            if is_ide:
                ide = check_win_list([
                    'Qt Creator', 'Visual Studio', 'Unity', 'Sublime Text',
                    'PyCharm'
                ])
                if ide is not None:
                    disc.update(DiscAPI.ContentType.IDE, ide)
                    continue
            last_title = title
            title = get_title(client_str)
            if title == last_title or title is None:
                continue
            print(title)
            if title['win_name'].find('YouTube') >= 0 and is_yt:
                print('here')
                if is_disc_closed:
                    disc.connect()
                    is_disc_closed = False
                disc.update(DiscAPI.ContentType.YT_Video, title['title'])
            elif title['win_name'].find('смотреть онлайн') >= 0 and is_anime:
                if is_disc_closed:
                    disc.connect()
                    is_disc_closed = False
                disc.update(DiscAPI.ContentType.Anime, title['title'],
                            'yummyanime')
            elif title['title'] == 'Смотреть онлайн' and is_anime:
                if is_disc_closed:
                    disc.connect()
                    is_disc_closed = False
                disc.update(DiscAPI.ContentType.Anime, service='nekomori')
            else:
                disc.update(DiscAPI.ContentType.No_Action)
                disc.close()
                is_disc_closed = True

            Sleep(delay)
        except Exception as e:
            print(e)
            continue
    disc.close()