Why are clipboard functions so unreliable in AHK?
Why are clipboard functions so unreliable in AHK?
It's driving me absolutely mad, there's no reason it should be like that, it's 2016..
Re: Why are clipboard functions so unreliable in AHK?
Is there a question?
Post your code.
The clipboard is reliable if you understand how it works and write your code accordingly.
Post your code.
The clipboard is reliable if you understand how it works and write your code accordingly.
Re: Why are clipboard functions so unreliable in AHK?
It's not AutoHotkey that doesn't work. It's more likely you failing to understand how the ClipBoard works or your target appllication messing up.
Recommends AHK Studio
-
- Posts: 1259
- Joined: 16 Apr 2015, 09:41
Re: Why are clipboard functions so unreliable in AHK?
Make sure you are giving your computer time to actually copy or paste.
For example...
With the above code, pressing F12 will often result in something like the following sequence on my system...
1. AHK stores the title of the currently active window.
2. AHK tells Windows that Ctrl+C was pressed.
3. AHK tells Windows to activate a Notepad window.
4. Windows recognizes that Ctrl+C was pressed.
5. Windows stores text onto the clipboard.
6. AHK tells Windows that Ctrl+V was pressed.
7. Windows activates the Notepad Window.
8. AHK tells Windows to activate the original window.
9. Windows recognizes that Ctrl+v was pressed.
10. Windows activates the original window.
11. Windows pastes the clipboard contents.
Due to delays in response time in Windows, the paste is often done after the window has switched back, instead of before as one would expect.
Changing the code to something like the following is the easiest way to work around these delays...
There are more complicated methods of course. A search of these forums will help you find them. As a hint, they generally involve the ClipWait command.
For example...
Code: Select all
f12::
WinGetTitle, CurrentWindow
Send ^c
WinActivate, Ahk_exe Notepad.exe
Send ^v
WinActivate, %CurrentWindow%
Return
1. AHK stores the title of the currently active window.
2. AHK tells Windows that Ctrl+C was pressed.
3. AHK tells Windows to activate a Notepad window.
4. Windows recognizes that Ctrl+C was pressed.
5. Windows stores text onto the clipboard.
6. AHK tells Windows that Ctrl+V was pressed.
7. Windows activates the Notepad Window.
8. AHK tells Windows to activate the original window.
9. Windows recognizes that Ctrl+v was pressed.
10. Windows activates the original window.
11. Windows pastes the clipboard contents.
Due to delays in response time in Windows, the paste is often done after the window has switched back, instead of before as one would expect.
Changing the code to something like the following is the easiest way to work around these delays...
Code: Select all
f12::
WinGetTitle, CurrentWindow
Send ^c
Sleep 250
WinActivate, Ahk_exe Notepad.exe
Send ^v
Sleep 250
WinActivate, %CurrentWindow%
Return
Re: Why are clipboard functions so unreliable in AHK?
Stupid idiots whine.
Smart people explain issues, theorize and finds solutions or workarounds.
Clipboard works flawlessly here in the scripts I've been using it for.
Smart people explain issues, theorize and finds solutions or workarounds.
Clipboard works flawlessly here in the scripts I've been using it for.