def addMember(self, rowNum):
     
     row = getInfoOnRow(rowNum)
     
     fn = str(row[0])
     ln = str(row[1])
     em = str(row[2])
     print 'STARTING, this row is', rowNum
     print 'adding :', fn, ln
     print 'and  email :', em
     time.sleep(.5)
     #fill in form
     #first name
     click(*geo_fn)
     time.sleep(.7)
     addToCB(fn)
     addToCB(fn)
     SendKeys('^v')
     #SendKeys(fn, pause=0)
     time.sleep(.2)
     #last name
     click(*geo_ln)
     addToCB(ln)
     SendKeys('^v')        
     #SendKeys(ln, pause=0)
     time.sleep(.2)
     #click email
     click(*geo_em)
     addToCB(em)
     SendKeys('^v')        
     #SendKeys(em, pause=0)            
     time.sleep(.2)
     #click list
     click(*geo_sub)
     SendKeys('members')        
from SendKeys import SendKeys
from win32clipboard import GetClipboardData, SetClipboardText, \
                            EmptyClipboard, OpenClipboard, \
                            CloseClipboard
from josh_new_user_account1 import click
import time

#copy link to moneris to CB
OpenClipboard()
EmptyClipboard()
url = r'https://www3.moneris.com/mpg/index.php'
SetClipboardText(url)
CloseClipboard()

time.sleep(3)


username = r'oshfadmin'
store_id = r'monca02268'
password = r'oshfadmin6'

un_pos = (291, 621)
sid_pos = (274, 636)
pas_pos = (279, 661)

pairs = [(username, un_pos), (store_id, sid_pos), (password, pas_pos)]

for string, pos in pairs:
    click(*pos)
    SendKeys(string, pause=0)
 def next(self):
     
     excel = Dispatch('Excel.Application')
     excel.visible = 0
     
     excel.Workbooks.Open(root_ent_filepath_curpath.get())        
 
     def getInfoOnRow(row):
         first_name = excel.ActiveSheet.Cells(row,1).value
         last_name = excel.ActiveSheet.Cells(row,2).value
         postal_code = excel.ActiveSheet.Cells(row,3).value
         email = excel.ActiveSheet.Cells(row,4).value
     
         return [first_name,last_name,postal_code, email]          
 
 
     row = int(root_ent_set_row.get())
     info = getInfoOnRow(row)
     #print info
     
     #takes their first last and email
     first_name= str(info[0])
     last_name= str(info[1])
     email_address= str(info[3])
     #username
     first_letter= first_name[0].lower()
     last_lower= last_name.lower()
     username= '******'.format(first_letter,last_lower)
     #password
     pwd_lower= str(info[2]).lower()
     pwd_split= pwd_lower.split(' ')
     password= ''.join(pwd_split)
     
     
     #change entries
     #first
     self.ent_fn.delete(0, tk.END)
     self.ent_fn.insert(0, first_name)        
 
     #last
     self.ent_ln.delete(0, tk.END)
     self.ent_ln.insert(0, last_name)        
 
     #email
     self.ent_em.delete(0, tk.END)
     self.ent_em.insert(0, email_address)        
 
     #username
     self.ent_un.delete(0, tk.END)
     self.ent_un.insert(0, username)        
 
     #password
     self.ent_pw.delete(0, tk.END)
     self.ent_pw.insert(0, password)
 
 
     #increment row by 1
     root_ent_set_row.delete(0, tk.END)
     root_ent_set_row.insert(0, row+1)
     print 'done next'
     
     #create url
     self.template = 'http://www.oshf.ca/admin/ManageSecureMembers.asp'\
 '?formAction=&RecordPerPage=&message=CONFIRM+AND'\
 ';+HIT+SUBMIT+AT+BOTTOM&msg=&firstName={first}&LastName={last}&email'\
 '={email}&username={user}&password={pwd}&strRefreshFormAction'\
 '=InsertSecureMembers&intSecureMemberId=&secureSectionId=444&'\
 'strRefreshSendEmail=1&emailMatch=1'.format(
     first=first_name,
     last=last_name,
     email=email_address,
     user=username,
     pwd=password)
     
     print first_name, last_name, email_address, username, password
     print self.template
     
     #put url in address bar        
     wcb.OpenClipboard()
     wcb.EmptyClipboard()
     wcb.SetClipboardData(win32con.CF_TEXT, str(self.template))
     wcb.CloseClipboard()
     
     click(335, 39)
     SendKeys('^a{DELETE}', pause=0.5)
     SendKeys('^v{ENTER}')
