LoginSignup
1
0

PowerAutomateDesktopでFirefoxにアドオンをねじ込む作業を自動化してみる

Last updated at Posted at 2024-03-28

前提

FirefoxではChromeやEdgeとはことなり、パッケージ化されていないアドオンを読み込んだ場合、Firefoxを完全に終了させると、次回起動時には跡形もなく読み込まれません。このため、Firefoxをクリーン起動するたびに読み込み直す必要があります。

about:debugging#/runtime/this-firefox

image.png

問題

1つくらいならともかく、3つも4つも読み込ませるとなると面倒です。

せっかくの便利なアドオンが面倒だからと使われないのはもったいないですよね。

自動化する

image.png

ソースコード
Variables.CreateNewList List=> manifest_path_list
Variables.AddItemToList Item: $'''C:\\msys64\\home\\path\\to\\somewhare''' List: manifest_path_list
System.RunApplication.RunApplication ApplicationPath: $'''\"C:\\Program Files\\Mozilla Firefox\\firefox.exe\"''' WindowStyle: System.ProcessWindowStyle.Normal ProcessId=> AppProcessId
WAIT 3
UIAutomation.GetWindow.GetForegroundWindow WindowTitle=> WindowTitle WindowInstance=> AutomationWindow
MouseAndKeyboard.SendKeys.FocusAndSendKeysByInstanceOrHandle WindowInstance: AutomationWindow TextToSend: $'''{Control}({T})''' DelayBetweenKeystrokes: 10 SendTextAsHardwareKeys: False
WAIT 2
MouseAndKeyboard.SendKeys.FocusAndSendKeysByInstanceOrHandle WindowInstance: AutomationWindow TextToSend: $'''about:debugging#/runtime/this-firefox{Return}''' DelayBetweenKeystrokes: 10 SendTextAsHardwareKeys: False
WAIT 3
MouseAndKeyboard.SendKeys.FocusAndSendKeysByInstanceOrHandle WindowInstance: AutomationWindow TextToSend: $'''{Tab}{Tab}{Tab}{Tab}{Tab}}{Tab}''' DelayBetweenKeystrokes: 10 SendTextAsHardwareKeys: False
LOOP FOREACH manifest_path IN manifest_path_list
    MouseAndKeyboard.SendKeys.FocusAndSendKeysByInstanceOrHandle WindowInstance: AutomationWindow TextToSend: $'''{Space}''' DelayBetweenKeystrokes: 10 SendTextAsHardwareKeys: False
    WAIT 3
    MouseAndKeyboard.SendKeys.FocusAndSendKeysByInstanceOrHandle WindowInstance: AutomationWindow TextToSend: $'''manifest.json{F4}{LControlKey}({A}){Back}%manifest_path%{Return}''' DelayBetweenKeystrokes: 10 SendTextAsHardwareKeys: False
    WAIT 2
    MouseAndKeyboard.SendKeys.FocusAndSendKeysByInstanceOrHandle WindowInstance: AutomationWindow TextToSend: $'''{Alt}({O})''' DelayBetweenKeystrokes: 10 SendTextAsHardwareKeys: False
    WAIT 3
END
UIAutomation.CloseWindow.CloseByInstanceOrHandle WindowInstance: AutomationWindow

マウス操作は一切使わずキー送信だけで実装しています。これは個人的にPowerAutomateのマウス操作が信用ならないからです。マウスが刺さってないときやRDPされている時の挙動が安定しない傾向にあるように思えます。

manifest.jsonを選択する画面では、最初にファイル名をいれる場所にフォーカスがあたっているのでまずmanifest.jsonと記入してから、 F4 キーでアドレスバーにフォーカスを当てて指定のパスに移動して、Alt + Oで読み込ませてます。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0