Our new Indie Games subforum is now open for business in G&T. Go and check it out, you might land a code for a free game. If you're developing an indie game and want to post about it, follow these directions. If you don't, he'll break your legs! Hahaha! Seriously though.
Our rules have been updated and given their own forum. Go and look at them! They are nice, and there may be new ones that you didn't know about! Hooray for rules! Hooray for The System! Hooray for Conforming!

Excel Send Keys

CauldCauld Registered User regular
Hey, so I'm looking through a telnet like interface at some data and I have the following lines of code:


Sess_Scrn.Putstring Acct_Prefix, 24, 12 Sess_Scrn.SendKeys ("<Enter>") Sess_Scrn.WaitHostQuiet (DT) Sess_Scrn.SendKeys ("<F2>") Sess_Scrn.WaitHostQuiet (DT)[/CODE] the DT is just a constant to wait for the mainframe to respond. My problem is that while it correctly sends the enter key, it simply puts <F2> in the command line when that line comes up. I tried changing the formatting of that line to [CODE]Sess_Scrn.SendKeys ("{F2}")[/CODE] as suggested in the excel vba help, and have tried many combinations of those things. So... help?[CODE] Sess_Scrn.Putstring Acct_Prefix, 24, 12
Sess_Scrn.SendKeys ("<Enter>")
Sess_Scrn.WaitHostQuiet (DT)
Sess_Scrn.SendKeys ("<F2>")
Sess_Scrn.WaitHostQuiet (DT)[/CODE]


the DT is just a constant to wait for the mainframe to respond. My problem is that while it correctly sends the enter key, it simply puts <F2> in the command line when that line comes up. I tried changing the formatting of that line to

Sess_Scrn.SendKeys ("{F2}")[/CODE] as suggested in the excel vba help, and have tried many combinations of those things. So... help?[CODE]Sess_Scrn.SendKeys ("{F2}")[/CODE]

as suggested in the excel vba help, and have tried many combinations of those things.

So... help?

Cauld on

Posts

  • AtomBombAtomBomb Registered User regular
    That's odd. The second one looks right to me. I don't know shit about this stuff really, but I made this code and it worked:

    Set objShell = WScript.CreateObject("WScript.Shell")
    objShell.Run "excel.exe"
    Do Until Success = True
    Success = objShell.AppActivate("Excel")
    Wscript.Sleep 1000
    Loop
    objShell.SendKeys "{F1}"


    Well, it didn't send the F1 to the correct application, but it did send it. Maybe try without the ()? Hopefully someone that knows better will chime in.

    I just got a 3DS XL. Add me! 2879-0925-7162
  • DaenrisDaenris Registered User regular
    Well, looking around at SendKeys examples it looks like a lot of samples have a caret (^) or percent (%) or both (%^) before the key code for function keys/etc. So try maybe any of these:
    Sess_Scrn.SendKeys ("^{F2}")
    Sess_Scrn.SendKeys ("%{F2}")
    Sess_Scrn.SendKeys ("%^{F2}")
    

    Edit: d'oh... nevermind... those are just the characters for ctrl/alt being added to the key.

  • CauldCauld Registered User regular
    AtomBomb wrote: »
    That's odd. The second one looks right to me. I don't know shit about this stuff really, but I made this code and it worked:

    Set objShell = WScript.CreateObject("WScript.Shell")
    objShell.Run "excel.exe"
    Do Until Success = True
    Success = objShell.AppActivate("Excel")
    Wscript.Sleep 1000
    Loop
    objShell.SendKeys "{F1}"


    Well, it didn't send the F1 to the correct application, but it did send it. Maybe try without the ()? Hopefully someone that knows better will chime in.


    I tried "{F2}" and the same thing happened, it just enters {F2} onto the command line, like before. I tried with and without parenthasis and the same thing happens either way.

Sign In or Register to comment.