Zohar Posted April 9 Posted April 9 (edited) Hi all Imagine this scenario: Firefox is running and is the active window, the clipboard has a URL that we wish the browser to navigate to, and now we need Firefox to initiate the "Paste and Go" MenuItem - which will do that. Instead of sending a RightClick, and then moving with the Arrow Keys to appropriate MenuItem, and then simulating en [Enter], maybe there's a way to spare this part, and initiate that MenuItem via a Windows Message? I tried using Spy++ to find such a message, but couldn't. There are 2 possibilities here: 1) There isn't such a Windows Message that is Sent for that MenuItem 2) There is a Windows Message that is Sent for that MenuItem, but I am just not finding it Can anyone please try and see if he gets any success with that? If this is not possible, might there be another way which I could make Firefox navigate to a URL (which is in the Clipboard, or in a Variable), other than the above mentioned way, and without installing a plugin? Thank you Edited April 9 by Zohar
ioa747 Posted April 9 Posted April 9 WinActivate("[CLASS:MozillaWindowClass]") WinWaitActive("[CLASS:MozillaWindowClass]", "", 3) Send("{F6}") ; Navigate using F6 Sleep(100) ; Small delay to ensure the address bar is focused Send("^v") ; Ctrl + V to paste Send("{ENTER}") ; Go I know that I know nothing
Zohar Posted April 9 Author Posted April 9 Thank you ioa747 That's actually what I currently use (or to be more accurate, I use Ctrl-L instead of F6, since it's more reliable) Yet this way is problematic: If the page is slow, it affects the time it takes the F6/Ctrl-L focus to happen. That's why I wish to use the "Paste and Go" menuItem, but hopefully, without opening it and selecting the MenuItem, and instead, activating it via a SendMessage().. (if one exists.. and that's where I need help)
KaFu Posted April 11 Posted April 11 This opens a new tab in a running FireFox instance for me. ShellExecute(@ProgramFilesDir & '\Mozilla Firefox\firefox.exe', 'https://www.google.com/search?q=AutoIt', '', 'open') WildByDesign 1 OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2025-May-18) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
Nine Posted April 11 Posted April 11 An approach based on UIAutomation : expandcollapse popup; From Nine #include <Constants.au3> #include "CUIAutomation2.au3" Opt("MustDeclareVars", True) Global Const $SELFLAG_TAKEFOCUS = 1 ClipPut("www.google.com") ; for testing purposes Example() Func Example() If Not ClipGet() Then Return SetError(1) ; clip empty Local $oUIAutomation = ObjCreateInterface($sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation) Local $pDesktop, $pCondition, $pChrome, $pBarView, $pAddress, $sText, $pPathValue $oUIAutomation.GetRootElement($pDesktop) Local $oDesktop = ObjCreateInterface($pDesktop, $sIID_IUIAutomationElement, $dtagIUIAutomationElement) $oUIAutomation.CreatePropertyCondition($UIA_ClassNamePropertyId, "Chrome_WidgetWin_1", $pCondition) $oDesktop.FindFirst($TreeScope_Descendants, $pCondition, $pChrome) Local $oChrome = ObjCreateInterface($pChrome, $sIID_IUIAutomationElement, $dtagIUIAutomationElement) If Not IsObj($oChrome) Then Return SetError(2) ; chrome not started $oUIAutomation.CreatePropertyCondition($UIA_ClassNamePropertyId, "LocationBarView", $pCondition) $oChrome.FindFirst($TreeScope_Descendants, $pCondition, $pBarView) Local $oBarView = ObjCreateInterface($pBarView, $sIID_IUIAutomationElement, $dtagIUIAutomationElement) $oUIAutomation.CreatePropertyCondition($UIA_ControlTypePropertyId, $UIA_EditControlTypeId, $pCondition) $oBarView.FindFirst($TreeScope_Descendants, $pCondition, $pAddress) Local $oAddress = ObjCreateInterface($pAddress, $sIID_IUIAutomationElement, $dtagIUIAutomationElement) $oAddress.GetCurrentPropertyValue($UIA_ValueValuePropertyId, $sText) ConsoleWrite("Current Address = " & $sText & @CRLF) $oAddress.GetCurrentPattern($UIA_LegacyIAccessiblePatternId, $pPathValue) Local $oPathValue = ObjCreateInterface($pPathValue, $sIID_IUIAutomationLegacyIAccessiblePattern, $dtagIUIAutomationLegacyIAccessiblePattern) $oPathValue.SetValue(ClipGet()) $oPathValue.Select($SELFLAG_TAKEFOCUS) WinActivate("[CLASS:Chrome_WidgetWin_1]") WinWaitActive("[CLASS:Chrome_WidgetWin_1]") Sleep(500) Send("{ENTER}") EndFunc ;==>Example “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
Zohar Posted April 11 Author Posted April 11 KaFu: Thank you very much. I indeed considered using the Command Line, but knew that it will open a new tab each time, and for that reason didn't go that way. I need to re-use the existing tab.. Nine: Thank you for this solution. Does UIAutomation require any addon to be installed on Firefox, for communicating with the browser?
Nine Posted April 11 Posted April 11 22 minutes ago, Zohar said: Does UIAutomation require any addon to be installed on Firefox, for communicating with the browser? Nope, you just need this UDF. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
Zohar Posted April 11 Author Posted April 11 Thank you very much Nine. Do you know how this UDF makes Firefox navigate to a URL? After all, If we use AutoIt Window Info Tool on Firefox, we cannot see any controls, since Firefox is using some custom drawing library of their own..
Nine Posted April 12 Posted April 12 Have you tried it ? Or you are too skinny ? Should be same. OFC there is no Win32 controls, that's why I suggested UIAutomation. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now