def loopOverEmails(i):
    
    cont = True
    ##alt tab over
    SendKeys.SendKeys('%{TAB}')    
    while cont:
        row = getInfoOnRow(i)
        
        fn = str(row[0])
        ln = str(row[1])
        em = str(row[2])
        print 'STARTING, this row is', i
        print 'look for:', fn, ln
        print 'and fix email to:', em
        
        
        
        ##fill in search form
        #first name
        click(*POS.SR_f)
        SendKeys.SendKeys(fn)
        #last name
        click(*POS.SR_l)
        SendKeys.SendKeys(ln)
        #click search
        click(*POS.SR_search)
        
        sleep(4)
        
        ##modify the entry
        #click entry
        click(*POS.DM_entry1)
        #click email
        click(*POS.DM_em)
        #ctrl a
        SendKeys.SendKeys('^a')
        #type new email
        SendKeys.SendKeys(em, pause=0)
        
        wcb.OpenClipboard()
        wcb.EmptyClipboard()
        wcb.SetClipboardText(str(em).strip())
        wcb.CloseClipboard()        
        
        
        resp = raw_input('Continue, y or n?')
                
        proper = False
        while not proper:
            if str(resp) == 'n':
                cont = False
                proper = True
            elif str(resp) == 'y':
                i += 1
                print 'continue, next row is', i
                print 'look for:', fn, ln
                print 'new email is:', em
                proper = True
                cont = True
                
                
                ##alt tab over
                SendKeys.SendKeys('%{TAB}')                
                click(*POS.DM_mod)
                click(*POS.DM_again)
                
                sleep(2)
            
            else:
                resp = raw_input('Continue, y or n?')        
def loopOverMemstoAdd(rowNum):
    
    cont = True
    #alt tab
    #SendKeys('%{TAB}')
    while cont:
            row = getInfoOnRow(rowNum)
            
            fn = str(row[0])
            ln = str(row[1])
            em = str(row[2])
            print 'STARTING, this row is', rowNum
            print 'adding :', fn, ln
            print 'and  email :', em
    
            #fill in form
            #first name
            click(*geo_fn)
            SendKeys(fn, pause=0)
            #last name
            click(*geo_ln)
            SendKeys(ln, pause=0)
            #click email
            click(*geo_em)
            SendKeys(em, pause=0)            
    
            #click list
            click(*geo_sub)
            SendKeys('members')
            
            #move mouse to add button
            win32api.SetCursorPos(geo_add)
            
            #confirm info
            resp = raw_input('If the confirmation is correct\n'\
                             'and the add button as been clicked'\
                             'continue, y or n?')            

            #confirm answer is a y or a n
            proper = False
            while not proper:
                if str(resp) == 'n':
                    cont = False
                    proper = True
                elif str(resp) == 'y':
                    rowNum += 1
                    print 'STARTING, this row is', rowNum
                    print 'adding :', fn, ln
                    print 'and  email :', em
                    proper = True
                    cont = True
                    
                    
                    ##alt tab over
                    SendKeys('%{TAB}')                
                    #click(*POS.DM_mod)
                    #click(*POS.DM_again)
                    
                    #sleep(2)
                
                else:
                    resp = raw_input('Continue, y or n?')        
def createURL(row):
    #gets the info on row X from the excel sheet
    
    excel = Dispatch('Excel.Application')
    excel.visible = 0
    
    excel.Workbooks.Open('C:/josh.xls')
    
    
    def getInfoOnRow(row):
        first_name = excel.ActiveSheet.Cells(row,1).value
        last_name = excel.ActiveSheet.Cells(row,2).value
        postal_code = excel.ActiveSheet.Cells(row,3).value
        email = excel.ActiveSheet.Cells(row,4).value
    
        return [first_name,last_name,postal_code, email]    
    
    info=getInfoOnRow(row)
    pp(info)
    
    
    #takes their first last and email
    first_name= str(info[0])
    last_name= str(info[1])
    email_address= str(info[3])
    #username
    first_letter= first_name[0].lower()
    last_lower= last_name.lower()
    username= '******'.format(first_letter,last_lower)
    #password
    pwd_lower= str(info[2]).lower()
    pwd_split= pwd_lower.split(' ')
    password= ''.join(pwd_split)
    
    
    template= 'http://www.oshf.ca/admin/ManageSecureMembers.asp'\
    '?formAction=&RecordPerPage=&message=SCRIPT'\
    ';+HIT+SUBMIT+AT+BOTTOM&msg=&firstName={first}&LastName={last}&email'\
    '={email}&username={user}&password={pwd}&strRefreshFormAction'\
    '=InsertSecureMembers&intSecureMemberId=&secureSectionId=444&'\
    'strRefreshSendEmail=1&emailMatch=1'.format(
        first=first_name,
        last=last_name,
        email=email_address,
        user=username,
        pwd=password)
    
    print template
    
    ##note not working, IDK why
    wcb.OpenClipboard()
    wcb.EmptyClipboard()
    wcb.SetClipboardData(win32con.CF_TEXT, str(template))
    wcb.CloseClipboard()
    
    #alt tab
    SendKeys('%{TAB}')
    
    #TRPL Click
    click(707,45)
    #click(707,45)
    #click(707,45)
    
    #ctrl A
    SendKeys('^v')