Jump to content

How to check text without using Clipboard?


Recommended Posts

So I have this script (it's not the entire script, but it will do):

WinActivate("[CLASS:phpdesktop-chrome]", "")

Mouseclick("Left",591, 398, 2, 0)
Sleep(250)
MouseClick("right",591,398)
Sleep(250)
MouseClick("left",630,414)
Sleep(250)

$String = "60a8d8"; Change test to what your looking to find in the clipboard.
    $Result = StringInStr(ClipGet(), $String)

    If $Result > 0 Then

Local $Magick = 'magick convert "C:\Users\ME\Desktop\Folder\photo.jpg" -fuzz 40% -fill "#ffffff" -opaque "#000000" "photo1.png"'
RunWait(@ComSpec & " /c " & $Magick)

Sleep(4000)

MouseClick("left",1500,246)
Sleep(250)
MouseClick("left",738,462)
Sleep(250)
Send("text")

Sleep(2000)

The script selects some text, copies it to clipboard, then checks if the contents of the clipboard are "60a8d8," and if they are then it executes the rest of the script.

My problem is with this line:

$Result = StringInStr(ClipGet(), $String)

The situation is that I have AutoIT working on another PC, and I have Anydesk open to watch that PC. But whenever something is copied to that PC's clipboard, it also gets copied to my lap top's clipboard, and it interferes with my work. I do a lot of copy/pasting in my work, and I can't have my clipboard just randomly populated with content from the PC I have open with Anydesk.

So anyway, I need a way to not use "ClipGet." I did a few google searches and found nothing. Can AutoIT use something like this for example?

$Result = StringInStr(SelectedTextGet(), $String)

So instead of reading the clipboard, just read the selected text on the screen (without copying it to clipboard).

Is it possible?

Thanks :)

Edited by Scorpys
Link to post
Share on other sites

You could store the original clipboard text before copying and then put the original text back once you've done what you need to with the clipboard?

Local $sOriginalText = ClipGet() ; Get the clipboard text before copying

WinActivate("[CLASS:phpdesktop-chrome]", "")

; I assume the copying is done starting here?
Mouseclick("Left",591, 398, 2, 0)
Sleep(250)
MouseClick("right",591,398)
Sleep(250)
MouseClick("left",630,414)
Sleep(250)
; ending here

$String = "60a8d8"; Change test to what your looking to find in the clipboard.
    $Result = StringInStr(ClipGet(), $String)

ClipPut($sOriginalText) ; Put the original clipboard text back in the clipboard

    If $Result > 0 Then

Local $Magick = 'magick convert "C:\Users\ME\Desktop\Folder\photo.jpg" -fuzz 40% -fill "#ffffff" -opaque "#000000" "photo1.png"'
RunWait(@ComSpec & " /c " & $Magick)

Sleep(4000)

MouseClick("left",1500,246)
Sleep(250)
MouseClick("left",738,462)
Sleep(250)
Send("text")

Sleep(2000)

There would be a brief (< 1 second) period where the clipboard isn't the original text however.

Link to post
Share on other sites

Thanks for the reply :)

Unfortunately that doesn't work for me. I need to take the clipboard completely out of the equation. It's not about the contents of the clipboard, it's about a change to the clipboard.

Let's say there are 2 computers and their clipboards are synchronized. I'm using one PC, and the other is doing things automatically. Any change to the clipboard of either computer would update the clipboard on the other PC also, and I can't have that.

Can't AutoIT do like a temporary read of currently active selected text without needing to store it somewhere?

Link to post
Share on other sites

It's not from a browser. The text is located on a program called "PHP Desktop". It's just a very old program which allows me to run a php script. So it's not a browser.

Here:

32323.PNG.344ba19459f10cc38664eed1a675095f.PNG

 

See, it's just text. Ancient text on an ancient program.

I selected the 3rd on from the top. What my AutoIT script does is it goes through the texts there one by one, starting from the top. When and if it finds "60a8d8", it does certain actions.

Link to post
Share on other sites
2 minutes ago, Luke94 said:

Search the forum for UI Automation. You may be able to access the controls that way.

Oh my God 😁

I thought it would be something simple, like turning this:

$Result = StringInStr(ClipGet(), $String)

Into this:

$Result = StringInStr(SelectedTextGet(), $String)

Or something like that...

But if I have to read 7 books and graduate 3 universities to do it, forget about it 😄

Anyway I plan to replace this entire part of my script with something that works internally with commands, without having to click on coordinates on the screen and all that. So I guess I'll just turn off the "Clipboards synchronized" option in Anydesk until then. Should solve my problem for now.

Now managing to find a way to read an image, extract the colors from it, list their hex codes, and then check them one by one until you find one of the two, in order to determine which actions to take, and do it all using commands, that's gonna be hard 😅

Link to post
Share on other sites
Quote

Now managing to find a way to read an image, extract the colors from it, list their hex codes, and then check them one by one until you find one of the two, in order to determine which actions to take, and do it all using commands, that's gonna be hard 😅

I don't think that's too hard, believe it or not. Take a look at the example for _GDIPlus_BitmapGetPixel. Think it's a long process looping through each pixel but it'll work.

Link to post
Share on other sites

Anydesk does have a text file I was thinking you would be able to edit in realtime located in %Appdata%\Roaming\Anydesk\system.conf but it appears process needs to be restarted for it to take effect if edited from outside the interface.. 

Edited by bobomb
Link to post
Share on other sites

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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...