i want to do code if this conotrl (ClassNN: _WwG1) is active?
also how can I eliminate all the formatting from a text? ms word "Keep Text Only" feature doesn't work for ^v in my ms word, so I need to do it somehow with ahk
I'm currently studying for university entrance exam and I'am seriously out of time, and I'm trying to find a way to paste plain text in ms word with knowing how to change ^v function if the control is active, OR strip all the formatting with ahk, appreciate anyhelp, so far I'm getting nowhere
Need Basic help
Re: Need Basic help
There's more than one way to strip formatting from Clipboard text.
This approach does so in the Document itself:The upside to this is Word doesn't need to be active for the paste to take place
This approach does so in the Document itself:
Code: Select all
F1:: ; << feel free to change the hotkey to taste
wrdObj := ComConnect( "_WwG1", "ahk_class OpusApp" ).Application ; << creates a COM connection to current open document
wrdObj.Selection.PasteAndFormat(22) ; << removes formatting and pastes from clipboard, use 0 for default format
return
Esc::ExitApp ; << press escape to exit
ComConnect( Con, WinTitle )
{
objID := "-16", objID &= 0xFFFFFFFF
refID := -VarSetCapacity( iid, 16 )
iid_type := NumPut( 0x46000000000000C0
, NumPut( 0x20400, iid, "Int64" )
, "Int64")
ControlGet, hwnd, hwnd,, % Con, % WinTitle
DllCall( "oleacc\AccessibleObjectFromWindow", ptr, hwnd, uInt, objID, ptr, refID+iid_type, "ptr*", pObj )
return ComObjEnwrap( 9, pObj )
}
Result
-
- Posts: 1259
- Joined: 16 Apr 2015, 09:41
Re: Need Basic help
Here's what I use (I need to strip formatting when pasting into several different applications, not just Microsoft Word)...
Code: Select all
^+v:: ; Press Ctrl+Shift+V to paste unformatted text into any application.
OldClip := ClipboardAll ; Stores the original clipboard contents (with formatting).
Clipboard = %Clipboard% ; Strips any formatting from the clipboard.
Sleep 250 ; Gives a slight delay so that Windows has a chance to finish the clipboard update.
Send ^v ; Paste the stripped clipboard contents.
Sleep 250 ; Give a slight delay to give the paste a chance to complete.
Clipboard := OldClip ; Restore the original formatted text back to the clipboard.
OldClip = ; Clear the variable to avoid wasting RAM.
Return
Who is online
Users browsing this forum: Billykid, Google [Bot] and 221 guests