winniepough
Programmer
See the three lines following the text in RED, thanks, Jim
Option Explicit
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Declare Sub keybd_event Lib "user32" _
(ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtrInfo As Long)
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" _
(ByVal hwnd As Long, ByVal lpClassName As String, byvalMaxCount As Long) As Long
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" _
(ByVal hwbd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" _
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long
Dim Executable
Public Sub Form_Load()
'--------------------------------
Call Launch
'--------------------------------
End Sub
Private Sub Launch()
Dim RunThis As String
Dim wHandle As Long
RunThis = "E:\TC2000CD\TC2000.exe "
Executable = Shell(RunThis, vbMaximizedFocus)
wHandle = FindWin("TC2000"
SetForegroundWindow wHandle
Sleep 5000 'allow time to load, required to function
SendKeys "%D", True 'alt D to select DataBase pull down
SendKeys "U", True 'U to select Update, using the Internet, vs. telephone 800 #
SendKeys "%U", True 'alt U to initiate Actual update 'Now'
Dim LTime
LTime = Timer()
While Timer() - LTime < 10 '10 seconds delay
DoEvents
Wend
SetForegroundWindow wHandle
NEXT THREE LINES DO NOT WORK, BUT EQUIVALENT FUNCTIONS MANUALLY!!
I TRIED THE keybd_event WITH VK_xxxx, IN MANY COMBINATIONS ALSO, NO LUCK
SendKeys "&H1B", True '(ESC), kill the Worden otes
SendKeys "&H1B", True '(ESC), kill any secondary pop-up
SendKeys "%&H73", False 'alt+F4, i.e. "%(F4)" close the "TC2000" program
Unload Form1 'FORM DOES UNLOAD, BUT "TC2000" IS STILL OPEN [/red]
End Sub
Function FindWin(AppTitle)
Dim FirstWin As Long
Dim DesktopWin As Long
Dim ReturnClass As Long
Dim WinClass As String * 252
Dim ReturnVal As Long
Dim WinTitle As String * 252
FindWin = 0
AppTitle = UCase(AppTitle)
DesktopWin = GetDesktopWindow
FirstWin = GetWindow(DesktopWin, 5)
Do While FirstWin <> 0
ReturnClass = GetClassName(FirstWin, WinClass, 250)
ReturnVal = GetWindowText(FirstWin, WinTitle, 250)
WinTitle = UCase(WinTitle)
If Trim(WinTitle) = "" Then GoTo NextOne
If Left(WinTitle, Len(AppTitle)) = AppTitle Then
FindWin = FirstWin
Exit Function
End If
NextOne:
FirstWin = GetWindow(FirstWin, 2)
Loop
End Function
Option Explicit
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Declare Sub keybd_event Lib "user32" _
(ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtrInfo As Long)
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" _
(ByVal hwnd As Long, ByVal lpClassName As String, byvalMaxCount As Long) As Long
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" _
(ByVal hwbd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" _
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long
Dim Executable
Public Sub Form_Load()
'--------------------------------
Call Launch
'--------------------------------
End Sub
Private Sub Launch()
Dim RunThis As String
Dim wHandle As Long
RunThis = "E:\TC2000CD\TC2000.exe "
Executable = Shell(RunThis, vbMaximizedFocus)
wHandle = FindWin("TC2000"
SetForegroundWindow wHandle
Sleep 5000 'allow time to load, required to function
SendKeys "%D", True 'alt D to select DataBase pull down
SendKeys "U", True 'U to select Update, using the Internet, vs. telephone 800 #
SendKeys "%U", True 'alt U to initiate Actual update 'Now'
Dim LTime
LTime = Timer()
While Timer() - LTime < 10 '10 seconds delay
DoEvents
Wend
SetForegroundWindow wHandle
NEXT THREE LINES DO NOT WORK, BUT EQUIVALENT FUNCTIONS MANUALLY!!
I TRIED THE keybd_event WITH VK_xxxx, IN MANY COMBINATIONS ALSO, NO LUCK
SendKeys "&H1B", True '(ESC), kill the Worden otes
SendKeys "&H1B", True '(ESC), kill any secondary pop-up
SendKeys "%&H73", False 'alt+F4, i.e. "%(F4)" close the "TC2000" program
Unload Form1 'FORM DOES UNLOAD, BUT "TC2000" IS STILL OPEN [/red]
End Sub
Function FindWin(AppTitle)
Dim FirstWin As Long
Dim DesktopWin As Long
Dim ReturnClass As Long
Dim WinClass As String * 252
Dim ReturnVal As Long
Dim WinTitle As String * 252
FindWin = 0
AppTitle = UCase(AppTitle)
DesktopWin = GetDesktopWindow
FirstWin = GetWindow(DesktopWin, 5)
Do While FirstWin <> 0
ReturnClass = GetClassName(FirstWin, WinClass, 250)
ReturnVal = GetWindowText(FirstWin, WinTitle, 250)
WinTitle = UCase(WinTitle)
If Trim(WinTitle) = "" Then GoTo NextOne
If Left(WinTitle, Len(AppTitle)) = AppTitle Then
FindWin = FirstWin
Exit Function
End If
NextOne:
FirstWin = GetWindow(FirstWin, 2)
Loop
End Function