Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel VBA Not Sending F keys to Attachmate 1

Status
Not open for further replies.

AlbertShenko

Programmer
Nov 20, 2018
12
0
0
US
Using Excel VBA and Attachmate EXTRA! X-treme I am running into issues sending function keys ( <F9> and <F10>)

Here is the code snippet. It is copying data from a csv file and pasting it into Attachmate. To move to the next screen, the F10 key must be pressed. This is not passing through.

I have also tried going the route of trying to access the window manually using AppActivate and to send keys as {f9} and {f10}; but this also does not work.
The tab, down, enter SendKeys all work, including the oSess.Screen.Paste.

Is anyone able to help me figure this out?

Excel VBA said:
[pre] Case "WHATIF"
ReDim wbs(1)
wbs(0) = "C:\TEST1.CSV"
wbs(1) = "C:\TEST2.CSV"

For j = 0 To 1
Workbooks.Open (wbs(j))
Set ws = ActiveWorkbook.ActiveSheet

Application.Wait (Now + TimeValue("0:00:03"))
ws.Range("A1:H1").Copy
oSess.Screen.Paste
oSess.Screen.SendKeys "<F10>"
ws.Range("A2").Copy
oSess.Screen.Paste
oSess.Screen.SendKeys "<F10>"
tickerCount = ws.Range("A" & Rows.Count).End(xlUp).Row
ws.Range("A3:H" & tickerCount).Copy
oSess.Screen.Paste
For k = 3 To tickerCount
oSess.Screen.SendKeys "<UP>"
Next k

For k = 3 To tickerCount
oSess.Screen.SendKeys "<F9>"
oSess.Screen.SendKeys "<TAB>"
ws.Range("I" & k).Copy
oSess.Screen.Paste
Next k

oSess.Screen.SendKeys "<F10>"
oSess.Screen.SendKeys "<DOWN>"
oSess.Screen.SendKeys "<ENTER>"

Call oSess.Screen.WaitForString("RETURN TO BLOCK ORDER STATUS", , , , , 10000)
oSess.Screen.SendKeys "<DOWN>"
oSess.Screen.SendKeys "<DOWN>"
oSess.Screen.SendKeys "<ENTER>"
Next j[/pre]
 
Hi,

A former PA guy here (circa 1960).

I assume that your keyboard mapping is such that F9==PF9 & F10==PF10 and therefore you can perform each of those commands manually with expected paging results. Yes?

And for no extra charge...
"copying data from a csv file and pasting it into Attachmate"
Coding in Extra VB is like driving a Yugo compared to coding in Excel VBA, which is like driving a Navigator by comparison.




Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein
 
Sorry- I should have mentioned I did try using <PF10> as well: oSess.Screen.SendKeys "<PF10>"
This did not work.

When I pause the code in Excel VBA after it fails to send the F10 key, I can manually press the F10 in the window directly and resume the code.
If I change the F10 to say a random string like "HI", it will write "HI" in the window, so it doesn't appear to be a lost focus issue.

Any thoughts on what could be the cause of this? Or potential work-arounds?

 
CLEAR and then try using this format...
Code:
oSess.Screen.SendKeys ("<PF10>")
...or...
Code:
oSess.Screen.SendKeys "<PF10>"

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein
 
What am I clearing - it didn't seem to do anything? Referring to the api documentation, I see it as clearing an object...
With oSys as my object, I tried:

Code:
oSys.Waits.Clear
oSess.Screen.SendKeys "<PF10>"
oSess.Screen.SendKeys ("<PF10>")
oSess.Screen.SendKeys "<PF10>"
capture_g0fjum.jpg

But all three failed to send the F10 key to the screen.
 
Have you checked your keyboard mapping?

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein
 
I'm out of options. Sorry.

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein
 
No worries. I'll keep monitoring this thread and will post a solution when I figure it out - unless its posted here first of course :)
 
I continue to ruminate on this.

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein
 
Skip - you were right. It was keyboard mapping inside AttachMate; not the OS.

In EXTRA!X-Treme you access this from the ribbon by selecting: Edit-->Settings-->Keyboard Maps-->Edit--> (Double click on key)--> (Review the Keystrokes value listed)
In my case, F10 is remapped as: 

Thanks for pointing me in the right direction!
-Al
 
I suspected keyboard mapping all along. That can be tricky. It's been a long time since I directly interacted with a mainframe via a terminal emulator.

BTW, if you do a lot of screen scraping, you might consider a more long-term solution for 1) defining any screen in a reference table and 2) coding to use such a table to capture every field on a screen and place that data in a table in an Excel workbook.

In that way you will need only one set of procedures to capture the data from any screen thats defined in your reference table. It usually took me maybe 15 minutes to add such data to the table for a new screen.

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein
 
Thanks!

I'm actually going the other way (but I do scrape the entire screen in other jobs like you describe)

I'm receiving input that needs to be processed in the mainframe which has no way to be loaded systematically.
Currently it is key-punched manually or copy/pasted by associates.

So I'm navigating through screens, relying on search for strings to ensure I'm on the right page before pasting in data, and then running processes (using those pesky F-keys).
 
Currently it is key-punched manually…

Wow. Are they still using key-punch cards for input in your establishment?

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein
 
Not quite (I really just mean type by hand), but it certainly feels that way at times.
 
Last time I used a key-punch and card sorter was in the late 1979s.


Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top