[c++] vb用模拟按键的 方法调用ug命令

[复制链接]
梅雷工具箱发表于 2015-6-25 13:33:33 | 显示全部楼层 |阅读模式

'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/
就上UG网淘宝直营店
您需要登录后才可以回帖 登录 | 注册UG网 用百度帐号登录

本版积分规则