LarryBenLev Posted February 3, 2021 Share Posted February 3, 2021 The following script should mouse over a location on a webpage, Click and drag, save to the clipboard and then assign the string to a variable. Instead, I break Chrome. Any ideas why? Is AutoIt optimised for MS-WIN Edge? MouseClickDrag($MOUSE_CLICK_LEFT, 870, 198,934,198) Sleep(1000) Send("^C") Sleep(1000) Func Example() ; Retrieve the data stored in the clipboard. Local $sData = ClipGet() ; Display the data returned by ClipGet. MsgBox($MB_SYSTEMMODAL, "", "The following data is stored in the clipboard: " & @CRLF & $sData) ; Add new data to the clipboard. ClipPut("A new string added to the clipboard.") ; Retrieve the data stored in the clipboard. $sData = ClipGet() ; Display the data returned by ClipGet. MsgBox($MB_SYSTEMMODAL, "", "The following data is now stored in the clipboard: " & @CRLF & $sData) EndFunc ;==>Example Link to comment Share on other sites More sharing options...
Danp2 Posted February 3, 2021 Share Posted February 3, 2021 @LarryBenLev No sure what you mean by "break Chrome". Please elaborate. As posted, only the first four lines of your script would run because you never call the Example function. P.S. See here for the proper way to post code on the forum P.P.S. There are better options than using mouse clicks and send to interact with a browser Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
LarryBenLev Posted February 6, 2021 Author Share Posted February 6, 2021 (edited) It turns out that the copy command is case sensitive, so it should be ^c, and not ^C. ^C in both chrome and edge issues a command to the webbrowsers that they don't like and start opening code windows that are way above my abilities. I am using the script to test for specific text to tell me if the page has changed. In short, I am using the script to see if pages for registering for vaccination have changed from saying, "Don't call us, we'll call you." How else would you do it? Also, the Example Func above isn't really used. and apologies, this is my first time back in more than a decade, so I'm blowing out some cobwebs to get this to work.. But how do I call a function? Edited February 6, 2021 by LarryBenLev Link to comment Share on other sites More sharing options...
LarryBenLev Posted February 6, 2021 Author Share Posted February 6, 2021 It turns out that the copy command is case sensitive, so it should be ^c, and not ^C. ^C in both chrome and edge issues a command to the webbrowsers that they don't like and start opening code windows that are way above my abilities. I am using the script to test for specific text to tell me if the page has changed. In short, I am using the script to see if pages for registering for vaccination have changed from saying, "Don't call us, we'll call you." How else would you do it? Also, the Example Func above isn't really used. and apologies, this is my first time back in more than a decade, so I'm blowing out some cobwebs to get this to work.. Link to comment Share on other sites More sharing options...
Danp2 Posted February 6, 2021 Share Posted February 6, 2021 Ctrl+Shift+C in most browsers will open the developer tools. Look at the help file entry for Func for an example of how to properly call the defined function. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
junkew Posted February 8, 2021 Share Posted February 8, 2021 you could also look at alternatives for driving webpages iuiautomation webdriver specific udf's for different browser use javascript in the addressbar see below Javascript in addressbar chrome://extensions/ make sure developer mode is on Start with userscripts turned on "C:\Program Files\Google\Chrome\Application\chrome.exe" –-enable-user-scripts type in addressbar: javascript:alert("hello world"); javascript:alert(document.body.innerText); and then you can make the javascript as complex as you want (you have to make it one liners) function copytext(text) { var textField = document.createElement('textarea'); textField.innerText = text; document.body.appendChild(textField); textField.select(); document.execCommand('copy'); textField.remove(); } FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
Danp2 Posted February 8, 2021 Share Posted February 8, 2021 Depends on the website, but you may also be able to use a function like _INetGetSource to read in the web page and then search the resulting string. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
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