+ Reply to Thread
Results 1 to 29 of 29

How to paste into IE textbox?

  1. #1
    Registered User
    Join Date
    11-01-2012
    Location
    helsinki, finland
    MS-Off Ver
    Excel 2007
    Posts
    81

    How to paste into IE textbox?

    Hello !

    SendKeys "^V" doesn't work, it does not put the clipboard content to an IE textbox, even the focus is there ....

    You can select all = Ctrl-A by IE.ExecWB 17, 0
    You can copy = Ctrl-Cit then by IE.ExecWB 12, 2
    IE is object type

    So, you can copy, but how about the paste (paste the clipboard to IE textbox)?
    I have not been able to find ExecWB xxxx, where xxxx = Ctrl-V as 17,0 = Ctrl-A and 12,2 = Ctrl-C
    Or perhaps there is more elegant way of pasting clipboard to Internet Explorer?

    regards
    keymuu
    Last edited by keymuu; 11-19-2012 at 06:46 AM.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: How to paste into IE textbox?

    keymuu

    If you have code can you post it?
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    11-01-2012
    Location
    helsinki, finland
    MS-Off Ver
    Excel 2007
    Posts
    81

    Re: How to paste into IE textbox?

    Hi Norie!

    I have had all the time problems with SendKeys when trying to send with this or that combination
    to IE of code around it. Here is the current code but the same problem with SendKeys seems to
    follow along all the way. Of course that might be the setup of my computer, but anyway.
    I seems to work a little bit better when sending the hole string instead of one character at time,
    When sending a long string (once) the possibility for success is much bigger, if we consider
    SendKeys to be unreliably.

    Doesn't anybody know a better way/ more reliably than SendKeys is ???????

    Is there in the existing DLLs any function that could maybe do the same thing?
    Does anybody know where one could find a list what each DLL includes? I have
    tried to search around the internet but haven't been able to find any good sites about this.


    Please Login or Register  to view this content.

    regards
    keymuu

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: How to paste into IE textbox?

    keymuu

    You shouldn't use SendKeys at all, if possible.

    What is it you are trying to do?

    Is it just logon or is there more?

  5. #5
    Registered User
    Join Date
    11-01-2012
    Location
    helsinki, finland
    MS-Off Ver
    Excel 2007
    Posts
    81

    Re: How to paste into IE textbox?

    Hi again Norie!

    that is just the beginning, first log on and then
    there is a lot to do after the logon. But that is chapter 2,
    I need to get those small routines to work without failures.
    If I succeed here there should not be any reasons why not that would
    be the case after the login.

    But what I am trying to do at this point (logon page) is to make sure all
    will work in the future also. That is that everything works correct:

    Set focus to IE or to Excel - that works nice a
    copy from IE to Excel - works fine
    copy from Excel to IE - is the problematic thing, SendKeys does not work reliably, and I have to write to a textbox,

    I Can't use HTLM tags to do it just for a small reason, that if the HTML code changes in the future, and specially
    one or more used tag-names then, the software failes. This is the reason I desperately would like to have a "better SendKeys"

    regards
    keymuu

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: How to paste into IE textbox?

    keymuu

    I don't think I can help you if you aren't able to refer to the HTML code, sorry.

  7. #7
    Registered User
    Join Date
    11-01-2012
    Location
    helsinki, finland
    MS-Off Ver
    Excel 2007
    Posts
    81

    Re: How to paste into IE textbox?

    Thank you Norie,

    you did what you could, thank you very much!

    However, as I said earlier, I would like have some help from anybody who has some knowledge about
    a better SendKeys! How to write to IE. How to write surely to a textbox or what ever in EE, but have
    to sure that written text is correct, that text what was intended to write there.

    Anybody, please help if you can, if you have a knowledge how to write securely to a textbox or
    ...whatever... into IE. That will be very flexible in the future if the HTML code has changed, that
    would then no matter.

    As in mine first mail, the ExecWB has a copy function, but, one would expect that there also
    is a paste function, but not, I haven't find such a function. So, please if anybody have
    any knowledge of any methods, functions or whatever, so please be so kind and
    share that information. Thank you in advance

    Or, any other methods that could do the same thing....

    Kind regards
    keymuu

  8. #8
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646
    keymuu

    To be honest I don't think there is a 'secure' way to do this sort of thing.

    You mentioned changes in the HTML, but what if the changes are a bit more radical than that?

  9. #9
    Registered User
    Join Date
    11-01-2012
    Location
    helsinki, finland
    MS-Off Ver
    Excel 2007
    Posts
    81

    Re: How to paste into IE textbox?

    Hi Norie!

    Maybe I was a little bit unclear when saying "... how to write securely to a textbox ..."
    I used the word securely - not refer to secure or data security or anything into that direction,
    what I meant is that if I try to write ABCDEF... there also is the same ABCDEF... instead of ABCCDEEF...
    Sorry for misunderstanding I caused

    Still looking for a way to write to IE so one can be sure it is correctly written.
    Of course you can read it back and then compare it to the original but what then
    when you have, let's say over 1000 chars, and you don't get it correct even when
    you try it maybe hundred times and still not able to paste/write it correct. As the
    case with SendKeys seems to be.

    There is a lot of DLLs but haven't been able to find listings of what functions
    are inside those DLLs ?

    As long as you do not find those listings, you cannot know if there somewhere
    in some DLL would be a better "send to keyboard buffer" or something like that.

    For example kernel32.dll has Sleep and user32.dll has function BringWindowToTop
    but what else is just in those DLL not to talk about all the other DLLs? Where could
    one find such listing. If you can find user32.h (h=header) then there should all be listed,
    but the problem is to find them. When you google around for example kernel32.h
    you find this and that around internet but haven't so far seen Sleep.

    regards
    keymuu

  10. #10
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646
    If you want to guarantee what is entered on a webpage use the DOM to access the elements of the page.

  11. #11
    Registered User
    Join Date
    11-01-2012
    Location
    helsinki, finland
    MS-Off Ver
    Excel 2007
    Posts
    81

    Re: How to paste into IE textbox?

    Hi Norie!

    I'm not very familiar with DOM or direct accessing HTML code, but as I earlier said
    I need to find a way to write to a TextBox without having to know the name of that
    TextBox. That way it doesn't matter what the name of it is or changes, i.e. user_name,
    username, name, user or whatever.
    Here is, as I see it, a good page about all that:
    http://www.access-programmers.co.uk/...d.php?t=176968

    Do you or anybody know where (what site) one could find info about
    what all functions are in which DLL.

    Maybe somebody has made a DLL or an exe-file that takes
    a string and sends it to the keyboard buffer and would be willing
    to share it to those who might need it. Just wondering

    regards
    keymuu

  12. #12
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: How to paste into IE textbox?

    keymuu

    That link seems to be suggesting using code like I'm suggesting.

    If you want to learn about APIs this might be one place to look.

    Though I think you'll find that APIs aren't that useful when trying to interact with web pages.

    PS Why do you want to send something to a keyboard buffer when you can enter it directly on the page?

  13. #13
    Registered User
    Join Date
    11-01-2012
    Location
    helsinki, finland
    MS-Off Ver
    Excel 2007
    Posts
    81

    Re: How to paste into IE textbox?

    Hi Norie, again

    As I told earlier, I don't feel like trusting the HTML-code will stay forever intact.
    However, I succeeded to solve this mystical thing (missing paste function), thank you Norie
    for directing me to the API page where I found keybd_event which do the trick almost perfectly,
    the failure percent is under 2%. Can't understand how/why I haven't found that page earlier.
    To check if a failure has happened I select all, then copy it back and compare it with the original
    text.

    This code works in my PC:
    Please Login or Register  to view this content.
    So, now it's working as one would suppose, almost perfectly. The thing that it is not 100% sure
    seems to me again like something like "Welcome to the Windows world". As earlier said, nobody
    knows exactly what is going on behind your back, one thing working in one place but not in a
    other place etc.

    When you do copy/paste with your fingers on the keyboard I can only remember one time when
    it has failed and thought about it, but when it happens in such a situation nobody is upset
    about that and does paste (Ctrl-V) again/once more not even thinking the fault is a windows
    fault.

    regards
    keymuu

  14. #14
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: How to paste into IE textbox?

    keymuu

    Why not post your working code?

  15. #15
    Registered User
    Join Date
    11-01-2012
    Location
    helsinki, finland
    MS-Off Ver
    Excel 2007
    Posts
    81

    Re: How to paste into IE textbox?

    Quote Originally Posted by Norie View Post
    keymuu

    Why not post your working code?
    Hi Norie!

    Am I missing something here? That is the working code (at least in my PC).
    That code in my previous mail is the missing PASTE I was looking for. Try it, I think
    it should work in your computer also.

    The other part, more or less, is in the first listing in this thread. The real
    failure percent is slightly lower than 0,4% and not 2% as I claimed in my
    previous mail. That was achieved by waiting for IE to be ready before every
    get or put clipboard. However, this paste method is not tested more than
    3000 rounds so far.

    regards
    keymuu

  16. #16
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: How to paste into IE textbox?

    There's no Sub/End Sub or any reference to InternetExplorer or any web page.

    How does the code know where to paste?

  17. #17
    Registered User
    Join Date
    11-01-2012
    Location
    helsinki, finland
    MS-Off Ver
    Excel 2007
    Posts
    81

    Re: How to paste into IE textbox?

    Hi Norie

    Just set it in a sub for example like this:

    Please Login or Register  to view this content.
    As you know how to use the keyboard copy/paste (Ctrl-A, Ctrl-C and Ctrl-V)
    How do you know when you use Ctrl-V where you want to paste that data?
    The same goes for that code, first you put the focus where you want to paste
    for example notepad, put the focus to notepad:

    Please Login or Register  to view this content.
    then just paste whatever is in clipboard, easy, isn't it?

    regards
    keymuu

  18. #18
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: How to paste into IE textbox?

    keymuu

    How are you using FindWindow to find inputboxes on a web page?

    By the way, there are other things you might want to look at eg SendMessage, GetDataFromClipboard.

  19. #19
    Registered User
    Join Date
    11-01-2012
    Location
    helsinki, finland
    MS-Off Ver
    Excel 2007
    Posts
    81

    Re: How to paste into IE textbox?

    Hi Norie!

    I'm not aware if it is possible to find input boxes with FindWindows on a web page.
    The name of the function FindWindows does not suggest such a functionality for it.
    It would nice to have a function that would do that job. Maybe somebody could
    help on this one, please share the information if you know how to do that.

    I have been testing the copy/paste thing with IE and run to some kind of memory error
    after 720951 copy/pastes. The clipboards goes to a mode where you can't use it any more.
    I believe the memory used by DataObject is not totally freed after the use.
    They look like this:
    Please Login or Register  to view this content.
    So, the question is something like this
    When you have
    New DataObject you would need to free the memory after the use
    Set clipData = Nothing is not enough (?), maybe it should also have clipData.Quit
    Have to test that next. However, if somebody knows if there should be
    some other things to do than the Quit method, please share that info.

    regards
    keymuu

  20. #20
    Registered User
    Join Date
    11-01-2012
    Location
    helsinki, finland
    MS-Off Ver
    Excel 2007
    Posts
    81

    Re: How to paste into IE textbox?

    Hi Norie!

    I'm not aware if it is possible to find input boxes with FindWindows on a web page.
    The name of the function FindWindows does not suggest such a functionality for it.
    It would nice to have a function that would do that job. Maybe somebody could
    help on this one, please share the information if you know how to do that.

    I have been testing the copy/paste thing with IE and run to some kind of memory error
    after 720951 copy/pastes. The clipboards goes to a mode where you can't use it any more.
    I believe the memory used by DataObject is not totally freed after the use.
    They look like this:
    Please Login or Register  to view this content.
    So, the question is something like this
    When you have
    New DataObject you would need to free the memory after the use
    Set clipData = Nothing is not enough (?), maybe it should also have clipData.Quit
    Have to test that next. However, if somebody knows if there should be
    some other things to do than the Quit method, please share that info.

    regards
    keymuu

  21. #21
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: How to paste into IE textbox?

    keymuu

    I don't know if it is, that's why I was asking if you had found a way to do it.

    I was also asking because I'm still not clear on what you are doing here.

    How exactly are you getting specific data to a specific textbox on a specific page?

    As for the clipboard, perhaps it's EmptyClipBoard you want.

    By the way, 'windows' doesn't just mean main windows, eg the instance of IE I'm viewing this page in

  22. #22
    Registered User
    Join Date
    11-01-2012
    Location
    helsinki, finland
    MS-Off Ver
    Excel 2007
    Posts
    81

    Re: How to paste into IE textbox?

    Hi Norie!

    The only ways I know is to use the tabulator,
    or knowing the coordinates of a textbox and then clicking on the texcbox in question.

    Yes it might very well be EmptyClipBoard, the Quit method was not accepted. Have to test that next.
    Then there are also OpenClipboard and CloseClipboard. What for are the open and close functions ?
    As I look at it, the clipboard seems to work all the time without any specific open or close things...

    regards
    keymuu

    PS I don't get it how it is possible to send twice a reply as my previous was

  23. #23
    Registered User
    Join Date
    11-01-2012
    Location
    helsinki, finland
    MS-Off Ver
    Excel 2007
    Posts
    81

    Re: How to paste into IE textbox?

    Of course, EmptyClipboard did not help...it clears the data stored in the clipboard,
    not the memory the object=motor use.

    So, I'm still confused,
    When you have
    Set X = New DataObject
    then you have also
    Set X = Nothing <<<<< Am I missing after this (or before) something?
    The first one reserves memory and
    the second one should release it, however, not totally, not to my experience.

    I know I'm harping, but this annoys me when I don't grasp what happening.
    In my computer after about 720000 copy/pastes I got Out of memory error,
    and the clipboard in Excel doesn't work any more. This is not a big deal, but
    on the other hand it would be very nice to know what causes this.

    The clipboard is specific to Excel and is not "a global clipboard". To get the
    clipboard work again, you only need to restart Excel, that is resetting the
    clipboard and again I can copy/paste over 700000 times. However there
    should be an API function that would the same job (=reset clipboard),
    but haven't find one yet.

    If you know how to reset clipboard, please share that info.

    regards
    keymuu

  24. #24
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: How to paste into IE textbox?

    keymuu

    Any chance you could post some working code?

    Something that demonstrates how to use API to paste from the clipboard into a specific texbox on a specific page.

    By the way, you mention using the co-ordinates of a textbox. Aren't they likely to change depending on the setup?

  25. #25
    Registered User
    Join Date
    11-01-2012
    Location
    helsinki, finland
    MS-Off Ver
    Excel 2007
    Posts
    81

    Re: How to paste into IE textbox?

    Hi Norie!

    Here is a working paste:
    Please Login or Register  to view this content.
    It will paste whatever text to the active page (focused) and there to the focused textbox or whatever can accept
    as text as input. Maybe it can paste other things also like pictures etc, but I haven't tested that,

    Here is copy IE:
    Please Login or Register  to view this content.
    here is select all, IE focused textbox:
    Please Login or Register  to view this content.
    The above trio is really much better approach than SendKeys can ever be. On the other hand never say never or ever say ever,
    today that is the fact.

    I'm still missing a function that would do a complete RESET to the clipboard. As long as I have this small memory (somebody
    is eating it).

    Norie, is this solved as long as I have the memory problem?

    regards
    keymuu

  26. #26
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: How to paste into IE textbox?

    keymuu

    This seems a bit of a rigmarole, first you have to set the focus on the right textbox on the right page?

    What happens when you have, say, 15 textboxes to fill in?

  27. #27
    Registered User
    Join Date
    11-01-2012
    Location
    helsinki, finland
    MS-Off Ver
    Excel 2007
    Posts
    81

    Re: How to paste into IE textbox?

    Hello Norie!

    Yes it might look like that, but as told earlier you have TAB and the mouse. And sure,
    I will have more than 15 textboxes and other input fields after the log on page,
    but I do not worry about that before all problems are solved at this first stage.
    Again, on the other hand, there is not infinitely time for this thing, so you can't
    stay forever on the same spot.

    regards
    keymuu

  28. #28
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: How to paste into IE textbox?

    keymuu

    I'm sorry I still don't get it.

    You said this was to future proof for when a webpage might change.

    However, aren't the tabs on a page going to change over time too?

    Also, I've just tried the code and all it seems to do is paste at the cursor in whatever window has the focus.

    Why not use the DOM, it's pretty reliable and is also pretty adaptable to change?

    Anyways, if what you've got works it works.

    PS A 'real' example would be great, for example doing a search with Google.
    Last edited by Norie; 11-20-2012 at 01:50 PM.

  29. #29
    Registered User
    Join Date
    11-01-2012
    Location
    helsinki, finland
    MS-Off Ver
    Excel 2007
    Posts
    81

    Re: How to paste into IE textbox?

    Hi Norie!

    What you see on the screen is simpler to incorporate to a schedule what to follow.
    If a new version is launched and the tab stop coordinates changes then....
    I will have have a schedule for every page where every object on that page is
    like this:
    to the left tab stop, to the right the text for it
    1 write A
    2 write B
    3 write C
    ....
    16 write D
    17 write E = the last one
    Lets now say there pops up a new input between the first and second stops,
    no matter where they are on the screen layout. Now we have then 18 input points
    and have to write "that schedule" again, however, not so much to do when it is
    on an Excel sheet.

    I admit it is as easy to do that in the HTLM code (DOM) and you don't need to worry
    about any other thing than the unfortunate situation where a new version is done
    by an other programmer who has changed a lot, in the worst case all tag names
    are new. That then about the adaptable nature of it. This is of course only
    speculation, this would probably newer happen On the other hand,
    what does Murphy's law say? If it can happen then it also will happen sooner
    or later.

    When you do copy/paste for enough many times you will end up with out of memory
    for copy or paste. I claimed earlier that it is a Excel thing but have to correct that
    a little bit, it seems to be more on the Excel side but I aren't so sure any more,
    had to boot here one day before I could get it to work again reliably. So why
    sometimes it is enough to just to restart Excel and the next time you need
    to boot the PC. This is Microsoft Windows, can't trust on almost anything.

    Doesn't anybody know any function that would be something like
    reset clipboard, or any other aid to get rid of the memory decrease
    problem? Please share that information if you have it.

    regards
    keymuu

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1