又是一个双线程的问题,请教解决方法!
If Dir(swOldpathname, vbHidden + vbReadOnly + vbSystem) <> "" ThenName swOldpathname As swNewpathname
End If
Kill (ipath1)
Set Part = swApp.OpenDoc6(swNewpathname, 3, 0, "", longstatus, longwarnings)
swApp.ActivateDoc2 Y5, False, longstatus '线程1:这两条是给SolidWorks图纸替换名称打开改名后的图纸,会弹出打开的通用对话框让手动选择对应的改名后零件名。
'线程2:下面是通过获取句柄来让程序自动选择对应的零件名。
hwnd = FindWindow(vbNullString, "打开 ")
If hwnd <> 0 Then
hWnd2 = FindWindowEx(hwnd, 0, "ComboBoxEx32", vbNullString)
按钮1 = FindWindowEx(hwnd, 0, "Button", "打开") '获取按钮1句柄
If hWnd2 <> 0 Then
hWnd3 = FindWindowEx(hWnd2, 0, "ComboBox", vbNullString)
If hWnd3 <> 0 Then
hWnd4 = FindWindowEx(hWnd3, 0, "Edit", vbNullString)
If hWnd4 <> 0 Then
SendMessage hWnd4, WM_SETTEXT, 0, ByVal Tx2
PostMessage 按钮1, BM_CLICK, 0, 0 '单击按钮1
End If
End If
End If
End If
longstatus = Part.SaveAs3(swNewpathname, 0, 2)
swApp.CloseDoc Y5 & ".SLDDRW"
问题是线程1不手动选择零件点击确定线程2不执行。求解决方法!