'vb用模拟按键的 方法调用ug命令
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Dim HwndVal&, Rtn&
Private Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long '激活窗口声明
Private Sub Delay(HowLong As Date) ' 延迟
TempTime = DateAdd("s", HowLong, Now)
While TempTime > Now
DoEvents '让 windows 去处理其他事
Wend
End Sub
Private Sub Form_Load()
'遇到错误,直接执行下一行。
On Error Resume Next
窗口全名 = "NX 4 - Modeling - [new_12345.prt (修改的) ]"
'取得窗口柄句
HwndVal = FindWindow(vbNullString, 窗口全名)
SetForegroundWindow (HwndVal) '激活窗口
Delay 0.1
SendKeys ("{F8}")
End Sub
_____________________________________________________________________________ _
中磊UG二次开发教程 梅雷著 qq1821117007
学UG就上UG网 http://www.9sug.com/ |