c#如何激活CAD窗口(红色部分如何写)
<P> AutoCAD.AcadSelectionSet sset;<BR> AutoCAD.AcadApplication app;<BR> app = (AcadApplication) </P><P> System.Runtime.InteropServices.Marshal.GetActiveObject("AutoCAD.Application.16");<BR> short[] f1 = new short[] { 2 };<BR> object[] f2 = new object[] { "gtmodel" };<BR> <BR> sset=app.ActiveDocument.SelectionSets.Add("MySelect");</P>
<P> this.Hide();</P>
<P> <FONT color=#ff0000>//此次如何激活CAD窗口,让程序在cad中选择<BR></FONT> <BR> app.ActiveDocument.Utility.Prompt("请选择对象:");<BR> sset.SelectOnScreen(f1, f2);</P>
<P> this.Show();</P> 望高手指点。 <TABLE class=tablebody2 style="TABLE-LAYOUT: fixed; WORD-BREAK: break-all" width="90%" border=0>
<TBODY>
<TR>
<TD style="FONT-SIZE: 9pt; LINE-HEIGHT: 12pt" width="100%"><IMG alt=发贴心情 src="http://www.mjtd.com/bbs/skins/default/topicface/face1.gif" border=0> <B></B><BR>望高手指点。</TD></TR></TBODY></TABLE> <p>不知老兄是否解决问题了?我的方法比较复杂,就是模拟鼠标在CAD屏幕上点击一下。 </p><p>using System.Diagnostics;</p><p>加上</p><p><br/> public extern static void mouse_event(int dwFlags, int dx, int dy, int dwData, IntPtr dwExtraInfo);</p><p> <br/> public extern static void SetCursorPos(int x, int y);</p><p> <br/> public extern static bool GetCursorPos(out POINT p);</p><p> <br/> public extern static int ShowCursor(bool bShow);</p><p><br/> public struct POINT<br/> {<br/> public int X;<br/> public int Y;<br/> }</p><p><br/> <br/> public enum MouseEventFlags<br/> {<br/> Move = 0x0001,<br/> LeftDown = 0x0002,<br/> LeftUp = 0x0004,<br/> RightDown = 0x0008,<br/> RightUp = 0x0010,<br/> MiddleDown = 0x0020,<br/> MiddleUp = 0x0040,<br/> Wheel = 0x0800,<br/> Absolute = 0x8000<br/> }</p><p></p><p>//==========================================模拟鼠标左键点击</p><p> private void AutoMouseLeftClick(int x,int y)<br/> {</p><p> int dx = 0;<br/> int dy = 0;<br/> mouse_event((int)(MouseEventFlags.LeftDown | MouseEventFlags.Absolute), dx, dy, 0, IntPtr.Zero);<br/> mouse_event((int)(MouseEventFlags.LeftUp | MouseEventFlags.Absolute), dx, dy, 0, IntPtr.Zero);<br/> <br/> <br/> }</p><p><br/></p> <p>模拟鼠标在屏幕 0,0坐标点击一下</p><p>AutoMouseLeftClick(0, 0); </p> <p>谢谢哦</p><p></p> <p>请问<strong><font face="Verdana" color="#61b713">blessli</font></strong>:</p><p>在CAD下显示一个无模式对话框,当鼠标离开该窗口后,如何将焦点转移至CAD主窗口?</p> azbd发表于2008-7-3 22:39:00static/image/common/back.gif请问blessli:在CAD下显示一个无模式对话框,当鼠标离开该窗口后,如何将焦点转移至CAD主窗口?
<p>遇到同样问题!</p><p>关注ing.</p> 遇到同样问题!
关注ing.
blessli 发表于 2008-1-24 00:29 static/image/common/back.gif
模拟鼠标在屏幕 0,0坐标点击一下AutoMouseLeftClick(0, 0);
你好,用AutoMouseLeftClick(0, 0); 的话,会出现"内部错误:gedit 3"这种错误。是为什么呢?
页:
[1]
2