Autohotkey Not Auto - autohotkey

Running AutoHotKey Version 3.0.06.01 with Win 10 Version 10.0.19043 Build 19043 on a System SKU LENOVO_MT_81CU_BU_idea_FM_YOGA 730-15IKB laptop.
I have read many postings about AHK not performing as expected on Win10 OS. I have followed those instructions: rebooting, uninstall/reinstall, changing UAC settings, using run as admin , checking virus software -- et al.
I am very new and have only attempted very rudimentary scripts: Send Hello World, Msgbox Hello World and the like. Those seem to work fine by simply selecting the indicated hot keys. However,
The problem: when attempting use [Run] EG.
^j:: Run Notepad.exe or ; an executable
^1:: Run C:\HamSphere\UnaMas.xlsm ; a file
I must
1. select the saved file
2. right click and select run script
3. (the hotkeys icon displays in the tray)
4. then select the indicated hot keys
in order for the script to run as expected. I cannot simply select the indicated hotkeys. Compiling the file doesn't help.
Question: is this normal? If so, it seems like it defeats the purpose of hot keys.
TIA
doco

Apparently,
1. right clicking the *.ahk file and selecting the [Run Script] menu item
2. compile the script to an executable then double click that executable
will cause script to be ready and running in the background as evidenced by the green icon in the tray. This then allow use of whatever hotkeys defined in the script, to run.
The scripts will automatically end when windows closes or the user right clicks the associated image and selects [Exit] from the subsequent drop down.
Kind of a toss-up to actually going and getting the exe/file.

You don't need to compile scripts.
There are 3 main options for getting your scripts executed on start.
Startup folder.
Scheduled tasks.
"AutoHotkey.ahk": The program looks for a script file called AutoHotkey.ahk in the following locations, in this order:
The directory which contains the AutoHotkey executable.
The current user's Documents folder.
And if you don't want your file to be called AutoHotkey.ahk you could for example save it somewhere else and call it with Run from AutoHotkey.ahk.

Related

Powershell scripts doesnt work when running from specific folder

I have a simple script which only prints "hello" to the screen.
When I run it from my desktop (for example) - it's working
When I run it from a specific folder under, c:\specific_folder it opens the "How do you want to open this file" window and even after I choose "Windows Powershell" it just keep popping up and script never executed..
I'm using Powershell version 5.1
I checked the permissions on folder properties and give everyone a full control but no change..
EDIT:
the script is:
Write-output "Hello"
pause
I run it by double clicking it (manually).
Can you help?
Thanks
If you are double clicking it, it might be executing and instantly closing as the script has finished.
You might want to add something like read-host or sleep(1) to the end just to be able to confirm the script is working

Eclipse Run not asking how to run as, and opens wrong file

I'm brand new to learning Python and am using Eclipse to go through a Python course. When I first started doing exercises in Eclipse, every time I opened a file from the course examples, the first time I ran it I would click the green "run" button, and it would ask me how I wanted to launch the file (as Python Run or Python Unit Test). Somewhere along the way it stopped doing that and now if I open a file that has never been run before, when I click the green run button, it just runs a different file. I can click through the drop down menus to run as and select python module and then the run button works fine any time I use that file, but I can't figure out why it won't just run new files the way that it did when I first installed eclipse.
You probably have configured to run the last file... (PyDev asks if you want to do that in a dialog and does that for you if you confirm). Still, don't worry, this is probably for the best anyways as you can just hit F9 to run your file directly without clicking anything (and Ctrl+F11 or clicking the run should now re-run the last launch you did).
Make sure you take some minutes to read http://www.pydev.org/manual_101_run.html for tips on the best way to run Python modules from PyDev.

How to build AHK scripts automatically on startup?

