How to extract texts displayed in MsgBox without the markers?
Posted: 06 Apr 2020, 11:40
Can I add some option to MsgBox, so that I can Copy (with ctrl+v) from its message box ONLY the input that I have fed to it? For now, I am using Vim macros to clean up the markers around the real contents of interest. A typical clipboard content obtained by pressing ctrl+v in a MsgBox window:
---------------------------
ahk_master.ahk
---------------------------
"XXXXXX___This_Line_is_of_interest_XXXXXX"
---------------------------
OK
---------------------------
From the documentation page for MsgBox, there is a tip mentioning: "Tip: Pressing ctrl+c while a MsgBox window is active will copy its text to the clipboard. This applies to all MsgBoxes, not just those produced by AutoHotkey." ==> Yet, as shown above, the copied contents are formatted with window_title and an OK button, along with a few horizontal divider lines. The following subroutine can reproduce the message above. (I would like to keep the "OK" button to make sure the MsgBox won't go away before I get a chance to *copy* from it for its text.)
Background: I find a potential problem with updating the clipboard using some existing variables. The characters with GBK encoding (Chinese characters) are "clipped" wrongly. The variables themselves were displayed normally when rendered through MsgBox. Yet, pasting from ClipBoard with ctrl+v after refreshing the clipboard with Clipboard := var_content shall replace all the GBK-encoded characters with one or two question mark(s). Since the problem appears to be with GBK-characters only, I have posted here and here in the Chinese forum.
---------------------------
ahk_master.ahk
---------------------------
"XXXXXX___This_Line_is_of_interest_XXXXXX"
---------------------------
OK
---------------------------
From the documentation page for MsgBox, there is a tip mentioning: "Tip: Pressing ctrl+c while a MsgBox window is active will copy its text to the clipboard. This applies to all MsgBoxes, not just those produced by AutoHotkey." ==> Yet, as shown above, the copied contents are formatted with window_title and an OK button, along with a few horizontal divider lines. The following subroutine can reproduce the message above. (I would like to keep the "OK" button to make sure the MsgBox won't go away before I get a chance to *copy* from it for its text.)
Code: Select all
test_clipboard:
StrOfInterest="XXXXXX___This_Line_is_of_interest_XXXXXX"
MsgBox, %StrOfInterest%
return