I used the input recorder to capture a task. If the Chrome tabs are in a different order or size and I run it, the mouse click will be in the wrong location to choose that particular tab. In Power Automate, it selects the right tab without using a mouse click. Is there a way to do with with LA? Thanks!
03-12-2024, 11:50 PM (This post was last modified: 03-12-2024, 11:51 PM by Davider.)
thank you!
I currently have multiple Chrome browser windows open.
Only one Chrome browser window is launched with proxy parameters(@"--proxy-server=socks5://127.0.0.1:1080 chat.openai.com"), and it contains a tab named "Chatgpt"
The other Chrome browser windows do not have any tabs named "Chatgpt."
How can I identify the Chrome browser window launched with proxy parameters?
var w = wnd.find("*Google Chrome", "Chrome_WidgetWin_1", also: o => process.getCommandLine(o.ProcessId, true) is string s && s.Contains(partOfCommandLine)).Activate;
03-14-2024, 05:55 AM (This post was last modified: 03-14-2024, 05:57 AM by Davider.)
I encountered another new issue.
The text on the ChatGPT tab randomly generates, as shown by the red box in the image below. Therefore, I cannot use the tab text to find the window or switch tabs.
However, I noticed that when hovering the mouse over the tab, tooltip text is displayed. This text can serve as an identifier, as shown by the purple box, but I am unable to locate it.
I encountered a complex situation: several web pages opened in the browser, and their tab texts are the same (as shown in the figure below)! https://i.ibb.co/PWxCx2q/TT.gif
I need to switch to the tab containing the text "apikeys" in the address bar,
but it seems that the link in the address bar can only be obtained when selected. Is there a better solution?
// script "Chrome switch to tab by URL.cs" //example print.clear(); varr=Chrome.ActivateTabByURL("*libreautomate.com*")??throw newNotFoundException(); print.it(r.url);
classChrome{ ///<summary>
/// Finds Chrome tab by URL, and activates it. /// Searches in all Chrome windows. ///</summary>
///<param name="url">URL. Format: wildcard expression.</param>
///<param name="activateWindow">Activete the Chrome window. Default true.</param>
///<returns>Tab info; null if not found.</returns>
///<exception cref="Exception">Something failed.</exception>
///<remarks>
/// Temporarily activates each tab (to get its URL) until finds the specified tab. There is no way to avoid it; even Selenium cannot get URL of inactive tabs. ///</remarks> public staticATBUResultActivateTabByURL(stringurl,boolactivateWindow=true) { wildexwx=url; foreach(varwinwnd.findAll("*Google Chrome","Chrome_WidgetWin_1")) { if(_ATBU_Window(w,wx,activateWindow)is{ }r)returnr;
} return null;
}
///<summary>
/// Finds Chrome tab by URL, and activates it. ///</summary>
///<param name="wChrome">Chrome window.</param>
///<param name="url">URL. Format: wildcard expression.</param>
///<param name="activateWindow">Activete the Chrome window. Default true.</param>
///<returns>Tab info; null if not found.</returns>
///<exception cref="Exception">Something failed.</exception>
///<remarks>
/// Temporarily activates each tab (to get its URL) until finds the specified tab. There is no way to avoid it; even Selenium cannot get URL of inactive tabs. ///</remarks> public staticATBUResultActivateTabByURL(wndwChrome,stringurl,boolactivateWindow=true)=>_ATBU_Window(wChrome,url,activateWindow);
03-25-2024, 11:54 PM (This post was last modified: 03-25-2024, 11:55 PM by Davider.)
I'd like to enhance the functionality of the above code.
add a switch in the parameters so that when it can't find a tab with the specified keyword, it opens a new tab with a specified URL. After the webpage has completely loaded, it should return.
Is there a more stable and widely applicable solution than the method of opening a new tab described below, which is only suitable for specific language operating systems?
var e = w.Elm["BUTTON", "新标签页"].Find(3); e.MouseClick();
string url = "libreautomate.com";
var w = wnd.find(1, "* - Google Chrome", "Chrome_WidgetWin_1").Activate();
var e = w.Elm["BUTTON", "新标签页"].Find(3); e.MouseClick();
var e2 = w.Elm["TEXT", prop: "key=Ctrl+L"].Find(3);
e2.MouseClick(); keys.send("Ctrl+A", $"!{url}", "Enter");
// script "Chrome open URL in new tab.cs" stringurl="libreautomate.com"; varw=wnd.find(0,"*Google Chrome","Chrome_WidgetWin_1"); w.Activate(); keys.send("Ctrl+T",100,"!"+url,"Del Enter");
//then find/wait a known UI element in the web page vare=w.Elm["web:LINK","Changes"].Find(15); osdText.showTransparentText("DONE");
I added the following tags, but it still doesn't work.
foreach (var w in wnd.findAll("*Google Chrome", "Chrome_WidgetWin_1")) TO:
foreach (var w in wnd.findAll("*Google Chrome", "Chrome_WidgetWin_1", flags: WFlags.HiddenToo))
04-08-2024, 01:38 AM (This post was last modified: 04-08-2024, 02:28 AM by Davider.)
The following error messages often appear in practical use:
Au.Types.NotFoundException: Not found.
at line 68 in _Chrome.cs, Chrome._ATBU_Window(wnd w, wildex wx, Boolean activateWindow)
at line 40 in _Chrome.cs, Chrome.ActivateTabByURL(String url, Boolean activateWindow)
I encounter these situations while using the code:
1. The Chrome browser window may be minimized.
2. The Chrome browser window may be on the second monitor.
3. There are two Chrome browser windows, each on separate screens (on the first and second monitors).
4. The Chrome browser is not launched.
///<summary>
/// Finds Chrome tab by URL, and activates it. /// Searches in all Chrome windows. ///</summary>
///<param name="url">URL. Format: wildcard expression.</param>
///<param name="activateWindow">Activete the Chrome window. Default true.</param>
///<returns>Tab info; null if not found.</returns>
///<exception cref="Exception">Something failed.</exception>
///<remarks>
/// Temporarily activates each tab (to get its URL) until finds the specified tab. There is no way to avoid it; even Selenium cannot get URL of inactive tabs. ///</remarks> public staticATBUResultActivateTabByURL(stringurl,boolactivateWindow=true)
{ //wildex wx = url; wildexwx=$@"*{url}*"; foreach(varwinwnd.findAll("*Google Chrome","Chrome_WidgetWin_1"))
{ if(_ATBU_Window(w,wx,activateWindow)is{ }r)returnr;
} return null;
}
///<summary>
/// Finds Chrome tab by URL, and activates it. ///</summary>
///<param name="wChrome">Chrome window.</param>
///<param name="url">URL. Format: wildcard expression.</param>
///<param name="activateWindow">Activete the Chrome window. Default true.</param>
///<returns>Tab info; null if not found.</returns>
///<exception cref="Exception">Something failed.</exception>
///<remarks>
/// Temporarily activates each tab (to get its URL) until finds the specified tab. There is no way to avoid it; even Selenium cannot get URL of inactive tabs. ///</remarks> public staticATBUResultActivateTabByURL(wndwChrome,stringurl,boolactivateWindow=true)=>_ATBU_Window(wChrome,url,activateWindow);
After not using inactive tabs, on tab.Invoke Chrome activates the tab but it's blank. To reproduce, need to wait a day.
This workaround seems to work: after tab.Invoke(); insert tab.Focus();.
Another possible reason - a side panel is visible (eg Bookmarks). Then w.Elm["webOCUMENT", prop: "value=?*"].Find(5) finds it instead. Fixed in next LA.
Sometimes, even after numerous tests, there are no errors, but suddenly errors occur. I believe the possible reason for this might be that I have placed some operations in class files. All the code is in one main file. It seems that the probability of encountering problems is very low.
Originally, all my code was in one main file. Later, in order to reuse certain code, I moved it into class files, and then it seems the problem arose...