AutoHotkey Permissions

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Alexander2
Posts: 348
Joined: 27 Apr 2019, 17:38

AutoHotkey Permissions

25 Mar 2022, 13:41

When I start Microsoft Outlook manually by clicking on its shortcut, the program automatically signs me in into my Gmail account at startup. But when I start Microsoft Outlook through AutoHotkey’s Run command, Outlook requires me to sign in manually. This may have to do with AutoHotkey’s permissions.

Does anyone know how to start Outlook through AutoHotkey with the highest permissions in order that Outlook may sign me in automatically into the Gmail account at startup?
gregster
Posts: 9113
Joined: 30 Sep 2013, 06:48

Re: AutoHotkey Permissions

25 Mar 2022, 13:55

Just a guess what the actual difference might be: A shortcut usually has information about a working directory for the program it runs.
You can try to add that same working directory as the second parameter of Run. For some programs, it really makes a difference.
Alexander2
Posts: 348
Joined: 27 Apr 2019, 17:38

Re: AutoHotkey Permissions

25 Mar 2022, 14:05

gregster wrote:
25 Mar 2022, 13:55
Just a guess what the actual difference might be: A shortcut usually has information about a working directory for the program it runs.
You can try to add that same working directory as the second parameter of Run. For some programs, it really makes a difference.
The following is the command which I use to start Outlook:

Code: Select all

run % """C:\Program Files\Microsoft Office\root\Office16\OUTLOOK.EXE"""
Can you explain what exactly has to be added or changed?
User avatar
boiler
Posts: 17399
Joined: 21 Dec 2014, 02:44

Re: AutoHotkey Permissions

25 Mar 2022, 14:52

The suggestion is to add its directory as the second parameter, which is the WorkingDir parameter:

Code: Select all

Run, "C:\Program Files\Microsoft Office\root\Office16\OUTLOOK.EXE", C:\Program Files\Microsoft Office\root\Office16

By the way, I'm usually a big proponent of using expression syntax over legacy syntax, but I don't see the advantage of forcing an expression for the first parameter in this case, so I showed it using legacy syntax (as I did for the second parameter).
Alexander2
Posts: 348
Joined: 27 Apr 2019, 17:38

Re: AutoHotkey Permissions

26 Mar 2022, 13:37

boiler wrote:
25 Mar 2022, 14:52
The suggestion is to add its directory as the second parameter, which is the WorkingDir parameter:

Code: Select all

Run, "C:\Program Files\Microsoft Office\root\Office16\OUTLOOK.EXE", C:\Program Files\Microsoft Office\root\Office16
By the way, I'm usually a big proponent of using expression syntax over legacy syntax, but I don't see the advantage of forcing an expression for the first parameter in this case, so I showed it using legacy syntax (as I did for the second parameter).
Thank you. I have tried using the above command, but Outlook still does not sign in automatically when it is launched through AutoHotkey automatically at system startup through the Task Scheduler. (The option “At logon” is selected in the Task Scheduler.)
User avatar
boiler
Posts: 17399
Joined: 21 Dec 2014, 02:44

Re: AutoHotkey Permissions

26 Mar 2022, 13:47

You might want to show all the properties in the shortcut you use manually because it may be passing some arguments to Outlook as it runs it that you could add to your Run command.
Alexander2
Posts: 348
Joined: 27 Apr 2019, 17:38

Re: AutoHotkey Permissions

27 Mar 2022, 12:37

boiler wrote:
26 Mar 2022, 13:47
You might want to show all the properties in the shortcut you use manually because it may be passing some arguments to Outlook as it runs it that you could add to your Run command.
The shortcut is ordinary. It does not have any parameters added.
1.png
1.png (51.79 KiB) Viewed 2372 times
User avatar
MrDodel
Posts: 96
Joined: 28 Apr 2021, 09:03
Location: Event Horizon

Re: AutoHotkey Permissions

27 Mar 2022, 14:47

I think you need to specify the profile in your command line arg:

Code: Select all

C:\Program Files\Microsoft Office\root\Office16\OUTLOOK.EXE /profile "NAMEOFPROFILE"
So much universe, and so little time. GNU Sir Terry.
Alexander2
Posts: 348
Joined: 27 Apr 2019, 17:38

Re: AutoHotkey Permissions

28 Mar 2022, 12:40

MrDodel wrote:
27 Mar 2022, 14:47
I think you need to specify the profile in your command line arg:

Code: Select all

