Skip to content

Is C# the right langage for: (please read!)

Jonathan

Asked Jun 6, 2006, 4:58 AM EDT3 answers
Share
LinkedInX
Hello!, I'm here to find out if C# would be the right langage to do what I need to do for my work. We are currently doing everything using AutoIT, but it is pretty annoying since these programs can't query anything from a Databse, so everything there's an update in our database, we need to go back in the code to make the changes. The Database in question is a pretty simple Excel Database. I was told that C# could be my solution, but before I start learning it and doing research for it, I need to know if I can really use C# for this. If you don't know what AutoIT is, it's a macro creator programming tool. My job is very boring and I'm filling damn forms all day that are always the same, so to save time I created myself a lot of macros with AutoIT that does everything for me. This way I can create about 100 a day when I was only able to create about 25-30 a day before using macros. So AutoIT takes control of the mouse and keyboard to click on specific locations and enter information for me. What I need to know is if C# could do this and replace AutoIT? Please advise! Thanks!

3 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    C# can do mouse clicks and fill in information, through sending Win32 messages. It just might be a little bit more complicated. Here's some incomplete code that should be useful. Depending on the nature of the forms you are filling in, you may need to add more levels of EnumChildWindows, such as if the form is split into panels. Hopfully this can get you started. using System.Runtime.InteropServices; // pass in a handle for the window that contains the form public FormFiller(int handle) { EnumChildWindows(new HandleRef(null, new IntPtr(handle)), new EnumWindowCallback(WindowCallback), NullHandleRef); } // this should be called from the other window for each of its child controls private static bool WindowCallback(IntPtr handle, IntPtr extraParameter) { // set the control's text to 'blah' SetWindowText(handle, "blah"); // send a left click for the point 0,0 on the control PostMessage(handle, 0x201, 0, 0); // 0x201 is the message WM_LBUTTONDOWN } [DllImport("user32.dll", ExactSpelling=true)] static extern bool EnumChildWindows(HandleRef hwndParent, EnumWindowCallback lpEnumFunc, HandleRef lParam); [DllImport("User32", CharSet=CharSet.Auto)] static extern bool SetWindowText(IntPtr hWnd, string lpString); [DllImport("user32.dll")] static extern int PostMessage(IntPtr hWnd, uint Msg, int wParam, int lParam); public delegate bool EnumWindowCallback(IntPtr hwnd, IntPtr lParam); public static HandleRef NullHandleRef;
    0
  • 0
    What is this excel database?... if its something as simple as csv then you should bypass everything and create a custom c# app to modify the file... personally I would try to find a way other than sending simulated clicks and typing
    0
  • 0
    Thanks for the replies. The Excel DB is just text basically, I need to be able to automatically go copy information in there and then paste it in a Internet explorer window. No modification needs to be done to the Excel DB, I just need to read information from it, which is now done anyway. So far, I'm able to do a lot of this, the biggest problem I have yet is the following, hope someone can help with this; I can I know how the internet explorer page is fully loaded. (well not me, but my program). I'm tried to find a way to go grab the status bar text (grab when it's written DONE), but can't find anything yet for this... any ideas how my app can know when the IE window is fully loaded before continuing? THanks
    0