×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • 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!
  • Students Click Here

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

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Sending text From Attachmate to Notepad

Sending text From Attachmate to Notepad

Sending text From Attachmate to Notepad

(OP)
Ah, my first visit to the well of knowledge...Thank you in advance for your help and much respect!

I have been asked to help get a macro to work in Win7. We are migrating from XP to Win7 our macro wont work in Win 7. I am inheriting this project, and I'm not really a programmer but know a just enough to be dangerous. I have researched enough to know that "Sendkeys" doesnt work in Win 7 unless you take UAC all the way down to the lowest level. That is not an option in this environment. Rewriting the macro from the ground up is not an option either. The macro works fine except for the parts where i'm trying to send the keystrokes to notepad. So if you can tell me how to sendkeys to notepad I would appreciate it.

Here is the begining of the macro, thanks again!


'Global variable declarations
Global g_HostSettleTime%
Global g_szPassword$

Sub Main()
'--------------------------------------------------------------------------------
' Get the main system object
Dim Sessions As Object
Dim System As Object
Set System = CreateObject("EXTRA.System") ' Gets the system object
If (System is Nothing) Then
Msgbox "Could not create the EXTRA System object. Stopping macro playback."
STOP
End If
Set Sessions = System.Sessions

If (Sessions is Nothing) Then
Msgbox "Could not create the Sessions collection object. Stopping macro playback."
STOP

End If
'--------------------------------------------------------------------------------
' Set the default wait timeout value
g_HostSettleTime = 700 ' milliseconds

OldSystemTimeout& = System.TimeoutValue
If (g_HostSettleTime > OldSystemTimeout) Then
System.TimeoutValue = g_HostSettleTime
End If


' Get the necessary Session Object
Dim Sess0 As Object
Set Sess0 = System.ActiveSession
If (Sess0 is Nothing) Then
Msgbox "Could not create the Session object. Stopping macro playback."
STOP
End If
If Not Sess0.Visible Then Sess0.Visible = TRUE
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)


Begin Dialog cbdlg 99, 130, 185, 130, "PACKAGE TYPE"
ButtonGroup .bg
OkButton 131, 74, 50, 14
CancelButton 132, 109, 50, 14
CheckBox 2, 0, 40, 10, "SOLE", .CheckBox1
CheckBox 2, 18, 40, 10, "PART", .CheckBox2
CheckBox 2, 36, 40, 10, "CORP", .CheckBox3
Text 44, 01, 96, 8, "SOLE OWNER"
Text 44, 19, 96, 8, "PARTNERSHIP"
Text 44, 37, 96, 8, "CORPORATION"
Text 44, 54, 96, 8, "Please check a checkbox"
Text 45, 78, 76, 8, "And then click OK -->"
End Dialog

Dim my_dialog as cbdlg
On Error Resume Next
Dialog my_dialog
If Err=102 then
MsgBox "canceled."
End If

'This section of code opens Notepad

Shell "Notepad"
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sendkeys "%of"
Sendkeys "Courier{tab}Regular{tab}10{enter}"
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sendkeys "%{Tab}"
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sess0.Screen.MoveTo 21,14
Sess0.Screen.Sendkeys("<BackTab><BackTab><BackTab>TARAI000000000<Enter>")

'This section of code is for Sole Owner Accounts

If my_dialog.CheckBox1 Then

Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sess0.Screen.MoveTo 21,12
Sess0.Screen.Sendkeys("SOLE OWNER ACCOUNT<BackTab><BackTab><BackTab>TARAI")
g_HostSettleTime = 1000
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sess0.Screen.Sendkeys("<EraseEOF>")
g_HostSettleTime = 700

'This section waits for you to input the account number on the go line,

Sess0.Screen.WaitForCursor 21,21
Sess0.Screen.Sendkeys("<Enter>")
Do While sess0.Screen.OIA.Xstatus <> 0
DoEvents
Loop

Location = Trim(Sess0.Screen.GetString (04,09,4))
If Location = "FLAG" Then
Pause 1
Sess0.Screen.Sendkeys("<PF3>")
Do While sess0.Screen.OIA.Xstatus <> 0
DoEvents
Loop
End IF

Dim Sys As Object, Sess As Object, MyScreen As Object, MyArea As Object

Set Sys = CreateObject("EXTRA.System")
Set Sess = Sys.ActiveSession
Set MyScreen = Sess.Screen
Set MyArea = MyScreen.Area(1, 1, 20, 80)
MyArea.Select
MyScreen.Copy

AppActivate "Untitled - Notepad"
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sendkeys "{Enter}%EP"
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sendkeys "%{tab}"
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Do While sess0.Screen.OIA.Xstatus <> 0
DoEvents
Loop

RE: Sending text From Attachmate to Notepad

You know how you established the objects with Extra? (Dim Sys As Object, Sess As Object, MyScreen As Object, MyArea As Object) You have to do the same for Notepad. I don't know the object hierarchy for Notepad tho.

RE: Sending text From Attachmate to Notepad

(OP)
Hey thanks for the nudge in the right direction. I'll see if i cant look up some info on the subject.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

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! Already a Member? Login

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