Script to add plugin to FF

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
MileHiDave
Posts: 18
Joined: 10 Dec 2020, 14:36

Script to add plugin to FF

Post by MileHiDave » 03 May 2024, 12:58

Hello,

This script should work. I admit, I am still fairly new to V2.

Any pointers as to what I did wrong, or to scripting help, would be appreciated:

Code: Select all

#f::
{If WinExist('ahk_class MozillaWindowClass')
	Send "^T"
	Sleep 500
	SendInput "{Raw}about:debugging#/runtime/this-firefox"

	Sleep 500
	Send "{Tab 6}"
	WinWaitActive ("firefox.exe")
	SendInput  "{Raw}C:\Dir1\Dir2\manifest.json"
	Send "{Enter}"
}		


Thanks,
Dave

[Mod edit: Added [code][/code] tags. Please use them yourself when posting code!]
[Mod edit: Since this is a help request, moved from 'Scripts and Functions'.]
User avatar
boiler
Posts: 17192
Joined: 21 Dec 2014, 02:44

Re: Script to add plugin to FF

Post by boiler » 03 May 2024, 16:05

MileHiDave wrote: This script should work.
Good to be confident, I guess. ;) Several things that I spot:

Don't send a capital letter for ^t because it can cause it to hold Shift as well.

Don't put a space between a function name and the open parenthesis that follows it when calling a function.

This is most likely the showstopper: The process name is not the window title. To use the process name for the WinTitle parameter, it needs to be preceded by ahk_exe:

Code: Select all

	WinWaitActive ("ahk_exe firefox.exe")
In case you're expecting a difference between Send and SendInput, the default Send mode in v2 is already Input, so there's no need to use SendInput as long as you don't change the mode.

Do you realize that the only line that's conditionally executed after the if is the one immediately following it since you didn't group multiple lines into a code block? Your indenting would suggest that you expect everything after it to be conditional.

There may be other issues regarding timing and expecting windows to be come active.
MileHiDave
Posts: 18
Joined: 10 Dec 2020, 14:36

Re: Script to add plugin to FF

Post by MileHiDave » Yesterday, 15:27

The code, I think, should work now but I am still having issues:

Code: Select all

{
if WinExist("ahk_class MozillaWindowClass")
{
	WinActivate
	Send "^t"
	Sleep 500
	Send {Text}"about:debugging{#}/runtime/this-firefox"
	Sleep 500
	;Send "{Tab 6

	Click 866 317
	WinWaitActive ("ahk_exe firefox.exe")
	Send "{Raw}C:\CHCLSNExtensions\HCLSNExtensions\manifest.json"
	Send "{Enter}"
}
}
The codeblock after the if statement should all run. That is my understanding. Not a dev here just an AHK hack wannabe.

I am getting this error:

FF_Addon_FF_Started.ahk (14) : ==> Missing space or operator before this.
Specifically: "about:debugging{#}/runtime/this-firefox")

I have tried double double quotes: ""about:debugging{#}/runtime/this-firefox""
I have tried: "about:debugging`#/runtime/this-firefox"
I have tried Send {Raw} "about:debugging#/runtime/this-firefox"

My google fu is not strong.

Any help is appreciated.

Thanks


[Mod edit: Added [code][/code] tags. Please use them yourself when posting code.]
User avatar
boiler
Posts: 17192
Joined: 21 Dec 2014, 02:44

Re: Script to add plugin to FF

Post by boiler » Yesterday, 15:38

@MileHiDave - Please don't make any more posts that contain code without adding [code][/code] tags! Here is how you do it:
add code tags.png
add code tags.png (14.11 KiB) Viewed 92 times

MileHiDave wrote: The code, I think, should work now but I am still having issues:
You keep saying this as if you feel confident in your grasp of AHK syntax, but the various things you have posted have not met basic expression syntax rules. You have not tried simply putting quotes around the entire literal string as shown in many examples in the Send documentation:

Code: Select all

	Send "{Text}about:debugging#/runtime/this-firefox"

I don't think you really wanted the { } around the #, especially since you specified text mode.

MileHiDave wrote: My google fu is not strong.
Your problem is you're googling instead of starting with the AHK documentation where you would have seen very clear examples on exactly this.
Post Reply

Return to “Ask for Help (v2)”