I am trying to automate a program using Visual BAsic.NET. The idea is to invoke my "Program" at the click of a button, pass inputs to the program and save the results it would generate.
For now I can invoke my program using VisualBasic.NET(comands: shell, appactivate), I can pass in data to the program( My.Computer.Keyboard.SendKeys("a")),( just that it is broken).
the main problem is that the data to be input goes into a form with multiple tabs and I am not able to figure out the best way to select the correct tab so that I can throw my data in there and get to the results
Can some one please help me with this.
Also is this program has a dll( obviously I am new to windows application programming), is there any way i can directly pass data to the dll and get results?
Thanks!
I think you need to look up reflection. A good starting point for me was
vbdotnetheaven
Related
I created a small LabVIEW VI which prompts for some database connection details and then returns a .net object which has methods to access data stored in the database. This works fine so far. But now I want to use this as a Sub-VI and thus I need to pass out the created database connector object as an output.
Everything I found when searching was to hook up an output control (text or numeric) to the "wiring panel" (I don't know what the English name for this is, in my German version it is called "Anschlussfeld"), but obviously, this only works for text, numbers and the like.
Is it only possible to output these types, or can I also output .net references, and if so, how do I do this?
Use a .NET Refnum control, on the Controls ยป Ref Num palette.
For example, open the Task Monitor Using .NET Objects example VI: from the Help menu, select Find Examples, then double-click Communicating with External Applications, and then double-click on .NET. Change one of the constructor nodes into a subVI and inspect the new VI's front panel and connector pane.
Here's an illustration:
I have no idea how to make this in Visual Studio 2010. I'm trying to make a program that has a "grid" with columns. It will have a option to name a new profile/process, which is then added to the grid/list.
I can then edit the profile/process by clicking a button and editing the parameters that the process runs with.
most of the time these processes are the same same program/executable, just multi-instanced.
I can then start the process with the given parameters after I have setup it's profile.
I want to be able to monitor the RAM/CPU usage in one of the colums of the record/profile/process, sort of like the task manager and also "maintain" the process and keep it running/restart automatically it so it doesn't stop or crash unless directed otherwise.
I want these profiles/process parameters to be stored in a sqllite dll embedded database.
I would appreciate your help. thanks.
The very first step is for you to get all process, then place it in a container.
From there you can rename the process via My.Computer.FileSystem.RenameFile(file ,newName)
I prefer using datagridview, as with it you can easily add/remove columns and refer to the data. Assuming you have a datagridview with one column:
For Each ito As Process In Process.GetProcesses
Datagridview1.rows.add(ito.ProcessName.ToString)
Next
this will get you through the first part.
I'm new to VB, and so forgive me if this is a simple question.
I will be running multiple time consuming (single thread) processes in a program (that allows automation thru COM). And so to save some time, I want to open two or more instances of this program and run them simultaneously. But anything that I try to do on the program, it happens on the first opened program. This is what I have which my intentions are to open two instances of the program (which does correctly), and open a new document in each of the instances (which what it does is open two new documents in myProcess0 and none in myProcess1. Note: I have System.Diagnostics namespace activated.
Using myProcess0 As Process = Process.Start(programPath)
myProcess0.WaitForInputIdle()
pws0 = New COMprogram.Document
End Using
Using myProcess1 As Process = Process.Start(programPath)
myProcess1.WaitForInputIdle()
pws1 = New COMprogram.Document
End Using
Note: The COM program does not allow to create an handle for the program (like Matlab allows with MLApp.MLApp)
Any help will be appreciated it! Thanks in advance!
This is not exactly a solution, but my current "brute" workaround. This works if your iterations are independent of each other and wish to use multiple instances of a program in the same computer to perform these iterations (but for some reason that is unknown to me, any "Application" objects created point back only to the first instance of the Application).
What I'm doing, is tricking the code by using "desktops": http://technet.microsoft.com/en-us/sysinternals/cc817881.aspx
I simply open the VB code and a Application instance in each desktop, and for some reason the VB code only interacts with the Application opened in the current desktop and not on the others. This happens as well with Matlab somehow. For some reason, all Matlab Application objects reference the first instance.
This will be up to the COMprogram API. With Word or Excel, for example, you can't specify which instance you're accessing without manipulating an Application object.
I'm having a problem with making my VB.NET application point to something rather than "Application" in Event Log...
I create my custom event log using the function: EventLog.CreateEventSource("My_Source_Name", "My_Log_Name")
where the first parm is the Source Name, and the second parm is the log name. This method works every time it creates the event log's source, but when I'm about to add a new entry, I'm surprised that for some sources the process write the log under my custom log, but for other sources, the log is written in Application!!! (Some times with an error at it's header)!!!!!
I need to know, what exactly is going on?? am I (somehow) following the right way?? if Yes, what are the enhancements that I need to add to my code to make it look much better?? how can I stop this from occurring again so I can have all my logs under my customized log name?? and if No, what is the right way of doing this?? and is there any other way of writing this code (even if the new code was for another solution rather than the event log)??
Thank you very much :)
"To create an event source in Windows Vista and later or Windows Server 2003, you must have administrative privileges."
http://msdn.microsoft.com/en-us/library/5zbwd3s3.aspx
On the other hand, you should have a class (or interface) in charge of logging as a vertical layer on your application. That class is the one in charge of internally write to the appropriate event source.
However, if you need something powerful I really recommend Log4Net.
http://logging.apache.org/log4net/
So, let's say that I have a VBA application inside of whatever Office Application. I have created a command-line VB.net program to do all of the fun web-services stuff.
Okay, the VBA application calls Shell() to run the command line program. Now, what is the best way to get information (a tracking number for a package) from the VB.net program back into the VBA program?
My thoughts on the issue so far include:
Writing the number with Console.Write and then somehow extracting it in VBA
Or, using some kind of external interface (like a database or file system) to number the data and then get it out in VBA.
Any thoughts on this?
Why not call the Web service directly from VBA?
Check the samples in MSDN on how this can be done:
Calling XML Web Services from Office VBA Using the Web Service References Tool
Other options that you have would be:
Make your VB assembly COM-visible so that you talk to the VB code directly without having to launch a separate process
Write all relevant data to an intermediate file and read that from VBA