win32com

Windows authentication code no longer working now

社会主义新天地 提交于 2019-12-29 09:18:26
问题 My below code for windows authentication was working well for over a year. But for the last few days it is longer working now. I am not able to identify exact reason for that. from selenium import webdriver import time import win32com.client driver=webdriver.Chrome('D:/Software/BrowsersDriver/ChromeDriver/chromedriver.exe') driver.maximize_window() driver.get("authentication windows url") shell = win32com.client.Dispatch("WScript.Shell") shell.Sendkeys("username") time.sleep(1) shell.Sendkeys

Python - run Excel macro

╄→尐↘猪︶ㄣ 提交于 2019-12-29 01:05:12
问题 I would like to use Python to run a macro contained in MacroBook.xlsm on a worksheet in Data.csv. Normally in excel, I have both files open and shift focus to the Data.csv file and run the macro from MacroBook. The python script downloads the Data.csv file daily, so I can't put the macro in that file. Here's my code: import win32com.client import os import xl excel = win32com.client.Dispatch("Excel.Application") macrowb = xl.Workbook('C:\MacroBook.xlsm') wb1 = xl.Workbook('C:\Database.csv')

How can I confidently set the attributes of dispatched objects using win32com

二次信任 提交于 2019-12-25 12:01:11
问题 I have been struggling to assign an attribute to an object (or is it an instance) xl=win32com.client.Dispatch('Excel.Application') xl.Visible=0 srce=xl.Workbooks.Open('myexcelfile') srce.CheckCompatibility='False' If I query the srce object about its CheckCompatibility attribute I get a response of 'False' >>> srce.CheckCompatibility False So I am naively thinking I can save this anyway I want srce.SaveAs(r'c:\newtttxt14.xls',FileFormat=1) But when I do that the Compatibility Checker dialog

Python thread: The application called an interface that was marshalled for a different thread

会有一股神秘感。 提交于 2019-12-25 08:14:10
问题 The following code works without errors: self.sim.create_pnl_results(gui_values, dfs) This code gives me an error: thread = Thread(target=self.sim.create_pnl_results, args=(gui_values, dfs)) thread.start() in _ApplyTypes_ self._oleobj_.InvokeTypes(dispid, 0, wFlags, retType, argTypes, *args), com_error: (-2147417842, 'The application called an interface that was marshalled for a different thread.', None, None) It seems that the application calls a com object somewhere further down the line

Python thread: The application called an interface that was marshalled for a different thread

一曲冷凌霜 提交于 2019-12-25 08:10:54
问题 The following code works without errors: self.sim.create_pnl_results(gui_values, dfs) This code gives me an error: thread = Thread(target=self.sim.create_pnl_results, args=(gui_values, dfs)) thread.start() in _ApplyTypes_ self._oleobj_.InvokeTypes(dispid, 0, wFlags, retType, argTypes, *args), com_error: (-2147417842, 'The application called an interface that was marshalled for a different thread.', None, None) It seems that the application calls a com object somewhere further down the line

How can I use SetJob in win32print?

心不动则不痛 提交于 2019-12-25 05:19:56
问题 I want to clear or delete print jobs using Python. But how can I get JobID ? win32print.SetJob(hPrinter, JobID , Level , JobInfo , Command) How could I run this code? jobs = [] for p in win32print.EnumPrinters(win32print.PRINTER_ENUM_LOCAL,None, 1): flags, desc, name, comment = p pHandle = win32print.OpenPrinter(name) print = list(win32print.EnumJobs(pHandle, 0, -1, 1)) jobs.extend(print) SetJob(pHandle, id, 1,JOB_CONTROL_DELETE) #where should i get id from? win32print.ClosePrinter(pHandle)

Create a scheduled task using TASK_TRIGGER_LOGON in python

两盒软妹~` 提交于 2019-12-24 19:56:31
问题 I’m trying to create a task that will run each time the current user logs in. I’m having trouble finding any good examples or documentation. The best example I’ve found is this. I tried swapping out TASK_TRIGGER_DAILY = 2 for TASK_TRIGGER_LOGON = 9 , removing tigger.DaysInterval = 100 and using the associated objects like trigger.Delay , etc. found here. It always results in: Pywintyps.com error: (-2147352567, ‘Exception occurred.’, (0, None, None, None, 0 -2147024809), None) on line 67:

python: win32com and cx_Freeze - error

白昼怎懂夜的黑 提交于 2019-12-24 17:13:05
问题 I'm trying to compile a Python 3.3 script using cx_Freeze. The script uses win32com.client to control MediaMonkey. This works perfect when I directly run it. But when I compile it, it throws this exception. Traceback (most recent call last): File "O:\Python\3\lib\site-packages\cx_Freeze\initscripts\Console3.py", line 27, in <module> exec(code, m.__dict__) File "test.py", line 6, in <module> sdb = win32com.client.DispatchWithEvents("SongsDB.SDBApplication", MMEventHandler) File "O:\Python\3

Evaluating an Index Match with Openpyxl and Xlwings; formula returns, not value

↘锁芯ラ 提交于 2019-12-24 12:50:49
问题 I have referred to the following links but still cannot get my code to work Python openpyxl data_only=True returning None Refresh Excel External Data with Python Using Python's Openpyxl for an index match I am tackling my project in small pieces as I am new to python and coding. Ultimately I hope to populate a cell with a random number then use an index match to evaluate a list of text and numbers to identify the text string which corresponds to the random number. So if Item 4 in the

How can I use automation to right-click with a mouse in Windows 7?

牧云@^-^@ 提交于 2019-12-24 11:34:22
问题 I've spent a while getting my mouse to be able to right-click in Windows XP. Here's the code: public class Mouse { [DllImport("user32.dll", SetLastError = true)] internal static extern uint SendInput(uint numberOfInputs, Input[] inputs, int sizeOfInputStructure); private const int RightDown = 0x0008; private const int RightUp = 0x0010; private const int InputMouse = 0; public void RightClick<T>(T element) where T: AutomationElementWrapper { var point = element.Element.GetClickablePoint(); var