.NET

Reply
Contributor
tracer123
Posts: 15
Registered: ‎08-05-2008
Message 1 of 7 (440 Views)

AutoCAD Steals Focus While Visible Is False and WindowState Is Minimized?

440 Views, 6 Replies
12-10-2012 09:33 AM

I am running some background automation on AutoCAD (2012 if it matters) and I am running into an annoying issue where even when AutoCAD's visibility is set to false and it's window state is minimized it still grabs focus when a drawing opens.

 

Me.autoCadApplication.WindowState = AcWindowState.acMin
Me.autoCadApplication.Visible = False

 

Does anyone know how to fix this? It makes my computer unusable when the automation runs.

ADN Support Specialist
fenton.webb
Posts: 352
Registered: ‎07-24-2007
Message 2 of 7 (414 Views)

Re: AutoCAD Steals Focus While Visible Is False and WindowState Is Minimized?

12-12-2012 10:00 AM in reply to: tracer123

I don't think there is alot you can do via AutoCAD to control that. I think it's more of a Windows setup issue.

 

I vaguely remember that there was a setting which allowed you to control how the focus reacted for programs starting up in Windows but I can't find it now. I'm sure some dedicated internet searching will dig this information up.





Fenton Webb

Developer Technical Services

Autodesk Developer Network


Contributor
tracer123
Posts: 15
Registered: ‎08-05-2008
Message 3 of 7 (410 Views)

Re: AutoCAD Steals Focus While Visible Is False and WindowState Is Minimized?

12-12-2012 10:13 AM in reply to: fenton.webb

I think you're referring to the desktop registry setting which disables applications from stealing active window focus. This is already set to not allow applications to do that.

 

I'm quite sure this is an AutoCAD issue, no other program that I've automated shares this behaviour (Excel, Word, Visio, etc...). It's unforunate that there doesn't seem to be a way to stop it.

ADN Support Specialist
fenton.webb
Posts: 352
Registered: ‎07-24-2007
Message 4 of 7 (398 Views)

Re: AutoCAD Steals Focus While Visible Is False and WindowState Is Minimized?

12-13-2012 10:36 AM in reply to: tracer123

FYI - I'm looking into this for you... I need to make sure that I'm on the same page as you before moving forward with this - do you have a build able sample project that I can refer to please?





Fenton Webb

Developer Technical Services

Autodesk Developer Network


Contributor
tracer123
Posts: 15
Registered: ‎08-05-2008
Message 5 of 7 (394 Views)

Re: AutoCAD Steals Focus While Visible Is False and WindowState Is Minimized?

12-13-2012 10:52 AM in reply to: fenton.webb

Thank you for looking into this.

 

I could upload a sample if you need, but all I am really doing is:

  1. Gettting an instance of AutoCAD (2012).
  2. Setting Visible to False and setting WindowState to acMin on the Application object (like first post).
  3. Looping through a data set with push information.
  4. Opening a series of templates 1-by-1 and pushing the associated information onto the template and then "Save As-ing" it to a file and continuing.

While an application with the above structure runs, AutoCAD will steal focus everytime the next document is opened. So if you were typing in a window you would get about 1-2 seconds of time in that window before AutoCAD would steal focus back and you would be forced to refocus the window you were just on.

Valued Mentor
DiningPhilosopher
Posts: 370
Registered: ‎05-06-2012
Message 6 of 7 (386 Views)

Re: AutoCAD Steals Focus While Visible Is False and WindowState Is Minimized?

12-13-2012 09:17 PM in reply to: tracer123

Have you tried it without setting the window state to minimized?

 

 

ADN Support Specialist
fenton.webb
Posts: 352
Registered: ‎07-24-2007
Message 7 of 7 (346 Views)

Re: AutoCAD Steals Focus While Visible Is False and WindowState Is Minimized?

12-17-2012 05:12 PM in reply to: DiningPhilosopher

Without a sample, I cannot proceed... if you do not want to post a sample, then you will have to control the focus with your own Win32 application code to bypass the issues.





Fenton Webb

Developer Technical Services

Autodesk Developer Network


Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.