C:\Program Files\Microsoft Office\root\Office16\OUTLOOK.EXE /profile "NAMEOFPROFILE"
Do you mean the Windows user name or the computer name (both of which are chosen during Windows 11 installation)?
Should this name be specified in the Outlook.exe file shortcut or in the AutoHotkey Run command?
User avatar
MrDodel
Posts: 96
Joined: 28 Apr 2021, 09:03
Location: Event Horizon

Re: AutoHotkey Permissions

29 Mar 2022, 05:00

Alexander2 wrote:
28 Mar 2022, 12:40
MrDodel wrote:
27 Mar 2022, 14:47
I think you need to specify the profile in your command line arg:

Code: Select all

C:\Program Files\Microsoft Office\root\Office16\OUTLOOK.EXE /profile "NAMEOFPROFILE"
Do you mean the Windows user name or the computer name (both of which are chosen during Windows 11 installation)?
Should this name be specified in the Outlook.exe file shortcut or in the AutoHotkey Run command?
It's the email profile name, so if you go to control panel, select mail, then the profile tab you can see the name of the profile you have setup in outlook, you then pass that profile name to outlook.exe as shown above.
Attachments
image.png
image.png (17.2 KiB) Viewed 2230 times
So much universe, and so little time. GNU Sir Terry.
Alexander2
Posts: 348
Joined: 27 Apr 2019, 17:38

Re: AutoHotkey Permissions

29 Mar 2022, 13:01

Thank you for the explanation.
The Control Panel shows that that the name of the profile is “Outlook”:
2.png
2.png (20.15 KiB) Viewed 2197 times


I have added the parameter in Outlook’s shortcut:
1.png
1.png (24.24 KiB) Viewed 2197 times
However, Outlook still does not sign in automatically when its shortcut is opened by AutoHotkey at system log on.
User avatar
boiler
Posts: 17399
Joined: 21 Dec 2014, 02:44

Re: AutoHotkey Permissions

29 Mar 2022, 13:36

You didn’t say you were running the shortcut from your AHK script, at least not that I saw. Is that what you are trying now? Can you show that script?
Alexander2
Posts: 348
Joined: 27 Apr 2019, 17:38

Re: AutoHotkey Permissions

30 Mar 2022, 10:34

boiler wrote:
29 Mar 2022, 13:36
You didn’t say you were running the shortcut from your AHK script, at least not that I saw. Is that what you are trying now? Can you show that script?
Yes, I have tried launching Outlook also through its shortcut with the use of AutoHotkey.

I have tried running both of the following commands, but in each instance Outlook does not sign in automatically when it is launched through Autohotkey at system log on:

Code: Select all

run "C:\Program Files\Microsoft Office\root\Office16\OUTLOOK.EXE" /profile Outlook

Code: Select all

run % """C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Outlook.lnk"""
However, Outlook signs in when I launch it with the use of AutoHotkey some time after system log on. It seems that the problem lies with the permissions at system log on, as if AutoHotkey does not have all the permissions immediately after the system starts but gains those permissions some time after the startup.
TrebleTA
Posts: 134
Joined: 20 Nov 2021, 06:44

Re: AutoHotkey Permissions

30 Mar 2022, 12:40

Have you tried shellrun, I'm having the same problem tring to run explorer as the loged in user, when running the script as a admin. Yet shellrun may work for you?
Alexander2
Posts: 348
Joined: 27 Apr 2019, 17:38

Re: AutoHotkey Permissions

31 Mar 2022, 09:54

TrebleTA wrote:
30 Mar 2022, 12:40
Have you tried shellrun, I'm having the same problem tring to run explorer as the loged in user, when running the script as a admin. Yet shellrun may work for you?
I can try using this command. How can this command be run in an AutoHotkey script to launch Outlook with the specified profile name?
TrebleTA
Posts: 134
Joined: 20 Nov 2021, 06:44

Re: AutoHotkey Permissions

31 Mar 2022, 19:52

Try here, were I see info. viewtopic.php?t=92700
Also my topic almost about the same problem here
viewtopic.php?t=102099

Also how do you start via task scheduler, what user, are you run with highest privileges, as could be due to this. To start outlook it would need ahk to be running as that user with standard privileges. Also you can add a delay to the task start like 5seconds or more.
Running as a admin then as x users profile may be the problem

Sorry for the edit, it's late.
Alexander2
Posts: 348
Joined: 27 Apr 2019, 17:38

