행위

"대신증권 자동로그인"의 두 판 사이의 차이

DB CAFE

(새 문서: <source lang=python> import pywinauto import time def logIn(): try: app = pywinauto.application.Application() #실행 app.start(r"C:\DAISHIN\STARTER\ncSta...)
 
 
(같은 사용자의 중간 판 2개는 보이지 않습니다)
1번째 줄: 1번째 줄:
 +
== Creon PLUS 자동 로그인 ==
 
<source lang=python>
 
<source lang=python>
 
import pywinauto
 
import pywinauto
78번째 줄: 79번째 줄:
 
      
 
      
 
</source>
 
</source>
 +
 +
== Creon PLUS 자동 로그인 다른방식  ==
 +
<source lang=sql>
 +
import win32com.client
 +
from pywinauto import application
 +
 +
class Creon:
 +
    def __init__(self):
 +
        self.obj_CpUtil_CpCybos = win32com.client.Dispatch('CpUtil.CpCybos')
 +
 +
    def kill_client(self):
 +
        os.system('taskkill /IM coStarter* /F /T')
 +
        os.system('taskkill /IM CpStart* /F /T')
 +
        os.system('taskkill /IM DibServer* /F /T')
 +
        os.system('wmic process where "name like \'%coStarter%\'" call terminate')
 +
        os.system('wmic process where "name like \'%CpStart%\'" call terminate')
 +
        os.system('wmic process where "name like \'%DibServer%\'" call terminate')
 +
 +
    def connect(self, id_, pwd, pwdcert):
 +
        if not self.connected():
 +
            app = application.Application()
 +
            app.start(
 +
                'C:\CREON\STARTER\coStarter.exe /prj:cp /id:{id} /pwd:{pwd} /pwdcert:{pwdcert} /autostart'.format(
 +
                    id=id_, pwd=pwd, pwdcert=pwdcert
 +
                )
 +
            )
 +
        while not self.connected():
 +
            continue
 +
 +
        return True
 +
 +
    def connected(self):
 +
        b_connected = self.obj_CpUtil_CpCybos.IsConnect
 +
        if b_connected == 0:
 +
            return False
 +
        return True
 +
 +
class MyWindow():                    # form class 로부터 form 로딩
 +
    def __init__(self):
 +
 +
        self.logIn = Creon()
 +
        self.login.kill_client()
 +
        id = '아이디 입력'
 +
        pass1 = '계정 패스워드 입력'
 +
        pass2 = '공인 인증서 패스워드 입력'
 +
        self.logIn.connect(id, pass1, pass2)
 +
 +
 +
if __name__ == "__main__":
 +
 +
    myWindow = MyWindow()
 +
 +
/*
 +
pywinauto 모듈 설치 필요
 +
*/
 +
</source>
 +
 +
[[category:주식]]

2023년 8월 28일 (월) 23:45 기준 최신판

thumb_up 추천메뉴 바로가기


1 Creon PLUS 자동 로그인[편집]

import pywinauto
import time

def logIn():
    try:
        app = pywinauto.application.Application()
        #실행
        app.start(r"C:\DAISHIN\STARTER\ncStarter.exe /prj:cp")
        time.sleep(10)
        
        flag=0
        while flag==0:
            try:
                #보안경고창 예 버튼 클릭
                title = '대신증권 CYBOS FAMILY'
                #dlg = app.window_(title=title) error나서 변경 20190331
                dlg = app.Connect(title=title).Dialog
                dlg['예(&Y)Button'].Click()
                time.sleep(1)
            except Exception as e:
                print(e)
            else:
                flag=1
                
        #안랩안티바이러스 로딩시간 대기
        time.sleep(80)
        
        #접속창 인식
        title = "CYBOS Starter"
        dlg = pywinauto.timings.WaitUntilPasses(120, 30, lambda: app.window_(title=title))
        pass_ctrl = dlg.Edit2
        
        #통신암호
        flag=0
        while flag==0:
            try:
                pass_ctrl.SetFocus()
                pass_ctrl.TypeKeys('PASSWORD')
                time.sleep(1)
            except Exception as e:
                print(e)
            else:
                flag=1
        
        cert_ctrl = dlg.Edit3
        
        #인증서암호
        flag=0
        while flag==0:
            try:
                cert_ctrl.SetFocus()
                cert_ctrl.TypeKeys('PASSWORD')
                time.sleep(1)
            except Exception as e:
                print(e)
            else:
                flag=1
        
        #접속버튼클릭
        flag=0
        while flag==0:
            try:
                btn_ctrl = dlg.Button
                btn_ctrl.Click()
                time.sleep(1)
            except Exception as e:
                print(e)
            else:
                flag=1
    except Exception:
        raise
    else:
        pass
        
if __name__ == '__main__':
    logIn()

2 Creon PLUS 자동 로그인 다른방식[편집]

import win32com.client
from pywinauto import application

class Creon:
    def __init__(self):
        self.obj_CpUtil_CpCybos = win32com.client.Dispatch('CpUtil.CpCybos')

    def kill_client(self):
        os.system('taskkill /IM coStarter* /F /T')
        os.system('taskkill /IM CpStart* /F /T')
        os.system('taskkill /IM DibServer* /F /T')
        os.system('wmic process where "name like \'%coStarter%\'" call terminate')
        os.system('wmic process where "name like \'%CpStart%\'" call terminate')
        os.system('wmic process where "name like \'%DibServer%\'" call terminate')

    def connect(self, id_, pwd, pwdcert):
        if not self.connected():
            app = application.Application()
            app.start(
                'C:\CREON\STARTER\coStarter.exe /prj:cp /id:{id} /pwd:{pwd} /pwdcert:{pwdcert} /autostart'.format(
                    id=id_, pwd=pwd, pwdcert=pwdcert
                )
            )
        while not self.connected():
            continue

        return True

    def connected(self):
        b_connected = self.obj_CpUtil_CpCybos.IsConnect
        if b_connected == 0:
            return False
        return True

class MyWindow():                     # form class 로부터 form 로딩
    def __init__(self):

        self.logIn = Creon()
        self.login.kill_client()
        id = '아이디 입력'
        pass1 = '계정 패스워드 입력'
        pass2 = '공인 인증서 패스워드 입력'
        self.logIn.connect(id, pass1, pass2)


if __name__ == "__main__":

    myWindow = MyWindow()

/*
pywinauto 모듈 설치 필요
*/