0
import win32com
import win32com.client
import win32gui
import win32con
import pythoncom

def getIEServer(hwnd, ieServer):
    if win32gui.GetClassName(hwnd) == 'Internet Explorer_Server':
        ieServer.append(hwnd)

if __name__ == '__main__':
    #pythoncom.CoInitializeEx(0) # not use this for multithreading
    mainHwnd = win32gui.FindWindow('windowclass', 'windowtitle')
    if mainHwnd:
        ieServers = []
        win32gui.EnumChildWindows(mainHwnd, getIEServer, ieServers)
        if len(ieServers) > 0:
            ieServer = ieServers[0]
            msg = win32gui.RegisterWindowMessage('WM_HTML_GETOBJECT')
            ret, result = win32gui.SendMessageTimeout(ieServer, msg, 0, 0,     win32con.SMTO_ABORTIFHUNG, 1000)
            ob = pythoncom.ObjectFromLresult(result, pythoncom.IID_IDispatch, 0)
            doc = win32com.client.dynamic.Dispatch(ob)
            print doc.url
    #        doc.all['id'].click()

You can get doc (document object) with the above code If you try doc.getElementById ("some-id") I get an error like the one below.

TypeError: getElementById () takes 1 positional argument but 2 were given

It will appear in IE11 Please Help Me T0T~

p.s The type of problem is different from the suggested answer. I think I need to fix the error in pywin32.

착실이
  • 1
  • 3
  • Possible duplicate of [Interesting "getElementById() takes exactly 1 argument (2 given)", sometimes it occurs. Can someone explain it?](https://stackoverflow.com/questions/9816967/interesting-getelementbyid-takes-exactly-1-argument-2-given-sometimes-it) – cdarke Jul 10 '18 at 06:45
  • Its a pity, although a duplicate there does not appear to be a good solution. – cdarke Jul 10 '18 at 06:48

0 Answers0