Hey, I have a simple script which makes a copy of a text from a browser and pastes to MSWord file automatically by keyboard shortcuts. I would like to make special formatting of this text - to have it in white font (to attain hidden text effect).
In other words: I would like to have a script which.
1) makes a copy of a text to Clipboard,
2) change a font to white
3) paste to file which I want.
Point 2 is missing.
I would like to change formatting of text in a Clipboard and paste it to MS Word file Topic is solved
Re: I would like to change formatting of text in a Clipboard and paste it to MS Word file
Where do you see a solution there? Surrounding in my Word file is not white, so MS options will not work. I want to copy black text to file with black text, but the copied text should be changed on the fly to white before pasting.
If it's possible, please for a line of code with such change on the fly.
If it's possible, please for a line of code with such change on the fly.
-
- Posts: 4331
- Joined: 29 Mar 2015, 09:41
- Contact:
Re: I would like to change formatting of text in a Clipboard and paste it to MS Word file
Hi, NagaSuka,
What do you mean by "paste to file"? Do you mean "add to the end of the file"? Or you mean "paste to MS Word Editor window to the caret position"?
What do you mean by "paste to file"? Do you mean "add to the end of the file"? Or you mean "paste to MS Word Editor window to the caret position"?
Re: I would like to change formatting of text in a Clipboard and paste it to MS Word file
Hi Teadrinker,
I mean caret position.
I read some texts in Word file, look up in the dictionary for important terms and would like to paste a translation in white font colour to have it a little hidden in the main text. Later I will make revision if I memorised this important terms.
I mean caret position.
I read some texts in Word file, look up in the dictionary for important terms and would like to paste a translation in white font colour to have it a little hidden in the main text. Later I will make revision if I memorised this important terms.
-
- Posts: 4331
- Joined: 29 Mar 2015, 09:41
- Contact:
Re: I would like to change formatting of text in a Clipboard and paste it to MS Word file Topic is solved
Try:
Open MS Word editor with your file, set the caret to the place you need, launch my script, then select the text you want to paste and press F10.
Code: Select all
$F10::
PutSelectedTextInClipboard()
PasteFormattedText( GetWord() ).Font.ColorIndex := 8 ; wdWhite := 8
Return
PutSelectedTextInClipboard() {
tempClip := ClipboardAll
Clipboard := ""
SendInput, ^{sc2E} ; Ctrl + C
ClipWait, .5
if ErrorLevel {
Clipboard := tempClip
MsgBox, Filed to get text!
}
}
PasteFormattedText(oWord) {
rng := oWord.Selection.Range
rng.Paste
Return rng
}
GetWord() {
if !hwnd := WinActive("ahk_class OpusApp")
hwnd := WinExist("ahk_class OpusApp")
ControlGet, ControlHwnd, Hwnd,, _WwG1, ahk_id %hwnd%
Return AccObjectFromWindow(ControlHwnd, -16).Application
}
AccObjectFromWindow(hWnd, idObject = 0)
{
static IID_IDispatch := "{00020400-0000-0000-C000-000000000046}"
, IID_IAccessible := "{618736e0-3c3d-11cf-810c-00aa00389b71}"
, OBJID_NATIVEOM := 0xFFFFFFF0, VT_DISPATCH := 9, h := DllCall("LoadLibrary", Str, "oleacc", Ptr)
VarSetCapacity(IID, 16), idObject &= 0xFFFFFFFF
DllCall("ole32\CLSIDFromString", Str, idObject = OBJID_NATIVEOM ? IID_IDispatch : IID_IAccessible, Ptr, &IID)
if DllCall("oleacc\AccessibleObjectFromWindow", Ptr, hWnd, UInt, idObject, Ptr, &IID, PtrP, pAcc) = 0
Return ComObjEnwrap(VT_DISPATCH, pAcc, 1)
}
Who is online
Users browsing this forum: filipemb, Frogrammer, Google [Bot], mcd and 191 guests