0
votes

So I am trying to look for a specific text on the webpage and do a thing if the text was found, here is my current script:

!m::
clipboard =  
text = my text here
Send, {Ctrl}+A
Sleep, 100
Send, {Ctrl}+C
var1 = %clipboard%
IfInString, var1, %text%
msgbox found the text
else
msgbox no text found

And regardless if the text is on the webpage or not, it always returns "no text found"

Any help on this?

P.S. I've also tried "if contains" and removing line breaks from the variable but the result is the same :(

StringReplace, var1, var1, `r `n, All
2

2 Answers

0
votes

The send commands are not correct.

A command {Ctrl}+A, will press Ctrl, release it, and then press A. The lower case letter should also be used.

You should use either:

Send, {Ctrl down}{a}{Ctrl up} 

or

Send, ^{a} 

Do this for both Send commands.

A return commend should also be included as the end of the hotkey code sequence:

    ...
    else
    msgbox no text found
return
0
votes

Try this:

!m::
clipboard := "", MyText := "Hello World"
cmds := ["{Ctrl down}", "a", "c", "{ctrl up}"]
Loop % cmds.MaxIndex() {
    Send % cmds[A_Index]
    if (A_index == 2)
        sleep 100
}
MsgBox % clipboard ~= "i)" MyText ? "Found" : "Not Found"