.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

6 REPLIES 6
Reply
Message 1 of 7
tracer123
990 Views, 6 Replies

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

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.

Tags (3)
6 REPLIES 6
Message 2 of 7
fenton.webb
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
AutoCAD Engineering
Autodesk

Message 3 of 7
tracer123
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.

Message 4 of 7
fenton.webb
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
AutoCAD Engineering
Autodesk

Message 5 of 7
tracer123
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.

Message 6 of 7

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

 

 

Message 7 of 7

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
AutoCAD Engineering
Autodesk

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost