+ Reply to Thread
Results 1 to 5 of 5

troubles with SendKeys

  1. #1
    mark
    Guest

    troubles with SendKeys

    Hello,

    I've been having trouble getting SendKeys to act as I would like.

    The thing I started to work on is to load data to another application, but I
    simplified it down to this, and it still stops:

    ****************
    For i = 1 To 6 Step 1

    AppActivate "Untitled - Notepad", True
    DoEvents
    sendkeys "123456{ENTER}"
    DoEvents

    Next i
    ************

    When I run that, it starts Notepad, but doesn't enter anything. The code
    doesn't stop though... each time that I click on the Excel application
    window, or on the VBA code window, if I'm running it that way, it cycles one
    more loop through the code, entering the data into Notepad, as it should.

    But it only ever does one iteration of the loop at a time, waiting for me to
    click on the application window again before it continues.

    Ideas as to why?

    Thanks,
    Mark

  2. #2
    Chip Pearson
    Guest

    Re: troubles with SendKeys

    I would avoid SendKeys at all costs. Instead of opening Notepad
    and trying to write data to it, why don't you just create a text
    file and use direct i/o on the file?

    --
    Cordially,
    Chip Pearson
    Microsoft MVP - Excel
    Pearson Software Consulting, LLC
    www.cpearson.com


    "mark" <[email protected]> wrote in message
    news:[email protected]...
    > Hello,
    >
    > I've been having trouble getting SendKeys to act as I would
    > like.
    >
    > The thing I started to work on is to load data to another
    > application, but I
    > simplified it down to this, and it still stops:
    >
    > ****************
    > For i = 1 To 6 Step 1
    >
    > AppActivate "Untitled - Notepad", True
    > DoEvents
    > sendkeys "123456{ENTER}"
    > DoEvents
    >
    > Next i
    > ************
    >
    > When I run that, it starts Notepad, but doesn't enter anything.
    > The code
    > doesn't stop though... each time that I click on the Excel
    > application
    > window, or on the VBA code window, if I'm running it that way,
    > it cycles one
    > more loop through the code, entering the data into Notepad, as
    > it should.
    >
    > But it only ever does one iteration of the loop at a time,
    > waiting for me to
    > click on the application window again before it continues.
    >
    > Ideas as to why?
    >
    > Thanks,
    > Mark




  3. #3
    mark
    Guest

    Re: troubles with SendKeys

    > I would avoid SendKeys at all costs

    Yeah, that's my opinion of it, too, but there have been occasions when I got
    it to work better than this, before.

    > Instead of opening Notepad and trying to write data to it, why don't you just create a text file and use direct i/o on the file?


    I would very happily do that, if a text file had been what I had originally
    needed to do with it. The Notepad screen was only an attempt to find out
    where the problme was.. in the destination application, or in the VBA code.
    The intended use had nothing to do with Notepad, or a regular text file.

    The intended use was to enter some data through a user interface in an
    Oracle Applications window... Yes, data can sometimes be entered directly
    into tables there, too, but only if they give you an interface, and I'm not
    in on that.

    The specific thing I was working on doing was to load a list of
    combinations... in this case, 33 of them. The method recommended by Oracle
    consultant is to cut/paste/down arrow through the list, entering them into
    the screen.

    This time, it's 33.. but I already did that 33 twice, and it won't always be
    the same thing.

    So, I was building a little data loader ... (yep, data loaders are available
    for sale, too).

    But anyway, I agree Chip, SendKeys is trash, and if I could just use i/o on
    a text file, I would. Notepad was only testing to prove the problem was in
    SendKeys, though.

    Thanks.

  4. #4
    Tim Williams
    Guest

    Re: troubles with SendKeys



    AppActivate "Untitled - Notepad"
    DoEvents

    For n = 1 To 10
    SendKeys "Hello " & n & "{ENTER}"
    DoEvents
    Next n



    works for me
    Tim

    --
    Tim Williams
    Palo Alto, CA


    "mark" <[email protected]> wrote in message
    news:[email protected]...
    > Hello,
    >
    > I've been having trouble getting SendKeys to act as I would like.
    >
    > The thing I started to work on is to load data to another application, but

    I
    > simplified it down to this, and it still stops:
    >
    > ****************
    > For i = 1 To 6 Step 1
    >
    > AppActivate "Untitled - Notepad", True
    > DoEvents
    > sendkeys "123456{ENTER}"
    > DoEvents
    >
    > Next i
    > ************
    >
    > When I run that, it starts Notepad, but doesn't enter anything. The code
    > doesn't stop though... each time that I click on the Excel application
    > window, or on the VBA code window, if I'm running it that way, it cycles

    one
    > more loop through the code, entering the data into Notepad, as it should.
    >
    > But it only ever does one iteration of the loop at a time, waiting for me

    to
    > click on the application window again before it continues.
    >
    > Ideas as to why?
    >
    > Thanks,
    > Mark




  5. #5
    mark
    Guest

    Re: troubles with SendKeys

    Yep, I know it's suposed to work, and as I mentioned, I've gotten it to work
    better in the past.

    But not today... was taking the naps in the middle that I mentioned...
    needing prodded along.

    Thanks for looking, though.

+ 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