Results 1 to 8 of 8

Thread: Send keystrokes on INternet Explorer

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2011
    Posts
    13

    Question Send keystrokes on INternet Explorer

    Just assume i have already opened Internet explorer-Yahoomail.com Window on my desktop , on that already opend FOREGROUNDED Window i want to send following keystrokes just by pressing CTRL + H.
    (1)Tab
    (2)ABCD
    (3)Tab
    (4)1234 AND THEN AGAIN CTRL + H ...........UPTO 1000 times

    CONDITIONS : I CAN NOT SWITCHOVER TO EXCEL MACRO BY ALT+TAB OR MOUSE(To activate that macro) AND I NEED TO PERFORM THIS CTRL + H TASK REPEATEDLY ON THE SAME WINDOW WITHOUT SWITCHOVER TO ANY OTHER WINDOW.

    If not Sendkey then anything else you will suggest?The basic requirement is sending some FIXED keystrokes one after another by pressing CTRL+H on a particular application REPEATEDLY.Any thing in Windows itself available so that whenever i press CTRL + H, IT WILL SEND some keystrokes.

    Thank you.
    Regards
    Robs

  2. #2
    Junior Member
    Join Date
    Apr 2012
    Posts
    17

    Re: Send keystrokes on INternet Explorer

    Quote Originally Posted by robbs View Post
    Just assume i have already opened Internet explorer-Yahoomail.com Window on my desktop , on that already opend FOREGROUNDED Window i want to send following keystrokes just by pressing CTRL + H.
    (1)Tab
    (2)ABCD
    (3)Tab
    (4)1234 AND THEN AGAIN CTRL + H ...........UPTO 1000 times

    CONDITIONS : I CAN NOT SWITCHOVER TO EXCEL MACRO BY ALT+TAB OR MOUSE(To activate that macro) AND I NEED TO PERFORM THIS CTRL + H TASK REPEATEDLY ON THE SAME WINDOW WITHOUT SWITCHOVER TO ANY OTHER WINDOW.

    If not Sendkey then anything else you will suggest?The basic requirement is sending some FIXED keystrokes one after another by pressing CTRL+H on a particular application REPEATEDLY.Any thing in Windows itself available so that whenever i press CTRL + H, IT WILL SEND some keystrokes.

    Thank you.
    Regards
    Robs
    Assigning a "Hotkey" to CTRL+H is a function that is available in windows and should not be a problem once you write the script and assign it the hotkey of your choice. SendKey is also an easy script to write, the problem will come in when SendKey fails, is not focused on the right item/screen and continues on it's merry way and you got a huge mess on your hands (especially if you are planning to run this for 1000 items/instances). The suggested method would be to use the InternetExplorer.Application approach and find out the names of the fields you are entering the information into and write a script that is not going to cause you more headaches in the end. After you figure out what/how to run this properly then you can implement a Loop to run it the amount of times you need to.

    Example:

    Code:
     Dim objIE : Set objIE = CreateObject("InternetExplorer.Application")
     objIE.Visible = True
     objIE.Navigate "https://login.yahoo.com/config/login_verify2?&.src=ym"
     Do Until objIE.ReadyState = 4 
     WScript.Sleep 500
     Loop
     objIE.Document.All.Item("username").Value = "me@yahoo.com"
     objIE.Document.All.Item("passwd").Value = "Th!s!sMyP@ssW@rd"
     objIE.Document.All.Item("persistent").checked = True
    P.S. The above is only an example. Don't use this script to login since it will keep your password in plain text

  3. #3

    Thread Starter
    New Member
    Join Date
    Feb 2011
    Posts
    13

    Smile Re: Send keystrokes on INternet Explorer

    Thank you Bookworm for your precious help and advice.You have suggested me to write that programme and assigning a hot key to it.

    Actually i dont know where to assighn this hot key in windows.Will you tell me sir.Also can you please add some more lines in this programme so that together with sending the required keystrokes , the programme will also find a button named TOOLS in that webpage.Please do remmber keyborad shortcuts are deactivated in this webpage.

    At the end ,just a final glimpse : This programme will send some of the required keystrokes on that I.E window and will find an existing button named TOOLS on that I.E window, it will happen whenever i il press CTRL+M on that window.Also i can not switch over to any other window to activate that CTRL+M macro.

    Thank you
    Robbs

  4. #4
    Junior Member
    Join Date
    Apr 2012
    Posts
    17

    Re: Send keystrokes on INternet Explorer

    Quote Originally Posted by robbs View Post
    Actually i dont know where to assighn this hot key in windows.Will you tell me sir.
    Create a shortcut for the item/software/script then right click on the shortcut and select properties, you will see a Hot Key box in the General tab - assign it what you want.

    Here's an example for SendKeys function:
    http://technet.microsoft.com/en-us/l.../ee156592.aspx

  5. #5

    Thread Starter
    New Member
    Join Date
    Feb 2011
    Posts
    13

    Exclamation Re: Send keystrokes on INternet Explorer

    Thank you for the wonderfull help and solution you gave.

    But now while experimenting my programme most of the times what happens that sendkeys are not working well , some of the send key strokes are sent but some are not and if i use WScript.Sleep 500 then it takes a lil more time but the automation i m trying to implement must run in minimum time span.
    (1)Is there any full proof way to send all key strokes without getting any keystoke damaged or lost without using sleep or wait method?

    (2)Also is there any way by which i can set focus or select a specific button ,for egample SIGN IN button in yahoomail.com.

    Thanks and regards
    Robbs

  6. #6
    Junior Member
    Join Date
    Apr 2012
    Posts
    17

    Re: Send keystrokes on INternet Explorer

    Quote Originally Posted by robbs View Post
    Thank you for the wonderfull help and solution you gave.

    But now while experimenting my programme most of the times what happens that sendkeys are not working well , some of the send key strokes are sent but some are not and if i use WScript.Sleep 500 then it takes a lil more time but the automation i m trying to implement must run in minimum time span.
    (1)Is there any full proof way to send all key strokes without getting any keystoke damaged or lost without using sleep or wait method?

    (2)Also is there any way by which i can set focus or select a specific button ,for egample SIGN IN button in yahoomail.com.

    Thanks and regards
    Robbs
    1. As I warned you above in previous post, SendKey is prone to failure. It relies on Sleep functions and an active window that it's working on in order to work properly (and even like that it fails sometimes). Set focus on specific buttons? I believe I have already demonstrated that in the above script.

    2. Same question as above. Yes, you can. In order to call the button(s) on a webpage first you need to know what the name of the button is:

    Code:
    IE.Document.Forms("Form").elements("submit").click


    2.

  7. #7
    Addicted Member
    Join Date
    Jul 2009
    Posts
    208

    Re: Send keystrokes on INternet Explorer

    Quote Originally Posted by robbs View Post
    Just assume i have already opened Internet explorer-Yahoomail.com Window on my desktop , on that already opend FOREGROUNDED Window i want to send following keystrokes just by pressing CTRL + H.
    (1)Tab
    (2)ABCD
    (3)Tab
    (4)1234 AND THEN AGAIN CTRL + H ...........UPTO 1000 times
    What are you doing that requires repeating those steps 1000 times?

  8. #8

    Thread Starter
    New Member
    Join Date
    Feb 2011
    Posts
    13

    Exclamation Re: Send keystrokes on INternet Explorer

    Thank you for helping me , and i m sorry for asking silly questions.

    And i m sorry again because i am not able to know the internal name of that button reason being right click on that entire web page is disabled.So is there any other method like if i can focus on it by just writing its name in the script , as given on the top of button.
    I want to send these key strokes for 1000 times cos i want to automate a task for 1000 requests.I il click the short cut key 1000 times and each key will result in sending those fixed key strokes.

    Sorry for behaving like a kid.

    Thank you
    Regards
    Robbs
    Last edited by robbs; Apr 25th, 2012 at 01:27 PM. Reason: Incomplete

Posting Permissions

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



Click Here to Expand Forum to Full Width