Clipboard value is not getting updated

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
aviator636
Posts: 1
Joined: 16 Jun 2021, 15:04

Clipboard value is not getting updated

16 Jun 2021, 15:22

I am trying to copy a number from and form paste it on another field after substracting 10 from it , but I get always the older value. sort of runs a loop behind.
No idea why is this happening. Need Help TIA

Code: Select all

`::
setkeydelay,10 
setformat float ,0.2
Send,  ^c
send, {Tab 2}		
rex := clipboard - 10
Send, %rex%
User avatar
mikeyww
Posts: 26891
Joined: 09 Sep 2014, 18:38

Re: Clipboard value is not getting updated

16 Jun 2021, 15:29

It worked in my test. You can debug the script by displaying what is happening at each step. What is on your clipboard after you copy the text?

Add a ClipWait.
Raghava Doregowda
Posts: 130
Joined: 06 Nov 2022, 01:48

Re: Clipboard value is not getting updated

26 Dec 2022, 14:26

@mikeyww No...Even I'm facing the same problem as the author.

If I select a number like 44 and I press ` repeatedly,
Output:
_ 34 34 34 34

The underscore where I have marked actually should print 34 but it doesn't.
Following which, If I select let's say 59,
Output:
34 49 49 49 49

The first input data is getting delayed by a step and that gets hidden as I proceed to fire the hotkey.

Some problem...And it's a huge setback for me...
User avatar
mikeyww
Posts: 26891
Joined: 09 Sep 2014, 18:38

Re: Clipboard value is not getting updated

26 Dec 2022, 16:19

I'm assuming that you added a ClipWait like the other author did. You can post your script in a reply below. Indicate exactly what you do, what happens, & what should happen instead.
Raghava Doregowda
Posts: 130
Joined: 06 Nov 2022, 01:48

Re: Clipboard value is not getting updated

26 Dec 2022, 17:22

mikeyww wrote:
26 Dec 2022, 16:19
I'm assuming that you added a ClipWait like the other author did. You can post your script in a reply below. Indicate exactly what you do, what happens, & what should happen instead.
Please Have a look:

Code: Select all

#IfWinActive Save As ahk_class #32770 ahk_exe notepad.exe
{
 ;User will input all his/her details in the Save as column until they press enter
 Enter::
 Send ^a
 Sleep 100
 Send ^c        
 Clipwait,,1 ;Here's the clipwait. I've made it so that it shouldn't be sent/copied as a blank clipboard.
 ;Send ^c    
 ;Clipwait,,1 ;These 2 statements in semicolons are the temporary fixes. I've had to duplicate (Control C) 2 times to compensate for the missing number I had mentioned in my previous answer and now it works but this kills time a little and also logically looks unnecessary
 texxt1:=Clipboard ;This new variable stores the clipboard which i need later on in my work. 
 Send ^l ; This command will focus on the file address left off the search bar
 Sleep 100
 Send ^a
 Send ^c
 Clipwait,,1
 ;Send ^c
 ;Sleep 300
 ;Clipwait,,1
 texxt2:=Clipboard; Clipboard pushes file address into texxt2 as a string which I will use later on for personal purposes
 Send {Enter}
 ;I open a .txt document now to test/check what the variables contain
 Send %texxt1%;This output is not right. The clipboard stores junk from exactly "one" previous instance of using Control C. If I had not put Send ^c and clipwait 2 times, this would always output the clipboard one process 
 before.
 Send %texxt2% This outputs whatever I intended to put in texxt1. Completely wrong...unless I put Send ^c 2 times...but I don't understand why
 return
}
#ifWinActive

To explain my output, I want to store the user input for File name and the respective file address that he/she stores the file in because it is important info for me to use later.
User avatar
mikeyww
Posts: 26891
Joined: 09 Sep 2014, 18:38

Re: Clipboard value is not getting updated

26 Dec 2022, 19:58

1. If you fail to clear the clipboard, the ClipWait will seldom have any effect. This is explained in the documentation, and an example is provided there.

2. If you are using Send, then why have you set the WaitForAnyData parameter?

What ClipWait does:
Waits until the clipboard contains data.
If you are not sure whether your clipboard has data, you can use your script to find out.

I suggest that you use a timeout so that you can know if something unexpected happens. Does something unexpected ever happen? Our scripts are perfect examples!

My guess is that you believe that ClipWait is waiting, when it is not actually waiting. The script itself can be used to test our own assumptions.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: doodles333, exodus_cl, Sniperman and 369 guests