Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Using Windows Scheduler to initiate an AutoHotKey Macro?


  • Please log in to reply
8 replies to this topic
tintinmilou
  • Members
  • 2 posts
  • Last active: Aug 23 2005 06:02 PM
  • Joined: 23 Aug 2005
:?: My apologies if this has been answered, and I just didn't get it, but I haven't seen a clear answer:
How can you use Windows Scheduler to initiate an AHK macro? :?:
Philippe Tusler

  • Guests
  • Last active:
  • Joined: --
http://www.microsoft...s/schtasks.mspx
That URL has lots of great information on schtasks, which replaces the AT command.

Anyway, something like this:
schtasks /create /tn "My Script" /tr "c:\program files\AutoHotkey\autohotkey.exe c:\script.ahk" /sc onidle /i 60 /ru ""

That would cause the script in the root of the C: drive to run when the machine has been idle for 60 minutes. /ru "" causes it to run under the system account, which prevents anything from showing up -- it becomes a background task. Otherwise use /ru "myusername" /rp "mypassword".

The above URL documents how to schedule your task however you would like.

tintinmilou
  • Members
  • 2 posts
  • Last active: Aug 23 2005 06:02 PM
  • Joined: 23 Aug 2005
I guess I need to express myself more clearly: How do I get the script to actually execute without being forced to enter a triggering keysequence?
Philippe Tusler

toralf as guest
  • Guests
  • Last active:
  • Joined: --
Hi,
It is always nice to make yourself clear. Because we can't read other users minds. What is that you want to do?

From what you wrote I guess:
You want to execute a script without using a key combination.
Your title suggest you want to use the Windows Scheduler. The guest showed a way to execute it with a scheduler. But form your last post I guess you didn't want that information. So what is left?

To execute a AHK script without a keysequence:
- Double click it in the explorer
- put it into the autostart folder of your windows OS
- have a second script start it at a given time or period
- use the GUI of the windows scheduler to have it scheduled
- use any other scheduler, you'll find several on the net

What do you want to do? Let us know. I'm sure we will be better in helping you then we are in mindreading. Thanks.

toralf
  • Moderators
  • 4035 posts
  • Last active: Aug 20 2014 04:23 PM
  • Joined: 31 Jan 2005

http://www.microsoft...s/schtasks.mspx
That URL has lots of great information on schtasks, which replaces the AT command.

Anyway, something like this:
schtasks /create /tn "My Script" /tr "c:\program files\AutoHotkey\autohotkey.exe c:\script.ahk" /sc onidle /i 60 /ru ""

That would cause the script in the root of the C: drive to run when the machine has been idle for 60 minutes. /ru "" causes it to run under the system account, which prevents anything from showing up -- it becomes a background task. Otherwise use /ru "myusername" /rp "mypassword".

The above URL documents how to schedule your task however you would like.

Thanks Guest for this info. I had a closer look at SchTasks, it is very powerful, but you need to have admin rights to use it :(

The user must be a member of the Administrators group on the computer that the command affects.


Ciao
toralf
 
I use the latest AHK version (1.1.15+)
Please ask questions in forum on ahkscript.org. Why?
For online reference please use these Docs.

Lemming
  • Members
  • 184 posts
  • Last active: Feb 03 2014 11:03 AM
  • Joined: 20 Dec 2005

:?: My apologies if this has been answered, and I just didn't get it, but I haven't seen a clear answer:
How can you use Windows Scheduler to initiate an AHK macro? :?:


I assume you're refering to "Scheduled Tasks" in Windows XP? If so, it is fairly simple.

Scheduled Tasks will run any program, if you have the proper rights. So all you need to do is to compile your AHK script into an EXE file (i.e. a program).

After that you only need to drag the EXE file into the Scheduled Tasks folder, and set the schedule. You'll have to make sure the user name and password are correct, or it won't run. They are under "Run as" and "set password".

learned
  • Guests
  • Last active:
  • Joined: --
I am getting the no account information error on SCHTASKS even on a local machine. any ideas what is causing it?

PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005

So all you need to do is to compile your AHK script into an EXE file (i.e. a program).

Well, I successfully ran uncompiled scripts too...
Posted Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")

guest9107
  • Guests
  • Last active:
  • Joined: --
Vista Business Ed...

I am having the same issue.
I have local admin rights w/ UAC turned off.
I recorded a repeptitive task.
The task was then compiled to an exe and setup to run 4 times a day.

I try running the task on the given time or manually and nothing happens.