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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending text From Attachmate to Notepad

Status
Not open for further replies.

MrDudeMan

Technical User
May 9, 2013
2
US
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
 
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.
 
Hey thanks for the nudge in the right direction. I'll see if i cant look up some info on the subject.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top