Run AutoHotKey daily at specific time

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Codernator
Posts: 3
Joined: 19 Jul 2018, 09:05

Run AutoHotKey daily at specific time

19 Jul 2018, 09:16

Hi guys,
I'm new to autohotkey.
I can't figure out how to run my ahk at a specific time on daily basis :-(
could you please tell me what to add in my script to run this at 1 am every day?

Here is the ahk script that I have so far:

Code: Select all


#SingleInstance,Force
#Persistent

Run PowerShell.exe
Sleep, 3000 ;3 Seconds
Send,
(
 & "C:\Users\MyUserName\OneDrive - For Business\Company\PowerShell\Update-Data.ps1"

 Sleep -Seconds 5

 Exit
)
Send, {Enter}


ExitApp



Thank you in advance for your help
Guest

Re: Run AutoHotKey daily at specific time

19 Jul 2018, 09:42

Why don't you use the Windows task scheduler?

Otherwise use SetTimer https://autohotkey.com/docs/commands/SetTimer.htm

Various working scripts and links here:
https://autohotkey.com/board/topic/2016 ... ific-time/
(You could have googled yourself no doubt)
Codernator
Posts: 3
Joined: 19 Jul 2018, 09:05

Re: Run AutoHotKey daily at specific time

19 Jul 2018, 10:04

Guest wrote:Why don't you use the Windows task scheduler?

Otherwise use SetTimer https://autohotkey.com/docs/commands/SetTimer.htm

Various working scripts and links here:
https://autohotkey.com/board/topic/2016 ... ific-time/
(You could have googled yourself no doubt)

Task scheduler didn't work, I tried this approach before posting my question.
I'm currently doing extensive research online and reading the documentation about settimer in ahk docs.
Without getting into so much details, the powershell command (populating lot of data in excel) it works when the user is logged in to the computer but it doesn't work when the computer is unsupervised (by design set by Microsoft)
Powershell populating data in excel is not the only thing i need there are some calculations that need to be calculated after the data gets populated and that's why I need to open the file and populate the data so excel calculation engine is triggered.

Thank you
Guest

Re: Run AutoHotKey daily at specific time

19 Jul 2018, 11:04

You may need to run it as administrator - (see Runas or the admin stettings of task scheduler)
Do you need powershell? You can automate Excel using COM with AHK directly (so starting ahk to launch powershell to automate excel seems a bit overkill as you can probably take powershell out of it)
See http://the-automator.com/excel-autohotkey/ for many excel tuts
Codernator
Posts: 3
Joined: 19 Jul 2018, 09:05

Re: Run AutoHotKey daily at specific time

19 Jul 2018, 11:11

Guest wrote:You may need to run it as administrator - (see Runas or the admin stettings of task scheduler)
Do you need powershell? You can automate Excel using COM with AHK directly (so starting ahk to launch powershell to automate excel seems a bit overkill as you can probably take powershell out of it)
See http://the-automator.com/excel-autohotkey/ for many excel tuts

I'm not sure if this is going to work.
I have been testing with ahk and it seems I can't run ahk on a locked computer!!!
if that's the case, this will definitely not work for whatever I'm trying to do.
it took me couple days to write this powershell script i'm 99% done
I'm at the point where I have to hook it up to my task scheduler and let it run but i couldn't because Microsoft doesn't let me automate excel on unsupervised computer, it's by design for all (microsoft office apps)
iPhilip
Posts: 822
Joined: 02 Oct 2013, 12:21

Re: Run AutoHotKey daily at specific time

20 Jul 2018, 12:29

Does this work for you?

Code: Select all

#NoEnv

SetTimer, Timer, % 60*1000 ; Runs once a minute
Return

Timer:
if (A_Hour = "01" && A_Min = "00")
{
   Run PowerShell.exe
   Sleep, 3000 ;3 Seconds
   Send,
   (
    & "C:\Users\MyUserName\OneDrive - For Business\Company\PowerShell\Update-Data.ps1"

    Sleep -Seconds 5

    Exit
   )
   Send, {Enter}
}
Return
Cheers!
Windows 10 Pro (64 bit) - AutoHotkey v2.0+ (Unicode 64-bit)

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], kingina and 215 guests