Each time I restart my computer, I have to rebuild all my AHK Scripts so the keyboard shortcuts will work.
For instance, I have a script that assigns Ctrl+j to set up an instance of the MEAN stack and open my web site. After restarting my computer, pressing ^j does nothing until I go into Sublime and ^b (Build). I could build from AHK, but I do a lot of work in Sublime, so it's easier to build there.
How can my AHK Scripts automatically build on startup?
What I've tried so far:
Looking to build a post startup, startup script: This Is concerned with using an AHK script to start many programs on starup. I use Windows' Task Manager > Startup to do this, thus has nothing to do with making. I want to not have to rebuild all my scripts after every restart.
Windows 10 - run script on windows startup problem: This assumes the start script is already written and implemented. However, it doesn't appear to give the script.
AutoHotKey FAQ: I eventually found a solution here, but it took a long time to dig through the questions so I figured I'd post a question anyway to help others who run into this.
Simply add a shortcut (don't need to be the actual file) of your script in the Windows 'Startup' folder.
Three ways to get there:
1- In Windows Explorer, go to %APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup (for current user startup list) or %ALLUSERSPROFILE%\Microsoft\Windows\Start Menu\Programs\Startup (for every user startup list)
or
2- Open Windows' Run application (Windows + r) write shell:startup (current user) or shell:common startup (every user) in the edit field and click on the 'ok' button.
or
3- Start > Programs > Startup (old Windows versions)
In AutoHotKey you can access this folder with the Built-in Variables %A_Startup% (current user) or %A_StartupCommon% (every user)
To create the (current user) shortcut automatically from your script, use the following line:
FileCreateShortcut, %A_ScriptFullPath%, %A_Startup%\shortcutname.lnk
To do the same for all users, use this line instead:
FileCreateShortcut, %A_ScriptFullPath%, %A_StartupCommon%\shortcutname.lnk
(in the case of having a file with the same name in the folder, the file would be overwritten)
ps: Win10 blocks scripts in startup with AHK running as admin... read the comments of this post for extra info.
Run at startup in Windows 10:
Compile the script to *.exe
Put the shortcut of that exe in startup folder "%appdata%\Microsoft\Windows\Start Menu\Programs\Startup"
That's all. Do NOT set it to run as admin. Programs in Win10 don't run at startup which are marked as run as admin.
Run Script as admin at Startup in Windows 10:
Go to ahk script and mark it run as admin.
Create the VBScript using a text editor
'put it in startup folder to run the mentioned ahk script at startup
Set WshShell = CreateObject("WScript.Shell" )
WshShell.Run """C:\Users\jerry\Downloads\scripts\some_script.ahk""", 0 'Must quote command if it has spaces; must escape quotes
Set WshShell = Nothing
Replace C:\Users\jerry\Downloads\scripts\some_script.ahk with the path to your script with extension and save it as .vbs.
Place this .vbs script at startup folder %appdata%\Microsoft\Windows\Start Menu\Programs\Startup
PS: My fav AHK scripts: https://gourav.io/blog/autohotkey-scripts-windows
Open note pad or any other text editor
write Start "" "C:\ahk\yourdirectory\yourahk.ahk"
press save as
navigate to %APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup
name the filename anything.bat
As a Windows 7 user, I have limited experience with Windows 10. I have heard that W10 can be finicky with regard to running programs underground administratie or limited user. In W7, you just add the .AHK file link to the startup dir.
A simple solution without writing any code, using the Windows Task Scheduler, set the script to start when the user logs on. If it is set to system startup it will error because it is too early.
To allow the script to automate administrative programs without running as admin, here're the required steps:
When installing AHK, check the "Add 'Run with UI Access' to context menus" option.
After installation, find AutoHotkeyU64_UIA.exe on your disk.
Open the .ahk script's properties, change the "Open with" option to the AutoHotkeyU64_UIA.exe you just found.
Create a shortcut to this script.
Open %APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup in the file explorer.
Move that shortcut to this folder.
And you're done.
How does it work?
The "Add 'Run with UI Access' to context menus" option provides a workaround for common UAC-related issues by allowing the script to automate administrative programs without running as admin.
Reference: Run with UI Access.
Open windows run (win+r) and type “shelll:startup”
Copy paste the ahk file into there
Close the folder
And that‘s all!

Autostart fails to detect default program

Every time my AHK script runs (the Startup folder constains a symlink that points to the file) Windows asks me what program it should use to open the file. Why does this happen?
It sounds like AutoHotkey isn't properly installed? Is it possible you didn't use an installer and are using a Stand Alone version?
To fix:
Either Uninstall/Reinstall latest version of Autohotkey from ahkscript.org
or
Open up Explorer, Right click a file with .ahk, select Open with option, choose a default program, navigate to Autohotkey.exe and choose that program select "always use.." option. If that doesn't fix your problem I'll try and help further.

Global variables and sessions in Developer Studio

Now it starts a session for each file you run. Is there any way to run two files using the same session (and the same global variables) in Eclipse Progress Developer Studio 3.7 (without one file running the other)?
Yes I know global variables should be avoided but that's not the topic.
You can start the Procedure Editor from Developer Studio by clicking the highlighted button.
The Procedure Editor will contain the currently active file from Eclipse. It is running in the progress process from Developer Studio that is used for compilation of the current project. So all files you start this way will be executed using the same process (as long as you do not restart the OpenEdge AVM).
In the Procedure Editor just hit F2 to execute the file. Note that this will only work for procedure files, not for classes.
There is an option in the run configuration to use the project avm instead of starting a new one.
That way subsequent runs will be in the same session.
You'll need to restart the avm to get rid of the context created by those runs
Only if you run it from the char or GUI client, and then it would still be:
run prog1.p.
run prog2.p.
so there's now way to do this w/out having a "stub" program which runs the two programs in sequence.