What do I need to learn?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
MileHiDave
Posts: 16
Joined: 10 Dec 2020, 14:36

What do I need to learn?

Post by MileHiDave » 15 Oct 2021, 10:18

Hello,
At work, I have an addon, a temporary addon, that I need to load up if FF closes for whatever reason. This add on is for one of the tools I use everyday, so I have to readd it to the browser.(Or I could learn how to make it a permanent addon but that is for later)

I have some limited experience with AHK so my question is:

If I give a set of steps I need to do, can someone point me to the concepts I need to learn? In that I can go to Joe's videos or YT, or even Udemy if need be to learn out to make a script I can call with a hot key that will do what I need?

The steps are:
Open a new FF tab using Control T
enter about:debugging in the address bar
click This Firefox
Click Load Temporary Add-on...
Either fill in the File Name or click on the file name to select it
Click Ok
Exit/close new tab

The goal is to learn how to do this myself. I just don't know what I need to learn.

Many thanks,
Dave

User avatar
mikeyww
Posts: 26588
Joined: 09 Sep 2014, 18:38

Re: What do I need to learn?

Post by mikeyww » 15 Oct 2021, 11:00

Ideas are below. You can read about the commands. Don't worry; there is plenty to learn!

Code: Select all

file = ....json ; Change as needed
F3::
Run, firefox.exe about:debugging#/runtime/this-firefox
WinWaitActive, Mozilla Firefox ahk_class MozillaWindowClass ahk_exe firefox.exe,, 5
If ErrorLevel
 Return
Sleep, 2000
Send {Tab 6}`n
WinWaitActive, Select manifest ahk_class #32770 ahk_exe firefox.exe,, 5
If ErrorLevel
 Return
SendInput {Text}%file%
; Send `n
Return

MileHiDave
Posts: 16
Joined: 10 Dec 2020, 14:36

Re: What do I need to learn?

Post by MileHiDave » 15 Oct 2021, 12:23

Hello and thank you.

I guess I will be digging into the AHK command syntax yes?

As I wanted to hit F3 and run the script :)

Questions will be coming!!

MileHiDave
Posts: 16
Joined: 10 Dec 2020, 14:36

Re: What do I need to learn?

Post by MileHiDave » 15 Oct 2021, 12:46

Hello Mike,
So am I correct in assuming that the F3:: line will invoke the rest of the script when it is pressed?
I have filled in the path to the json file and added firefox.exe to my PATH as it was not there.

Thanks,
Dave

User avatar
mikeyww
Posts: 26588
Joined: 09 Sep 2014, 18:38

Re: What do I need to learn?

Post by mikeyww » 15 Oct 2021, 13:21

Yes.

MileHiDave
Posts: 16
Joined: 10 Dec 2020, 14:36

Re: What do I need to learn?

Post by MileHiDave » 15 Oct 2021, 14:51

Hello Mike,
Thank you very much for the helping hand!!

The script runs fine. I just need to add it to Joe Glines add to startup script.

Now for a wrinkle:
Let's say I forget to run this and open FF and not via the script.

Code: Select all

file = ....json ; Change as needed
F3::
;Run, firefox.exe about:debugging#/runtime/this-firefox
Send Ctl-T to open a new tab
SendInput about:debugging#/runtime/this-firefox
Send {Tab 6}`n
WinWaitActive, Select manifest ahk_class #32770 ahk_exe firefox.exe,, 5
If ErrorLevel
Return
SendInput {Text}%file%
Send {Enter}
Return
[Mod edit: [code][/code] tags added.]

Is my thought process right here?

User avatar
mikeyww
Posts: 26588
Joined: 09 Sep 2014, 18:38

Re: What do I need to learn?

Post by mikeyww » 15 Oct 2021, 15:00

Easiest thing: try it! Try the original script first. If it failed, try your update next.

You have the right idea. Might need a Sleep somewhere.

MileHiDave
Posts: 16
Joined: 10 Dec 2020, 14:36

Re: What do I need to learn?

Post by MileHiDave » 15 Oct 2021, 15:04

Hi Mike,
Thanks for the reply.

The original script works great so no issues there.

I will let you know how the new script runs.
Dave

User avatar
mikeyww
Posts: 26588
Joined: 09 Sep 2014, 18:38

Re: What do I need to learn?

Post by mikeyww » 15 Oct 2021, 15:17

OK. I mean that the first one might work again, but give it a go.

MileHiDave
Posts: 16
Joined: 10 Dec 2020, 14:36

Re: What do I need to learn?

Post by MileHiDave » 15 Oct 2021, 16:27

Ok so based on your initial script, which runs like a champ, I created an off shoot for when FF is already open:

Code: Select all

<insert file path info here>
F3::
Send ^+T about:debugging#/runtime/this-firefox
WinWaitActive, Mozilla Firefox ahk_class MozillaWindowClass ahk_exe firefox.exe,, 5
If ErrorLevel
        Return
Sleep, 2000
Send {Tab 6}`n
WinWaitActive, Select manifest ahk_class #32770 ahk_exe firefox.exe,, 5
If ErrorLevel
        Return
Sleep, 2000
SendInput {Text}%file%
Sleep, 1000
Send !+o
[Mod edit: [code][/code] tags added.]

I am kind of stuck on the last command once I put the file name in. I have tried:

Code: Select all

!+o
Send {Enter}
Send `n
Where am I going wrong? Or do I need another sleep?
Thanks
Last edited by gregster on 15 Oct 2021, 21:00, edited 1 time in total.
Reason: Please use code tags. Thank you!

User avatar
mikeyww
Posts: 26588
Joined: 09 Sep 2014, 18:38

Re: What do I need to learn?

Post by mikeyww » 15 Oct 2021, 20:02

The original script worked for me in both situations. If it did not work at your end, you could display both of the ErrorLevels to see what they are. I am not sure what your Alt+Shift+O is supposed to do. In any case, you just need to use whatever key sequence you would be using manually. In your testing, I think that debugging would require you to figure out what is happening at each step, to know what should happen next. I think that after sending %file%, you will probably want {Enter} after that.

Post Reply

Return to “Ask for Help (v1)”