这个问题我已经解决了! Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long 'Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As LongPrivate Const HWND_BOTTOM = 1 Private Const SWP_SHOWWINDOW = &H40 Private Const SWP_HIDEWINDOW = &H80 Private Sub Command1_Click() Dim h1, h2, Point As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
'Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As LongPrivate Const HWND_BOTTOM = 1
Private Const SWP_SHOWWINDOW = &H40
Private Const SWP_HIDEWINDOW = &H80
Private Sub Command1_Click()
Dim h1, h2, Point As Long
Shell "NotePad", vbNormalFocus '打开记事本
h1 = FindWindow("Notepad", "无标题 - 记事本")
'ShowWindow h1, 0 '隐藏记事本窗口
SetWindowPos h1, HWND_BOTTOM, -100, -100, 0, 0, SWP_HIDEWINDOW
SendKeys "PowerBASIC中国", True '键入一些字符
SendKeys "%FA", True '打开另存为对话框
h2 = FindWindow("#32770", "另存为") '获取另存为对话框句柄
'ShowWindow h2, 0 '隐藏另存为对话框
SetWindowPos h2, HWND_BOTTOM, -100, -100, 0, 0, SWP_HIDEWINDOW
SendKeys "C:\PowerBASIC.txt", True '输入文件名
SendKeys "{TAB}{TAB}", True '将焦点定位到保存按钮上
SendKeys "{ENTER}", True '回车
SendKeys "%(FX)", True '退出记事本
MsgBox "您的文件已经保存到 C:\PowerBASIC.txt 中!"
End Sub