Clipboard unvisible items

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
roeleboele
Posts: 33
Joined: 24 Nov 2022, 02:39

Clipboard unvisible items

17 Apr 2024, 04:16

Hello

I have a script that copies value to an array, the value is empty but if i want to test ii, he copied something although i can't see it and in the array there are ""
It tested it with couple methods but non of them give me the answer to tell me that the value is empty
I tried it with
- UIIA (value functon, and the setfocus function and then copy the thing)
- an condition if (A_Clipboaerd = "")
- an condition if (A_Clipboaerd == "")
-Clipwait
- tried to replace `r of `n of the A_clipboard (there are no invisible enters or new lines )

nothing seems to work

Anyone with an other idea

The code is very simple

Code: Select all

Clipboard := ""
Send ^c
var := A_clipboard ; this is an empty field
if (var = "")
	msgbox "Empty"
Thanks a lot
Last edited by gregster on 18 Apr 2024, 02:46, edited 2 times in total.
Reason: Moved back to v2 help since this is actually a v2 help request (see below).
User avatar
mikeyww
Posts: 27140
Joined: 09 Sep 2014, 18:38

Re: Clipboard unvisible items

17 Apr 2024, 04:48

Hello,

Your post is vague. You have not indicated what you have selected, what should be copied, what your script does, and what your script should do. No examples are provided.

The clipboard requires significant time to populate, but a script has nothing inherent that will wait for that to happen before proceeding. To the rescue, AHK does have a command that will wait for data to populate the clipboard. Try :arrow: ClipWait. An example is also provided for you there.

You have posted a v1 script in the v2 forum. Your script suggests that you are mixing syntax, but AHK does not actually handle that. It does not affect this v1 script but might affect other scripts that you write.

V1's original clipboard variable was Clipboard. A_Clipboard was added later and then also subsequently fixed. Whether it works in your v1 script will depend on what version of AHK you are running. Why your script uses both Clipboard and A_Clipboard is unclear.

Instead of using a new variable and an If statement, you can simplify your script by displaying the value of the clipboard after it is populated.

Changelog
just me
Posts: 9509
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Clipboard unvisible items

17 Apr 2024, 06:45

Code: Select all

Clipboard := ""
doesn't clear A_Clipboard ;)
User avatar
mikeyww
Posts: 27140
Joined: 09 Sep 2014, 18:38

Re: Clipboard unvisible items

17 Apr 2024, 07:12

Thank you, just me!

I stopped using A_Clipboard in v1 due to some issues like this. This might not be a bug but can create confusion or unexpected results. Problems in v1 are no longer being corrected through updates to AutoHotkey.

Nonetheless, please note the following.

Code: Select all

#Requires AutoHotkey v1.1.37.02
Clipboard := 5
Sleep 900
A_Clipboard := 6
Sleep 900
Clipboard := ""
Sleep 900
MsgBox % A_Clipboard
image240417-0816-001.png
Output
(8.23 KiB) Downloaded 89 times

viewtopic.php?f=14&t=125044
just me
Posts: 9509
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Clipboard unvisible items

17 Apr 2024, 07:35

mikeyww wrote:You have posted a v1 script in the v2 forum.
@mikeyww, sorry, I missed that.
roeleboele
Posts: 33
Joined: 24 Nov 2022, 02:39

Re: Clipboard unvisible items

18 Apr 2024, 02:11

My script is certain in v2
the #Requires AutoHotkey v2+ is on thet top of my script

I was just typing it, i should copy it instead

Eather way, if found an woraround
I use the uIA function GetCurrentDocumentElement().DumpAll() and dump it all to an txt-file
I read the line where the items are and use an strlen to get the length. if the length is greater then 5 for example then i know there is something in the clipboard
thanks anyway
Here the code

Code: Select all

cUIA.Navigate(kol[2]) 
cUIA.WaitPageLoad("Change column", ,2500 , 2)
A_Clipboard := cUIA.GetCurrentDocumentElement().DumpAll()
FileEncoding "UTF-16"
FileAppend A_Clipboard, individueleKolomBestand
					
i := 1
i := telAantalLijntjes(individueleKolomBestand) ; counts the lines in the file individueleKolomBestand
startindex := i - 9 ; the line i need
Loop read, individueleKolomBestand
{
	if (A_Index = startindex)
	{
		tekstje := StrSplit(A_LoopReadLine,"Type")
		zoeklengte := StrLen(tekstje[2])
		inhoud := StrSplit(tekstje[2],"`"")
		if (zoeklengte = 5)
		{
			beheerdeMetaDataArr.Push([kol[1],kol[2],"N",inhoud[2]])
		}
		else
		{
			beheerdeMetaDataArr.Push([kol[1],kol[2],"J",inhoud[2]])
		}
}
}
gregster
Posts: 9070
Joined: 30 Sep 2013, 06:48

Re: Clipboard unvisible items

18 Apr 2024, 02:42

roeleboele wrote:
18 Apr 2024, 02:11
My script is certain in v2
the #Requires AutoHotkey v2+ is on thet top of my script
Well, we don't know your actual script and have to go with the information provided. We actually encounter a lot of v1 questions which are initially posted in the v2 help subforums.
When I moved your script, I based that mainly on Send ^c which would error out in v2 because quotes are missing, and the use of clipboard - which was renamed in v2 (while your script can be executed in v1).

I'll move it back to v2 help but this shows that more care for details in the initial help request would reduce misunderstandings, delays and possibly frustrations for everyone involved.

Return to “Ask for Help (v2)”

Who is online

Users browsing this forum: Descolada, joedf, kunkel321 and 37 guests