Solved

VB.net 2005 - Set Focus on Control (External Program)!

Posted on 2014-12-23
9
94 Views
Last Modified: 2015-03-11
Hello Experts!

OK so I'm trying to write a program that will simulate an operator's key strokes because we have a program that we would like to run overnight, but we don't have an operator available to start the program at midnight.  So I've been able to execute the program and set focus on it...but I need to set focus on a specific control within the program...how can I do this?

I need the focus to be on the checkbox of the external program so I can uncheck the box then click OK.
I can't seem to get the focus on the checkbox...how can I get the checkbox name and set focus on it then use sendkeys to uncheck the box?

Thanks,
Mark
0
Comment
Question by:smithmrk
  • 5
  • 2
  • 2
9 Comments
 
LVL 12

Expert Comment

by:Ammar Gaffar
ID: 40515278
You can simulate user behavior by activating the external application and send the keys pragmatically.
Check this post it might help you:
http://www.codeproject.com/Tips/232649/Setting-Focus-on-an-External-application

In this link you can find the keys code:
http://www.developerfusion.com/article/57/sendkeys-command/

Good Luck
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 40515282
It's certainly possibly with VB.Net, but I'd recommend simply using something that can do this out of the box like AutoIT:
https://www.autoitscript.com/site/autoit/
0
 

Author Comment

by:smithmrk
ID: 40515343
Thanks to both of you...however I have the ability to set focus on the external program, and I've been sending keys just fine...but I want to grab window information from labels and checkboxes.

I want to be able to read the text of a checkbox or label.

For example if the checkbox says "Delete Batches" I want to grab the words "Delete Batches" from that checkbox label.

Thanks,
Mark
0
 
LVL 12

Expert Comment

by:Ammar Gaffar
ID: 40515387
I am really confused about your requirements,   if you have an operator,  he needs to make a decision based on something or just do some clicks so you program will start execute?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:smithmrk
ID: 40515451
OK, so once I get to the point of clicking the Button on the external program it brings up a popup box that is asking the operator if it is OK to delete the batches from a certain date I want to be able to pull that date off the popup box and verify it is correct before I sendkeys (Enter).

Thanks,
Mark
0
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 40515921
In that case I recommend using an approach like the one in this PAQ:
http://www.experts-exchange.com/Programming/Languages/.NET/Visual_Basic.NET/Q_26376975.html#33353089
0
 

Author Comment

by:smithmrk
ID: 40516363
OK, Thanks!
I'll take a look and play with the code after the holidays.

Hope ALL of you have a great Holiday to you and your families.

Mark
0
 

Author Comment

by:smithmrk
ID: 40522242
OK, I have a NEW Problem now!
When the workstation is NOT logged in the schedule job to run the program doesn't work because it won't do the SendKeys commands.

How can I get around logging into the computer to do the SendKey commands?

By the way the logon needs CNTL/ALT/DELETE and is Novel Logon.

Thanks,
Mark
0
 

Author Closing Comment

by:smithmrk
ID: 40658942
I had to abandon this program as I couldn't get around the Novel Login Screen.

Thanks for your help!

Mark
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now