Looking to trigger part of a C# script by external event - c#

ill try to keep my question short, littlebit of context:
I'm not a programmer, I work as engineer making configurators. I made a C# (.NET) .exe that uses another program's API to preform actions, right now it does so by me clicking a button on a windows forms application. This is already great, but i'm looking to automate further.
What is my goal? instead of me triggering a part of my script by clicking, i need it to trigger automatically.
Under What condition do i need to trigger? Right now i use Power Automate (previously know as Microsoft flow) to write data to Excel file, when it is finished writing data there, the script is allowed to trigger once.
What ways of achieving this do i see?
I could possibly use Excel API to detect a change of values inside my Excel document and trigger the script that way
I see i can create a Webhook in Power Automate and send a HTTP push
Again, i am not a programmer so i don't have to knowledge to make a good descision here. Maybe there is other ways to accomplish my goal aswell. I need a bit of direction and reference so i find the right solution and implement it.
Thank you all, if something is unclear or more information is needed, let me know!

Related

Manipulate an application using VB

I have a problem in my VB code so I am now stuck. I am trying to open a certain application by my VB application code, this is done successfully by Process.Start().
However I don't only need to start application, I also need to manipulate its User Interface, like button presses or loading configuration.
So how can I do that, given all what I know from the tool that I launch, is its destination in my machine?
I tried to google it, but I couldn't find good answer!

Online messaging system

I'm building a website at the moment and now i stand in a crossroad to chose which kind of messaging system to choose.
The website is build in asp.net, so using c# and other microsoft technologies i want to build a very simple messaging system between different users.
My question is how to do that, and what is the best way?
One option which i see is to use a database, to store the messages and then let the messaging page, every second refresh and perform code to retrieve the message, altho i tried it and i dont really like, because it isn't the proper way ... letting the page refresh and yeah retrieve the messages it is not very good.
But i dont really know the alternative i tried to search but didnt find any other possible solution only use of database and refreshing of the page.
My question is, what are any other possibilities to implement a very simple messaging system to a website, where for example 2 users can private message each other?
I dont need alot of explanation just some direction where to search ...
Thanks in advance for reading and replying to me, and for admins not to close the thread.
This should get you started.
Simple Chat Application in ASP.NET
Here's another one that looks promising...
LiveChat Starter Kit
Use jQuery and Ajax to get rid of the "refresh" page http://api.jquery.com/category/ajax/.
Regarding if you should use DB or not. Its really up to you, to whatever you are comfortable with. It dosen't sound that you have a lots of requirement.
If I would do it by myself and its a micro project I think I just would store the messages in the HttpContext...

Is it possible in Visual Studio to write code or debug an application while it is running?

As the questions says, I want to write code or debug an appication in real-time without setting breakpoints or pausing/restarting the application.
For example, when I write a game, I want to see what is happening when I change the code for the calculation of the light effects or the AI of the enemies immediately, while running the game on my second monitor.
Update:
Ok, it seems that you guys don't understand exactly what I want.
I want Visual Studio to be more like a WYSIWYG editor...make changes or add new code and see instantly what has changed in my application, without the application to pause it's work.
Update:
I saw this feature in this Video with Java in Eclipse (go to 14:30, where he changes the light effects of the game without stopping it.)
Sometimes. Check out the Edit and Continue feature: http://msdn.microsoft.com/en-us/library/bcew296c%28v=vs.80%29.aspx
Based on the comments, it sounds like you either want a dynamic language (a lot of games are scripted with LUA, or check our IronPython or IronRuby) or you want to dynamically load and reload assemblies, which would require something like MAF perhaps. With that, you could build the bits that you are changing as addins, and then unload and reload the addin assemblies when they change. That seems hacky though, and will likely perform poorly compared to a DLR language.
here is all you want to know abt the Edit and continue feature in Visual Studio:
http://msdn.microsoft.com/en-us/library/bcew296c(v=vs.80).aspx
You can edit the code while debugging, but no instruction will be executed during this time.
If you hit F10, the next instruction will be executed. If you hit F5 the normal execution will continue.
Why not create a resource file with the values to apply. Then have a command you can execute in the app that will reread the file. World of Warcraft has a feature like this. /reload ui
Yes, but unless Edit and Continue is enough for your need you need to design and implement the functionality yourself.
if the change is data driven - just reload the data when some file changes.
if change is in code - consider making that portion of the code to be in separate assembly and dynamically load and rewire the assemebly (may require strongly signed assembly to proper version code). Or dynamically compile code into new assembly (to avoid assembly conflicts in the same app domain).
In all cases you need to figure out how to deal with loosing part of previous state that could be in older objects.

How to get a value of a RadioButton from a WinForm application that I don't have an API for?

I have a small calculation system that will be installed in multiple PCs. Those PCs have a program installed in them and this program is always open (but minimized).
I need to get the value of a 'RadioButton' in this program but I can't access it!
I've tried to get an API for this application but the company developed it refused to co-operate. I've got a crazy idea, you can refer to my question regarding this idea Click It and the last thing is to get the cache for the button but I think this is going to work with WebApplications only!
Any help would be Great! =) .. And btw I decided to build my application as web application but then I changed my mind to build it as a WinForms because of the screenshot. But if I got a better and a more clean solution I'd go back to WebApp
Screen grabbing is not a good option. You should be able to use FindWindow based methods to get hold of the radio button if the app uses windowed controls. If not then UI Automation may very well be able to get the value of the radio button. Whatever it's usually possible to read UI state out of another application with methods like this, and much easier than screen scraping.

How does someone go about writing a "macro" in C#?

I know something about MACROS. I don't mean the ASSEMBLY language kind. I am talking about those programs that you can use perform repetitions actions on another program. I am talking about those programs that you can use to record a series of events on your computer, like, mouse movements and button clicks and then you can play them back. Some of them are elaborate enough to run only on a paricular app that you designate.
I wrote one of sorts once. It was a program that launched an Excel sessions and then used the dynamic data exchage pipe of some kind to feed the excell session script commands. It worked.
But something on the level of the operating system, I imagine, is a whole different story.
How does someone go about writing a "macro" in C#?
I think the approach I will take is to use the spy routine that comes with the development environment to get a list of the proper messages and parameters (wm_lbuttondown for example) and then use dynamic data exchange to send those messages to the app.
So I have three questions.
Is this the best way to do this?
How do I get a handle to an app that is already running?
How do I send user-like messages to an app that is already running?
There are different answers based on many following factors:
is it 3rd party or your own
application?
does it have automation interface
GUI toolkit used in app
If it is a 3rd party app then you need to work on Windows API level via PInvoke - subclassing WinMain proc, capturing and sending input messages, etc. There are 3rd party library for that task. C# obviously is not a right choice for such task.
In case application has automation model (like Excel) it's a pretty straight forward to write program that will be interact with this app.
If it's your own application you want to enhance with macros functionality then you should take this into account on design state. If you use Command pattern from the beginning then it's not hard to program macro recording.
You should provide more details to get a better answer.
Oh, I almost forgot to answer those three questions
Is this the best way to do this?
Depends on concrete scenario
How do I get a handle to an app that is already running?
Depends on application. If it's a native Win app you can easily get process Id and window's handle via WinApi.
How do I send user-like messages to an app that is already running?
Once again it depends on application type. For native win apps you can easily send WM_XXX messages via WinAPI
Unless its something you need to add in your own program you can just download a keyboard/mouse macro program and use it to perform these repeatable actions.
On the other hand to perform macro's in your own program you would want to find a way to record the buttons clicked and write them to a temporary list that can be saved and then run the list by clicking the buttons (programmically).

Categories

Resources