HurleyShanabarger Posted October 28, 2017 Posted October 28, 2017 I am able to reprocude the behaviour of the first script when running the second script. I don't believe it is an error in the language or the function. If you accessing the clipboard mulitple times the access to it get sometime rejected. That is why you should stick to a good coding pratice and include fail-safes: Dim $sClip_Act, $sClip_Old ClipPut("12345") While 1 Sleep(5) $sClip_Act = ClipGet() If @error Then ConsoleWrite("Error:" & @tab & @error & @CRLF) ContinueLoop EndIf If $sClip_Act <> $sClip_Old And $sClip_Act Then $sClip_Old = $sClip_Act Beep(800, 100) ConsoleWrite($sClip_Act & @CRLF) ElseIf Not $sClip_Act Then Beep(800, 100) ConsoleWrite("Empty" & @CRLF) EndIf WEnd Run this code and start your second script: you will get "Error: 3" all the time.
AndreyS Posted October 28, 2017 Author Posted October 28, 2017 Thank you very much for your participation, HurleyShanabarger! Yes, of course, constantly flies out: Error: 3 So what's the problem? Why prevents the second script from getting the value of the buffer to the first script? After all, the value of the buffer does not change either the first or the second script. They just read the value of the buffer.
AndreyS Posted October 28, 2017 Author Posted October 28, 2017 (edited) It turns out that simultaneously two scripts can not extract information from the buffer with the function ClipGet(). It is necessary to check constantly an error(if it is 3) and again to launch ClipGet(). Correctly I understood? Edited October 28, 2017 by AndreyS
HurleyShanabarger Posted October 28, 2017 Posted October 28, 2017 (edited) I explained the problem already. If two programs try access the clipboard at the same time, one operation will fail - this not related to AutoIt. Run your second script and open excel, write something into a cell and try to copy it. Most likely you will get an error like this: Edited October 28, 2017 by HurleyShanabarger
AndreyS Posted October 28, 2017 Author Posted October 28, 2017 In my Excel, the paste works without problems, but sometimes when copying, the following error occurs: "the error of clearing the clipboard" and "error opening the clipboard." Once Excel even flew completely. ))) Thank you, HurleyShanabarger, for your time and help! Now it is clear that you will need to track all of your scripts when using ClipGet () error 3/4. I could not assume that you can not read the information from the clipboard at the same time!
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