4

One of my clients has an application that can not be run from command line or via API but needs to be run on an scheduled basis. It would require that I launch the application if it's not already running and then click a button. This task would exist on a server.

I had read about AutoHotKey but it doesn't sound like it can click buttons from a Scheduled Task.

Does anyone have ideas on how to do this?

NOTE: As I answered below... I know this is a hack. It would be better to have an app that can actually be scheduled to run. Unfortunately (for me) this application isn't going to be replaced as it is connected to the client's beloved inventory management system and the entire deal is proprietary. So I just need to find an option to attempt this (might not be completely reliable I know). Thanks.

  • Why would you use AutoHotKey to click a button from a scheduled task instead of just using AutoHotkey to run a macro or AutoIt script that you create? – joeqwerty Aug 28 '12 at 03:34
  • Because it needs to run on a scheduled basis (i.e. nightly). As far as I know I will still need a scheduler to handle the scheduling of the script unless I would prefer to create a console application and put the thread to sleep for the remainder of the day. Or does AHK/AutoIt allow scheduling? – Jeremy Lattimore Aug 28 '12 at 03:42
  • I don't know, that's what I'm asking you. My point was that if you're looking to use a third party tool to interact with the sceduled task why not just see if the third party tool can do what you need in the first place. – joeqwerty Aug 28 '12 at 03:51

2 Answers2

2

Tell your clients to buy a real application?

It can, in theory, be done with a keyboard/mouse macro, which you could create with a product like AutoIT, but think about all the ways that can break or fail once you've created it and set the expectation that this task will fire regularly. More trouble than it's worth.

In all honesty, rather than hack something that ugly together, I would advise the client that what they want can't be done because they have a PoS product, and the solution is to upgrade or switch to something less awful.

HopelessN00b
  • 53,795
  • 33
  • 135
  • 209
  • I have no argument with you that the app (and hack to make it schedulable) is terrible design. Unfortunately, it is a supporting tool to their inventory system and it is proprietary. Replacing it isn't really an option as much as I would love it to be. – Jeremy Lattimore Aug 28 '12 at 00:05
  • @JeremyLattimore Well, then look into creating a mouse/keyboard macro with AutoIT (or another similar product, I just keep mentioning AutoIT, as it's the one I have experience with). And I'd make them pay through the nose too, but I get pissy around retarded legacy systems and stupid management/design decisions. – HopelessN00b Aug 28 '12 at 00:09
  • 1
    Sometimes, no matter how much we might like a "proper" solution, we have to work with what is there and simply don't get a choice, for whatever reason. – John Gardeniers Aug 28 '12 at 08:12
1

This is quite easily solved by having Task Scheduler run a batch file, which in turn calls the application and AutoHotKey, or some other such product. You may even be able to use an automation product to start the application and then click the button. Because both processes get started under the same user account the two will be able to interact as required.

John Gardeniers
  • 27,458
  • 12
  • 55
  • 109
  • Thanks John. I will give it a try. I wasn't sure if AHK or some other product would be able to do the click if it was a scheduled task based on other info that I had read. We shall see. Thanks. – Jeremy Lattimore Aug 28 '12 at 12:41
  • @Jeremy, the reason such things generally fail as a scheduled task is because the two processes are running under different accounts. – John Gardeniers Aug 28 '12 at 21:07