Code:
Option Explicit
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function ShellExecute Lib "shell32" 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 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 ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Private Declare Function SetParent Lib "user32.dll" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Private Declare Function MoveWindow Lib "user32" (ByVal hwnd As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Boolean) As Long
Private Declare Function SendMessageLong& Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long)
Private Const WM_LBUTTONDOWN As Long = &H201
Private Const WM_CLOSE As Long = &H10
Private Const WM_LBUTTONUP As Long = &H202
Private Const WM_KEYDOWN = &H100
Private Const WM_KEYUP = &H101
Private Const VK_SPACE = &H20
Private rHwnd As Long
Private okHwnd As Long
Private Sub Form_Load()
On Error GoTo errortrap
ShellExecute 0, vbNullString, "c:\program files\routis\routis.exe", vbNullString, "c:\program files\routis", 1
Form1.Width = Screen.Width
Form1.Height = Screen.Height
Form1.Top = 0
Form1.Left = 0
Timer1.Interval = 500
Timer2.Interval = 500
Timer1.Enabled = True
errortrap:
End Sub
Private Sub Form_Unload(Cancel As Integer)
Call SendMessageLong(rHwnd, &H10, 0&, 0&)
End Sub
Private Sub Timer1_Timer()
Timer1.Enabled = False
rHwnd = FindWindow("#32770", "Warning")
okHwnd = FindWindowEx(rHwnd, 0&, "button", "OK")
SendMessage okHwnd, WM_LBUTTONDOWN, 0, 10
SendMessage okHwnd, WM_LBUTTONUP, 0, 10
Timer2.Enabled = True
End Sub
Private Sub Timer2_Timer()
Timer2.Enabled = False
If FindWindow("#32770", "Warning") <> 0 Then
rHwnd = FindWindow("#32770", "Warning")
okHwnd = FindWindowEx(rHwnd, 0&, "button", "OK")
Call PostMessage(okHwnd, WM_KEYDOWN, VK_SPACE, 0&)
Call PostMessage(okHwnd, WM_KEYUP, VK_SPACE, 0&)
End If
embed
End Sub
Private Sub embed()
rHwnd = FindWindow("intellinavwcls", "Routis")
okHwnd = FindWindowEx(rHwnd, 0&, "afx:400000:b:10011:6:0", vbNullString)
Call SetParent(okHwnd, Me.hwnd)
MoveWindow okHwnd, 0, 0, Screen.Width / Screen.TwipsPerPixelX, 7 / 8 * Screen.Height / Screen.TwipsPerPixelY, True
Call ShowWindow(rHwnd, 0)
End Sub
I don't think it really matters that much cause i like copilot better but it would be nice to figure out.
Bookmarks