Open
Description
Phone numbers usually look like this:
+49-1234-56 78 90
+491234567890
Problem: When you copy the second number to the clipboard (manually or programmatically) and afterwards try to receive it with get_clipboard()
, you will only get 491234567890
instead of +491234567890
(spot the missing +
). The first number is copied as-is.
You might find the following examples useful.
BUG_clipboard.py
:
import ahkpy as ahk
@ahk.hotkey('^p')
def print_clipboard():
print(ahk.get_clipboard())
def test_clipboard(test_str: str):
print('----------')
ahk.set_clipboard(test_str)
ahk.sleep(.5)
clipboard = ahk.get_clipboard()
if clipboard == test_str:
print("OK:", test_str)
else:
print("ERROR:")
print(test_str, "!=")
print(clipboard, type(clipboard))
# Failing:
test_clipboard('+491234567890')
test_clipboard(' +491234567890 ')
test_clipboard('+49.1234567890')
# OK:
test_clipboard('+49.1234.567890')
test_clipboard('+49-1234-56 78 90')
test_clipboard('+49 1234 56 78 90')
test_clipboard('-491234567890')
test_clipboard('Phone: +491234567890')
test_clipboard('+491234567890 x')
It looks like as if somewhere on it's way from AHK to Python the clipboard content get's interpreted as a number (if possible) and as consequence looses it's plus sign.
The following Autohotkey script works fine:
phone := "+491234567890"
clipboard := phone
MsgBox % clipboard
Metadata
Metadata
Assignees
Labels
No labels