Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...This is easily the most helpful website I've ever used, and this is the best forum with the quickest response time bar none...."

Geography

Where in the world do Tek-Tips members come from?
dvirgint (Programmer)
23 Apr 12 14:07
Hello,

My company has switched from Attachmate Extra! to Attachmate Reflection recently and I have been creating new macros with the new Reflection syntax.

All is going well, however I was wondering if there was a way to create a variable to shorten the extremely long Sendkey functions.

For example, to make the system send a "tab" key, you have to add ibm.CurrentScreen.SendControlKey(ControlKeyCode_Tab)

I thought I could do something like:
Set tabKey = ibm.CurrentScreen.SendControlKey(ControlKeyCode_Tab)
... but that did not work.

Any ideas on how to approach this?

Thanks for your help.
Helpful Member!  Lakare (Programmer)
26 Apr 12 1:54
Have never used Attachmate Reflection, but can't you make a function to do the job like,

CODE

Declare Function sendkey(key)

Function sendkey(key)
  ibm.CurrentScreen.SendControlKey(key)
End Function

or if you want a Function, just for tab, then

CODE

Declare Function sendtab()

Function sendtab()
  ibm.CurrentScreen.SendControlKey(ControlKeyCode_Tab)
End Function

Then you just need to call it in main with,

CODE

Sub main
  sendkey("Hello World!")
End Sub

Don't know if the declaration of function syntax is the same in Reflection, because i use Extra!, and i'm not sure if this will work perfectly, but that is how i would do it.

Hope it helps
Lakare (Programmer)
26 Apr 12 3:39
Sorry, just realize the function was called SendControlKey, so the first function should not use SendControlKey, but the Sendkeys function instead.
Also, if you want a function to handle more ControlKeys, then you can make a function with an argument for the Controlkey, and then have a Switch (Select case) statement inside the function to use the correct control key.

You also need to Dim your session objects before the functions are described.
dvirgint (Programmer)
1 May 12 7:25
Thanks Lakare, it worked perfectly!!

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close