-
Notifications
You must be signed in to change notification settings - Fork 0
/
bancolombia_login.py
85 lines (69 loc) · 1.95 KB
/
bancolombia_login.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import pyautogui as py
import webbrowser
import time
# Chrome browser path
chrome_path = "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s"
# Images directory to use pyAutoGui
img_dir = './images/bancolombia/'
# URL to open
URL = "https://sucursalpersonas.transaccionesbancolombia.com/"
###############
# CREDENTIALS #
###############
username = "username"
code = "0000"
code_list = [*code]
images_list = code_list
images_list = [img_dir + x + '.png' for x in images_list]
buttons = []
#############
# FUNCTIONS #
#############
# Function to locate image
def find_img(img, conf=0.9):
print(img)
img = img_dir + img
location = None
while location is None:
try:
if conf == 1:
location = py.locateCenterOnScreen(img)
else:
location = py.locateCenterOnScreen(img, confidence=conf)
except Exception as e:
print(e)
return location
# Function to click image
def find_and_click(png, conf=0.9):
location = find_img(png, conf)
py.click(location)
return location
##############
# AUTOMATION #
##############
# Open URL in Chrome browser
webbrowser.get(chrome_path).open(URL)
print("Buscando ingresar usuario...")
location = find_img('icon-user.png')
py.click(location[0] + 20, location[1])
py.write(username)
py.press('enter')
print("Ingresando usuario...")
print("Buscando numeros...")
# Locate keypad numbers
for i in range(len(code)):
location = None
while (location == None):
try:
location = py.locateCenterOnScreen(images_list[i])
coord = (location.x, location.y)
buttons.append(coord)
except Exception as e:
print(e)
# Click keypad password
print("Ingresando password...")
for i in range(len(buttons)):
py.click(buttons[i])
time.sleep(1)
print("click ingresar...")
find_and_click('ingresar.png')