Issue with launching AHK from Note Pad ++

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
PipeDreams
Posts: 165
Joined: 19 Dec 2015, 00:20

Issue with launching AHK from Note Pad ++

Post by PipeDreams » 01 Jul 2021, 05:28

Whenever I launch this script from NP++ via NP++’s run window using "C:\Program Files\AutoHotkey\AutoHotkey.exe" "$(FULL_CURRENT_PATH)" or just using "$(FULL_CURRENT_PATH)" ImageSearch fails.

However, if I launch the AHK script by double-clicking it from windows explorer, ImageSearch works as expected.

Am I launching it incorrectly from NP++? I don’t understand why the script is not running correctly when it is launched from NP++.
Do I need an addon or something?

Code: Select all

#SingleInstance Force
CoordMode, Pixel, Screen

IfNotExist, %USERPROFILE%\Downloads\HappyFace.jpg
{	UrlDownloadToFile, https://www.autohotkey.com/boards/download/file.php?id=14008, %USERPROFILE%\Downloads\HappyFace.jpg
	SoundBeep, 300, 50
} SplashImage, %USERPROFILE%\Downloads\HappyFace.jpg, A FS12, Image

Loop, 3
{	ImageSearch, X, Y, 0, 0, A_ScreenWidth, A_ScreenHeight, *60 HappyFace.jpg
	If !(ErrorLevel)
	{	MsgBox, Immage Found
		Exitapp
	} SoundBeep, 200, 50
	Sleep, 500
} MsgBox, No Immage Found	
ExitApp

*~Esc::ExitApp
HappyFace.jpg
HappyFace.jpg (2.33 KiB) Viewed 251 times

swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Issue with launching AHK from Note Pad ++

Post by swagfag » 01 Jul 2021, 06:16

check what the errorlevel was. if its 2, ur image wasnt loaded. since ure using a relative path, ull have to have npp also set the starting directory for the launched script(dont ask me how, never used npp)

Post Reply

Return to “Ask for Help (v1)”