Re: AutoHotkey Permissions

01 Apr 2022, 10:53

Try here, were I see info. viewtopic.php?t=92700
Also my topic almost about the same problem here
viewtopic.php?t=102099
Thank you for the information. Since I do not have much programming knowledge, I do not understand what is stated in those threads. Perhaps there may be a simpler way to run Outlook normally.
Also how do you start via task scheduler, what user, are you run with highest privileges, as could be due to this. To start outlook it would need ahk to be running as that user with standard privileges.
The following are the parameters in the Task Scheduler:
1.png
1.png (32.53 KiB) Viewed 1907 times
2.png
2.png (31.62 KiB) Viewed 1907 times
3.png
3.png (21.99 KiB) Viewed 1907 times
The option “Run with the highest privileges” is checked because the AutoHotkey script runs at system log only when this option is selected.
Also you can add a delay to the task start like 5seconds or more.
The delay is already added in the AutoHotkey script. The script launches Outlook more than a minute after the script is run. But Outloook still does not sign in automatically.
User avatar
tank
Posts: 3130
Joined: 28 Sep 2013, 22:15
Location: CarrolltonTX
Contact:

Re: AutoHotkey Permissions

01 Apr 2022, 14:39

seems you might try the RunAs command for your script to apply the correct user context. the scheduled task causes an administrative context to the script which needs to be specific to the current user
We are troubled on every side‚ yet not distressed; we are perplexed‚
but not in despair; Persecuted‚ but not forsaken; cast down‚ but not destroyed;
Telegram is the best way to reach me
https://t.me/ttnnkkrr
If you have forum suggestions please submit a
Check Out WebWriter
TrebleTA
Posts: 134
Joined: 20 Nov 2021, 06:44

Re: AutoHotkey Permissions

01 Apr 2022, 16:27

In picture 2 edit trigger, delay task for put 30 seconds. See if that works else can try this

Code: Select all

/*
  ShellRun by Lexikos
    requires: AutoHotkey v1.1
    license: http://creativecommons.org/publicdomain/zero/1.0/

  Credit for explaining this method goes to BrandonLive:
  http://brandonlive.com/2008/04/27/getting-the-shell-to-run-an-application-for-you-part-2-how/
 
  Shell.ShellExecute(File [, Arguments, Directory, Operation, Show])
  http://msdn.microsoft.com/en-us/library/windows/desktop/gg537745
*/
ShellRun(prms*)
{
    shellWindows := ComObjCreate("Shell.Application").Windows
    VarSetCapacity(_hwnd, 4, 0)
    desktop := shellWindows.FindWindowSW(0, "", 8, ComObj(0x4003, &_hwnd), 1)
   
    ; Retrieve top-level browser object.
    if ptlb := ComObjQuery(desktop
        , "{4C96BE40-915C-11CF-99D3-00AA004AE837}"  ; SID_STopLevelBrowser
        , "{000214E2-0000-0000-C000-000000000046}") ; IID_IShellBrowser
    {
        ; IShellBrowser.QueryActiveShellView -> IShellView
        if DllCall(NumGet(NumGet(ptlb+0)+15*A_PtrSize), "ptr", ptlb, "ptr*", psv:=0) = 0
        {
            ; Define IID_IDispatch.
            VarSetCapacity(IID_IDispatch, 16)
            NumPut(0x46000000000000C0, NumPut(0x20400, IID_IDispatch, "int64"), "int64")
           
            ; IShellView.GetItemObject -> IDispatch (object which implements IShellFolderViewDual)
            DllCall(NumGet(NumGet(psv+0)+15*A_PtrSize), "ptr", psv
                , "uint", 0, "ptr", &IID_IDispatch, "ptr*", pdisp:=0)
           
            ; Get Shell object.
            shell := ComObj(9,pdisp,1).Application
           
            ; IShellDispatch2.ShellExecute
            shell.ShellExecute(prms*)
           
            ObjRelease(psv)
        }
        ObjRelease(ptlb)
    }
}
; ------------ here you put your run line ----------
ShellRun("outlook.exe /profile")

The first part of the code is to get your command to run as a user. Just not sure if it will work. The bottom command can then be put in your script to replace the run.
TrebleTA
Posts: 134
Joined: 20 Nov 2021, 06:44

Re: AutoHotkey Permissions

01 Apr 2022, 16:30

Or shellrun("outlook.exe")

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], Mateusz53, MrDoge, peter_ahk and 365 guests