andy7172289
Technical User
Hi all,
I'm attempting to control a mainframe to automate a manual process using a sort of screen scraping method with the Application.SendKeys function. I've written code which does just that, but I've hit a wall. I've scoured the internet and found no solutions! The mainframe requires the enter key to be used, NOT the return key in order to move through the system. SendKeys to my knowledge does not allow me to differentiate to my knowledge.
Does anyone know what code might work or any work arounds? I've posted the code below. FYI - control+A, F10 and Page up all work with a keyboard, too, but not with SendKeys. Also, the online forums I read state that it's "Enter" or "~". The code below works fine until I get to the 'enter' (highlighted in yellow). I've highlighted commented text in orange.
Option Explicit
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Declare Function Wow64EnableWow64FsRedirection Lib "kernel32.dll" (ByVal Enable As Boolean) As Boolean
Private Sub RunOsk_on64Bit()
[highlight #F57900]
' This is a test macro to switch between TRUST and excel[/highlight]
Dim IDTRUST As Variant
Dim Path As String
Dim IDEXCEL As Worksheet
[highlight #F57900]'........................................................................................................................[/highlight]
[highlight #F57900] ' Set the Path variable equal to the path of your program's installation[/highlight]
Path = "C:\Program Files (x86)\WinVVTN\WinVVTN\WinVVTN.exe"
IDTRUST = Shell("C:\Program Files (x86)\WinVVTN\WinVVTN.exe", vbNormalFocus)
Application.Wait Now + TimeValue("00:00:12")
MsgBox "Please log in to WinVV and leave it on the blank input screen. This is to enable a TRJG search."
Dim IDnotepad As Double ' to identify application with AppActivate
Workbooks("Automated Incident Number Correction in TRUST Macro 2.0.xlsm").Sheets("1").Activate
[highlight #F57900]' IDnotepad = Shell("Notepad", vbMaximizedFocus)
'' MsgBox IDnotepad, vbOKOnly, "Notepad ID:"[/highlight]
Range("B2").Select
ActiveCell.Copy
AppActivate "SCR1 - WinVV Session 1", True
'''''''''''''''''Call OpenOSK
SendKeys "TRJG "
Application.Wait Now + TimeValue("00:00:01")
[highlight #FCAF3E]'''' SendKeys "R"
'''' Application.Wait Now + TimeValue("00:00:01")
'''' SendKeys "J"
'''' Application.Wait Now + TimeValue("00:00:01")
'''' SendKeys "G" {PGUP} {ENTER}
'''' Application.Wait Now + TimeValue("00:00:01")
'''' SendKeys " "[/highlight]
Application.Wait Now + TimeValue("00:00:01")
SendKeys "^(V)"
Application.Wait Now + TimeValue("00:00:01")
''''''''''''''''''''''''''''''''''' OSK = Shell("osk.exe")
Const SW_SHOWNORMAL = 1
On Error Resume Next
Wow64EnableWow64FsRedirection False
ShellExecute 0, "open", "osk.exe", "", "C:\windows\system32\osk.exe", SW_SHOWNORMAL
Wow64EnableWow64FsRedirection True
[highlight #FCE94F] Application.SendKeys ("{ENTER}")[/highlight]
[highlight #F57900]' SendKeys "{PGUP}"([F10])
' Application.SendKeys "%{F10}"
' Application.SendKeys "{CHAR(13)}"
' Application.SendKeys "%{F1}"
' Application.Wait Now + TimeValue("0:00:01")
[/highlight]
I'm attempting to control a mainframe to automate a manual process using a sort of screen scraping method with the Application.SendKeys function. I've written code which does just that, but I've hit a wall. I've scoured the internet and found no solutions! The mainframe requires the enter key to be used, NOT the return key in order to move through the system. SendKeys to my knowledge does not allow me to differentiate to my knowledge.
Does anyone know what code might work or any work arounds? I've posted the code below. FYI - control+A, F10 and Page up all work with a keyboard, too, but not with SendKeys. Also, the online forums I read state that it's "Enter" or "~". The code below works fine until I get to the 'enter' (highlighted in yellow). I've highlighted commented text in orange.
Option Explicit
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Declare Function Wow64EnableWow64FsRedirection Lib "kernel32.dll" (ByVal Enable As Boolean) As Boolean
Private Sub RunOsk_on64Bit()
[highlight #F57900]
' This is a test macro to switch between TRUST and excel[/highlight]
Dim IDTRUST As Variant
Dim Path As String
Dim IDEXCEL As Worksheet
[highlight #F57900]'........................................................................................................................[/highlight]
[highlight #F57900] ' Set the Path variable equal to the path of your program's installation[/highlight]
Path = "C:\Program Files (x86)\WinVVTN\WinVVTN\WinVVTN.exe"
IDTRUST = Shell("C:\Program Files (x86)\WinVVTN\WinVVTN.exe", vbNormalFocus)
Application.Wait Now + TimeValue("00:00:12")
MsgBox "Please log in to WinVV and leave it on the blank input screen. This is to enable a TRJG search."
Dim IDnotepad As Double ' to identify application with AppActivate
Workbooks("Automated Incident Number Correction in TRUST Macro 2.0.xlsm").Sheets("1").Activate
[highlight #F57900]' IDnotepad = Shell("Notepad", vbMaximizedFocus)
'' MsgBox IDnotepad, vbOKOnly, "Notepad ID:"[/highlight]
Range("B2").Select
ActiveCell.Copy
AppActivate "SCR1 - WinVV Session 1", True
'''''''''''''''''Call OpenOSK
SendKeys "TRJG "
Application.Wait Now + TimeValue("00:00:01")
[highlight #FCAF3E]'''' SendKeys "R"
'''' Application.Wait Now + TimeValue("00:00:01")
'''' SendKeys "J"
'''' Application.Wait Now + TimeValue("00:00:01")
'''' SendKeys "G" {PGUP} {ENTER}
'''' Application.Wait Now + TimeValue("00:00:01")
'''' SendKeys " "[/highlight]
Application.Wait Now + TimeValue("00:00:01")
SendKeys "^(V)"
Application.Wait Now + TimeValue("00:00:01")
''''''''''''''''''''''''''''''''''' OSK = Shell("osk.exe")
Const SW_SHOWNORMAL = 1
On Error Resume Next
Wow64EnableWow64FsRedirection False
ShellExecute 0, "open", "osk.exe", "", "C:\windows\system32\osk.exe", SW_SHOWNORMAL
Wow64EnableWow64FsRedirection True
[highlight #FCE94F] Application.SendKeys ("{ENTER}")[/highlight]
[highlight #F57900]' SendKeys "{PGUP}"([F10])
' Application.SendKeys "%{F10}"
' Application.SendKeys "{CHAR(13)}"
' Application.SendKeys "%{F1}"
' Application.Wait Now + TimeValue("0:00:01")
[/highlight]