Jump to content

Recommended Posts

Posted

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
 

Posted (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 by LarryBenLev
Posted

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.. 

Posted

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

  1. chrome://extensions/  make sure developer mode is on
  2. Start with userscripts turned on
    "C:\Program Files\Google\Chrome\Application\chrome.exe" –-enable-user-scripts
  3. type in addressbar:  javascript:alert("hello world");
  4. 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();
}

 

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...