0

Goodday,

We have been using Autohotkey for our company to automate certain events when uploading new items into our webshop to increase work efficiency. Autohotkey's features for using InputBoxes for Text Input are somewhat limited so right now I am struggling with C# Forms to replace our existing Autohotkey Program.

Virtual Mouse and Keyboard events are simulated very simply. Here's an example:

Mouseclick, l, 325, 60 //mouseclick at coordinate from top left corner of active window
Sleep, 50 //delay 50ms
Mouseclick, l, 950, 420
Sleep, 50
Send, %itemtitle% //writes text from variable
Sleep, 50
Mouseclick, l, 950, 445
Send, %itemdescription%

and so forth...

I need a simple function in C# that can be used as in the above example.

writeText(string text)

and

mouseclick (int button, int x_coordinate, int y_coordinate)

The coordinates in Autohokey are calculated inside the active window, but coordinates that are calculated for the entire screen will also work.

Thank you very much

AzulShiva
  • 201
  • 2
  • 17
  • Have you looked at http://stackoverflow.com/questions/647236/moving-mouse-cursor-programmatically ? for some pointers – BugFinder Jul 31 '15 at 09:00
  • I believe I have already seen that some time ago. I have now studied and tried to implement the code for the past hour, it's not working at all, although I managed to get rid of any error messages. I have no idea what I'm doing and I'm getting nowhere. I'm not that familiar with C# and somewhat shocked performing a mouseclick can be this complicated. Are there no common tools or library that has those functions that I need? – AzulShiva Jul 31 '15 at 10:30
  • Are you trying to write a generic automation app, to replace autohotkey? is it an internal app that you're trying to automate? Example: You can do button1.PerformClick(); which will click "button1" on your form. So, it can be easy, however, if you're controlling an app thats not the one you're in, then you probably need to resort to generating windows messages (windows works entirely on queues of messages such as WM_MOUSEMOVE etc.) and once you have gained the method of sending mouse move commands, click commands, and paste text or type text commands.. you could then write a script – BugFinder Jul 31 '15 at 10:41
  • https://msdn.microsoft.com/en-us/library/ms171548.aspx also looks useful – BugFinder Jul 31 '15 at 10:43

0 Answers0