startup script not working

Get help with using AutoHotkey and its commands and hotkeys
blk28

startup script not working

18 May 2018, 04:38

I need help in getting my script to start. I want it to run all the time, and start when computer boots up. Running Windows 10 Home.

I want the mouse wheel button to double click. I have tried both of the following scripts (each followed with "return" [keyed, not typed]) -- with a shortcut to the script in my startup folder:

#persistent
MButton::
click middle 2

MButton::
click middle 2

I must have done something wrong, but I can't figure out what I did, or didn't do. Please help.
Rohwedder
Posts: 1511
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: startup script not working

18 May 2018, 09:13

Hallo,
perhaps:

Code: Select all

~MButton::MButton
JDN
Posts: 9
Joined: 09 May 2018, 01:33

Re: startup script not working

18 May 2018, 14:55

There is a most excellent freeware utility called "Startup" written by Mike Lin. Just Google "startup mike Lin" and download it.

Here is one link but I haven't tried it: http://www.majorgeeks.com/files/details ... rsion.html

Managing the startup folder is a real pain in the neck because it is so complicated and difficult to find your startup folder. Mike Lin's utility makes it simple as pie.

For example, on my PC, the startup folder is found under the following path.

"C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup"

Can you believe that you have to remember such a complicated path in order to access the Startup folder yourself? I can't believe Microsoft never provided any easier way. The AHK documentation just says to "Navigate to the Startup folder inside the Programs folder." But, IMO, that is woefully inadequate. You can find the Startup folder under the hidden folder called "C:\ProgramData". But you must first remove its "hidden" attribute. You can do this by using Windows Explorer and selecting "Tools" then "Folder Options" then "View" and specify "Show Hidden files, Foders and Drives".

For these reasons, it is just so much easier to use Mik Lin's Startup utility. P.S. Here is an extract from the FAQ section in the AHK documentation:

How do I put my hotkeys and hotstrings into effect automatically every time I start my PC?

There is a folder in the Start Menu called Startup. If you put a shortcut to your script in that folder, the script will launch automatically every time you start your PC. To create a shortcut:
Find the script file, select it, and press Control-C.
Right-click the Start button (typically at the lower left corner of the screen) and choose "Explore All Users".
Navigate to the Startup folder inside the Programs folder.
From the menu bar, choose Edit -> Paste Shortcut. The shortcut to the script should now be in the Startup folder.

It says "Navigate to the Startup folder inside the Programs folder.: But that is not nearly enough information. "

I am running Windows 7. I can't see any selection called "Explore All Users" and when I try to find the Startup folder myself, I can't find any folder called the "Programs" folder.
There are these 3 folders: "Program Files", "Program Files (x86)" and "ProgramData". The Startup folder is found under the "ProgramData" folder which is a hidden folder by the way.

I strongly recommend that you should use Mike Lin's Startup utility. It's very much simpler than trying to do it for yourself.

In the following thread: https://autohotkey.com/boards/viewtopic ... 92#p218992
Swagfag posted that you can access the Startup folder for an individual user by opening the Run Box (you should be able to do this by pressing Win+r
Then you enter the command: shell:startup
That should open Windows Explorer to the folder "C:\Users\Admin\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup" which is the Startup folder for an individual user of the PC"

Jeeswg then posted that you can access the Startup folder for all users by opening the Run Box (you should be able to do this by pressing Win+r
Then you enter the command: shell:Common Startup
That should open Windows Explorer to the folder "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup" which is the Startup folder for the entire PC (for all users of the PC)
Last edited by JDN on 18 May 2018, 19:58, edited 2 times in total.
garry
Posts: 1565
Joined: 22 Dec 2013, 12:50

Re: startup script not working

18 May 2018, 16:03

tried this ,
add scripts link to a_startupcommon

Code: Select all

run,%a_startupcommon%
and
first line from script shoul'd be =
SetWorkingDir,%a_scriptdir%
lexikos
Posts: 6207
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: startup script not working

18 May 2018, 20:27

JDN wrote:Managing the startup folder is a real pain in the neck because it is so complicated and difficult to find your startup folder.
You've already shown otherwise. It could hardly be easier than running shell:startup.

It is trivial to manage the startup folder from script: use the variable A_Startup or A_StartupCommon, FileCreateShortcut to add items, Loop Files to discover items, and FileDelete to remove items.
The AHK documentation just says to "Navigate to the Startup folder inside the Programs folder."
Not true. It clearly shows two previous steps. The third step is trivial if the first two steps are followed, but that's only possible on Windows XP. See Update startup info for Windows 10 by MakotoE · Pull Request #271.
You can find the Startup folder under the hidden folder called "C:\ProgramData". But you must first remove its "hidden" attribute.
Not true. You can simply type it, or the full path to the startup folder, into the address bar or Run dialog.
You can do this by using Windows Explorer and selecting "Tools" then "Folder Options" then "View" and specify "Show Hidden files, Foders and Drives".
That will not remove any hidden attributes. It will simply show files and folders which have the hidden attribute (but not items with hidden+system unless the respective setting is also changed from default).
garry
Posts: 1565
Joined: 22 Dec 2013, 12:50

Re: startup script not working

19 May 2018, 04:31

filecreateshortcut not worked for me for a_startupcommon , because I'm not admin
this example works
( create a script msgbox_test.ahk example and then a link in a_startupcommon )

Code: Select all

;- run this script as ADMIN
;https://autohotkey.com/docs/commands/Run.htm#RunAs

setworkingdir,%a_scriptdir%

msgbox,ADMIN=%A_IsAdmin%

full_command_line := DllCall("GetCommandLine", "str")
if not (A_IsAdmin or RegExMatch(full_command_line, " /restart(?!\S)"))
{
  try
  {
  if A_IsCompiled
    Run *RunAs "%A_ScriptFullPath%" /restart
      else
    Run *RunAs "%A_AhkPath%" /restart "%A_ScriptFullPath%"
  }
ExitApp
}

;MsgBox A_IsAdmin: %A_IsAdmin%`nCommand line:`n %full_command_line%

f1=%a_desktop%\msgbox_test.ahk   ; create a msgbox example and then a link in a_startupcommon
fx=%a_startupcommon%

IfNotExist,%f1%
{
e4x=
 (LTrim Join`r`n % `
 SetWorkingDir,%a_scriptdir%
 MsgBox, 262208,TEST ,This is a test`nSecondline
 Return
 )
fileappend,%e4x%,%f1%
SplitPath, f1, name, dir, ext, name_no_ext, drive
FileCreateShortcut,%f1%,%fx%\%name_no_ext%.lnk             ;- creates a link 
}
run,%a_startupcommon%
exitapp

JDN
Posts: 9
Joined: 09 May 2018, 01:33

Re: startup script not working

19 May 2018, 09:59

Lexicos is entirely correct.

For some reason, I was mistaken in saying that changing that Windows Explorer Folders Option would remove the Hidden attribute. I had spent several hours trying to find the Startup folder on my PC and was only able to do it once I changed that option. But of course that doesn't change the attribute. As Lexicos said, it only enabled me to see the folder when using Windows Explorer.

I thank Lexicos for correcting my errors.

Return to “Ask For Help”

Who is online

Users browsing this forum: Google [Bot], Hellbent and 78 guests