本文整理汇总了Python中win32com.client.Dispatch.visible方法的典型用法代码示例。如果您正苦于以下问题:Python Dispatch.visible方法的具体用法?Python Dispatch.visible怎么用?Python Dispatch.visible使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类win32com.client.Dispatch
的用法示例。
在下文中一共展示了Dispatch.visible方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Demo
# 需要导入模块: from win32com.client import Dispatch [as 别名]
# 或者: from win32com.client.Dispatch import visible [as 别名]
def Demo() :
# Open excel
excel = Dispatch('Excel.application')
excel.visible = 1
#excel.windowState = con.WS_MAXIMIZE
excel.workbooks.Add()
sheet = excel.ActiveSheet
# Specify cell contents
# Some description of the contents:
cell = sheet.Cells(1,1)
cell.value = "Array"
cell.Font.Size = 14
cell.Font.Bold = True
# Enter data row by row.
data = range(0,10)
row_start = 3
rows = 5
rows = range(row_start, rows + row_start)
addresses = [] # These cell addresses will be used later.
for row in rows :
column_start = 2
cell = sheet.Cells(row, column_start - 1)
cell.value = 'Data Set' + str(row - row_start)
column = column_start
row_addresses = []
for item in data :
cell = sheet.Cells(row, column)
cell.value = item * row
row_addresses.append(cell.Address) # Record the cell address.
column += 1
addresses.append(row_addresses)
# Create a 'Total' row and enter a summation formula at the end of each column.
cell = sheet.Cells(row + 1, column_start - 1)
cell.value = 'Total'
# Make sum formulas
column = column_start
row += 1
for item in data :
cell = sheet.Cells(row, column)
cell.value = '=sum(' + addresses[0][column-column_start] + ":" + addresses[len(addresses)-1][column-column_start] + ')'
column += 1
# Delete all knowledge of the excel process for this Python session.
del excel
示例2: MakeSheet
# 需要导入模块: from win32com.client import Dispatch [as 别名]
# 或者: from win32com.client.Dispatch import visible [as 别名]
def MakeSheet(wx, tab, spread) :
# Open excel
busy = wx.BusyInfo("Creation of spreadsheet in progress ... ", tab)
wx.Yield() # necessary, otherwise busyinfo display is empty on Linux.
excel = Dispatch('Excel.application')
excel.workbooks.Add()
sheet = excel.ActiveSheet
busy.Destroy()
busy = wx.BusyInfo("Writing data to the spreadsheet ...\n\nThis will take about 11 seconds. ", tab)
wx.Yield() # necessary, otherwise busyinfo display is empty on Linux.
row = 1
for r in range(len(spread)) :
row += 1
col = 1
addRow(row, spread[r], col, sheet)
#for c in range(len(spread[r])) :
#col += 1
#cell = sheet.Cells(row, col)
#cell.value = spread[r][c]
# Delete all knowledge of the excel process for this Python session.
excel.visible = 1
#excel.windowState = con.WS_MAXIMIZE
busy.Destroy()
del excel
示例3: Dispatch
# 需要导入模块: from win32com.client import Dispatch [as 别名]
# 或者: from win32com.client.Dispatch import visible [as 别名]
from win32com.client import Dispatch
import SendKeys
import win32clipboard as wcb
excel = Dispatch('Excel.Application')
#excel.visible = 1
excel.Workbooks.Open('C:/changedEmails1.xls')
excel.visible = 1
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,3).value
return [first_name, last_name, email]
def loopOverEmails(i):
cont = True
while cont:
row = getInfoOnRow(i)
fn= row[0]
ln = row[1]
em = row[2]
print 'STARTING, this row is', i
print 'look for:', fn, ln
示例4: signin
# 需要导入模块: from win32com.client import Dispatch [as 别名]
# 或者: from win32com.client.Dispatch import visible [as 别名]
def signin(self):
deadline = "08:30:00"
nowtime = time.ctime()[-13:-5]
nowday = time.ctime()[0:3]
if nowday == "Sat" or nowday == "Sun":
logging.info("Running at %s", nowday)
return
if deadline < nowtime:
logging.info("QUIT. It's late.")
return
logging.info("Start running for %s...", self.u.upper())
ie = Dispatch('InternetExplorer.Application')
ie.visible = 1
ie.navigate("http://web.abc/portal/")
while ie.ReadyState != 4:
time.sleep(1)
logging.info("mainpage loaded")
document = ie.Document
document.getElementById("UserName").value = self.u
document.getElementById("Token").value = self.p
document.getElementById("saveCal").click()
# wait in case cookies not loaded
time.sleep(3)
try:
document.getElementById('something').innerHtml
except AttributeError:
logging.error('Wrong username or password!')
self.killie()
return
ie.navigate('http://kfzxsoi.zh.abc/attendance/userinfo.nsf/xpIndex.xsp')
while ie.ReadyState != 4:
time.sleep(1)
logging.info("xpIndex loaded")
ie.navigate('http://kfzxsoi.zh.abc/attendance/userinfo.nsf/xpSignLogsOfMy.xsp')
while ie.ReadyState != 4:
time.sleep(1)
logging.info("xpSignLogs loaded")
try:
document.getElementById("view:_id1:btnSignIN").click()
except:
logging.error("btn sign-in not found...")
self.sms("Sign in FAILED! btn sign-in not found...")
return
signinname = document.getElementById('view:_id1:repeat1:0:cfName').innerHtml
signindate = document.getElementById('view:_id1:repeat1:0:cfDate').innerHtml
signintime = document.getElementById('view:_id1:repeat1:0:cfTime').innerHtml
today = datetime.date.today()
if signindate == str(today):
if signintime < deadline:
smscontent = "%s %s Success.%s" % (signinname, signindate, signintime)
else:
smscontent = "Failed. It's late."
logging.info("Signed in SUCCESS.")
self.sms(smscontent)
self.killie()
else:
logging.info("Oh, you son of a biscuit.")
logging.error("Failed. Date ERROR. Restart in 10 sec...")
self.killie()
time.sleep(10)
self.signin()
示例5: next
# 需要导入模块: from win32com.client import Dispatch [as 别名]
# 或者: from win32com.client.Dispatch import visible [as 别名]
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}')
示例6: Dispatch
# 需要导入模块: from win32com.client import Dispatch [as 别名]
# 或者: from win32com.client.Dispatch import visible [as 别名]
fn = data[0].capitalize()
ln = data[1].capitalize()
except AttributeError as e:
print e, "for", data
all_data.append((fn, ln))
print "found data on {} rows".format(len(all_data))
return all_data
if __name__ == "__main__":
# open both sheets, make them visible
xl = Dispatch("Excel.Application")
pending = xl.Workbooks.Open(fp1)
renewed = xl.Workbooks.Open(fp2)
xl.visible = 1
##load each xls to a list
# loaded each set to a list
data_pending = getAllRows(pending.ActiveSheet, pen_strt_row, pen_end_row)
data_renewed = getAllRows(renewed.ActiveSheet, rnw_strt_row, rnw_end_row)
# compare them and find matches
matches = []
for person in data_pending:
if person in data_renewed:
print person[0], person[1], "matched"
first = person[0].encode("utf8", errors="replace")
last = person[1].encode("utf8", errors="replace")
matches.append("{} {}".format(first, last))
示例7: createURL
# 需要导入模块: from win32com.client import Dispatch [as 别名]
# 或者: from win32com.client.Dispatch import visible [as 别名]
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')