Using this code,
Code: Select all
^!a::
Send, ^c
Run C:\[path to my doc]\mydoc.docx
Send, ^f
Send, %clipboard%
return
How can I solve this?
Code: Select all
^!a::
Send, ^c
Run C:\[path to my doc]\mydoc.docx
Send, ^f
Send, %clipboard%
return
Code: Select all
^!a::
ClipSaved := ClipboardAll ; save the entire clipboard to the variable ClipSaved
clipboard := "" ; empty the clipboard (start off empty to allow ClipWait to detect when the text has arrived)
Send, ^c ; copy the selected text,
ClipWait, 1 ; wait for the clipboard to contain data.
if (!ErrorLevel) ; If NOT ErrorLevel clipwait found data on the clipboard
{
If !WinExist("mydoc ahk_class OpusApp") ; title and ahk_class
{
oWord := ComObjCreate("Word.Application") ; create MS Word object
oWord.Visible := True
file := "C:\path to my doc\mydoc.docx" ; Path to file
oWord.Documents.Open(file)
}
oWord := ComObjActive("Word.Application") ; activate an open one doc
oWord.Selection.Find.ClearFormatting
oWord.Selection.Find.Text := clipboard
oWord.Selection.Find.Wrap := 1
oWord.Selection.Find.Execute
}
else
MsgBox, No clipboard data
clipboard := ClipSaved ; restore original clipboard
return
Code: Select all
#+t::
clipboard := "" ; empty the clipboard (start off empty to allow ClipWait to detect when the text has arrived)
Send, ^c ; copy the selected text,
Run WINWORD.exe, , Max
WinWait, Untitled - WINWORD,, 3
Run C:\path to my doc\mydoc.docx
if WinExist("Untitled - WINWORD")
WinActivate ; Use the window found by WinExist
Send, ^f
Send, %clipboard%
return
Code: Select all
#+t::
ClipSaved := ClipboardAll ; save the entire clipboard to the variable ClipSaved
clipboard := "" ; empty the clipboard (start off empty to allow ClipWait to detect when the text has arrived)
Send, ^c ; copy the selected text
ClipWait, 1 ; wait for the clipboard to contain data.
if (!ErrorLevel) ; If NOT ErrorLevel clipwait found data on the clipboard
{
If !WinExist("title of mydoc.docx") ; Use Window Spy to get the exact title
Run C:\[path to my doc]\mydoc.docx, , Max
WinWait, title of mydoc.docx ; Use Window Spy to get the exact title
WinActivate title of mydoc.docx ; same here
WinWaitActive, title of mydoc.docx ; and here
Send, ^f
Sleep, 300 ; wait for the search box
Send, ^v ; paste the clipboard content in the search box
}
else
MsgBox, No clipboard data
clipboard := ClipSaved ; restore original clipboard
return
Before you started with AHK you were unfamiliar with all commands...
Code: Select all
oWord := ComObjActive("Word.Application")
oWord.Selection.Find.Text := "test"
oWord.Selection.Find.Execute
Users browsing this forum: Chunjee, mikeyww, scriptor2016 and 273 guests