Coding/Python 삽질기2017. 6. 30. 01:51

import threading

import time



def count(s, c):

    for i in range(s, c):

        m = '+' + str(i)

        print m

        time.sleep(0.2)


def count2(s, c):

    for j in range(s, c, -1):

        n = '-' + str(j)

        print n

        time.sleep(0.1)



t1 = threading.Thread(target=count ,args=(10,100))

t2 = threading.Thread(target=count2,args=(200,101))

t1.start()

t2.start()

'Coding > Python 삽질기' 카테고리의 다른 글

[Python] Sleep  (0) 2017.07.08
Python으로 마우스 제어하기  (0) 2017.06.22
Python for Windows Extensions  (0) 2017.06.21
Posted by chobocho
Coding/Python 삽질기2017. 6. 22. 00:49

# pymove.py


import win32api

import win32con

import sys


mVersion = "V0.627_20170622"


def clickMouseLeft(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)


def clickMouseRight(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)


def moveMouseXY(x,y):

    win32api.SetCursorPos((x,y))



def readDataFile(filename):

    ''' Example of data file

        L 1 2

        R 2 3

        M 3 4

    '''

    with open(filename, 'r') as fp:

        cmdlines = fp.readlines()

    return cmdlines



def parseCommand(cmdlines):

    cmdlist = []

    for c in cmdlines:

        cmd = c.strip().split(" ")

        cmdlist.append(cmd)

    return cmdlist


cmdTable = { 

   'L':clickMouseLeft,

   'R':clickMouseRight,

   'M':moveMouseXY

}


def process(cmdlist):

    for c in cmdlist:

        cmdTable[c[0]](int(c[1]), int(c[2]))


def main(filename):

    cmdlines = readDataFile(filename)

    cmdlist = parseCommand(cmdlines)

    process(cmdlist)


def printHelp():

    print "\n[Help]"

    print "Usage : pymove filename"


if __name__ == '__main__':

    if (len(sys.argv) < 2) or ('-h' in sys.argv[1:]):

        printHelp()

    else:

        main(sys.argv[1])

    print mVersion



'Coding > Python 삽질기' 카테고리의 다른 글

[Python] Thread example  (0) 2017.06.30
Python for Windows Extensions  (0) 2017.06.21
[Python] 진법 변환  (0) 2016.12.27
Posted by chobocho
Coding/Python 삽질기2017. 6. 21. 23:53

Win32관련 Python 라이브러리


Download : https://sourceforge.net/projects/pywin32/


사용처 : Macro 프로그램 제작

'Coding > Python 삽질기' 카테고리의 다른 글

Python으로 마우스 제어하기  (0) 2017.06.22
[Python] 진법 변환  (0) 2016.12.27
단위분수를 소수로 변환하기  (0) 2016.09.07
Posted by chobocho
Coding/Tip2017. 6. 15. 23:28

출처 : http://www.samsungsvc.co.kr/online/faqView.do?domainId=NODE0000033866&node_Id=NODE0000124902&faqId=KNOW0000035916&pageNo=1


시작 -> 프로그램 추가/제거 ->  NSD 5.0 제거

'Coding > Tip' 카테고리의 다른 글

[GIT] 특정 폴더만 받아오기  (0) 2017.07.22
[Android] ADB로 전화 걸기  (0) 2017.06.15
삼성 노트북 삼성 TV와 무선 연결 하기  (0) 2017.05.03
Posted by chobocho
Coding/Tip2017. 6. 15. 00:51

[전화걸기]

adb shell am start -a android.intent.action.CALL -d tel:123-4567


[통화종료]

adb shell input keyevent KEYCODE_ENDCALL

or

adb shell input keyevent 6


[전화수신]

adb shell input keyevent 5


[5초간 대기 - DOS command]

timeout /t 5



[ 전화를 걸고 10초 뒤에 종료하는 스크립트 ]

adb shell am start -a android.intent.action.CALL -d tel:123-4567

timeout /t 10

adb shell input keyevent KEYCODE_ENDCALL




[ 자료출처 ]

https://stackoverflow.com/questions/4923550/how-to-make-a-call-via-pc-by-adb-command-on-android

https://stackoverflow.com/questions/25587147/adb-command-to-cancel-hang-up-incoming-call

https://stackoverflow.com/questions/166044/sleeping-in-a-batch-file

Posted by chobocho
Coding/Script2017. 6. 15. 00:30

Batch 파일을 이용한 작업을 하다가, 작업을 종료를 팝업 윈도우를 띄워주는 기능이 필요하여 찾아보았다.


[ 출처 ]

https://stackoverflow.com/questions/774175/show-a-popup-message-box-from-a-windows-batch-file


1. CSCRIPT


[ msgbox.vbs ]

Set args = WScript.Arguments

msgText = args(0)

MsgBox msgText


CSCRIPT msgbox.vbs "chobocho.com"




2. mshta 이용 


mshta javascript:alert("chobocho.com!");close();



[ Python에서 호출 ]

import os

 

if __name__ == '__main__':

    cmd = "mshta javascript:alert(\"chobocho\.com!\");close();"

    os.system(cmd)

Posted by chobocho