Sign in to follow this  
Followers 0
tauruzian

AutoIT get active document

9 posts in this topic

#include <Word.au3>

Global $oWord = _Word_Create()
Global $oDoc = _Word_DocGet($oWord, 1)
MsgBox(0,"Test",$oDOc.Name)

Above code help me to get the active Word filename . How do I get the active file for PDF,EXCEL,TXT and some other files. Any advice or reference link is highly appreciated. 

Thanks.

 

Share this post


Link to post
Share on other sites



Excel:

#include <Excel.au3>

Global $oExcel = _Excel_Open()
Global $oWorkbook = $oExcel.ActiveWorkbook
MsgBox(0,"Test",$oWorkbook.Name)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

PDF, TXT etc. depend on the application you use to open this files.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

PDF, TXT etc. depend on the application you use to open this files.

PDF im using Acrobat.

Share this post


Link to post
Share on other sites

PDF and TYT get much more complex.

Can you please tell us why you need that at all?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

I need to get the highlighted text in the Word or Excel or PDF document. In order to do so, I need to activate the document and send the "^c" to copy the highlighted text,

Word:

include <Word.au3>
Global $oWord = _Word_Create()
Global $oDoc = _Word_DocGet($oWord, 1)
Send ("^c")
winActivate($oDOc.Name)
Send ("^c")

Excel:

Global $oExcel = _Excel_Open()
Global $oWorkbook = $oExcel.ActiveWorkbook
Send ("^c")

How do I do the same for PDF.

Share this post


Link to post
Share on other sites

You are mixing two things:

  • Automating the GUI (by using Send)
  • Automating the program by using COM

Is the text you want to copy always in the active Window?

If yes: Why not just send "^c" to this window?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

You are mixing two things:

  • Automating the GUI (by using Send)
  • Automating the program by using COM

Is the text you want to copy always in the active Window?

If yes: Why not just send "^c" to this window?

User will select some text in the document, it can be first paragraph or second (any text). I need to copy those text and push it to clipboard. I will retrieve the value from clipboard using Java and i managed to do so. That's why in need to use Send(^C) , so the text will be pushed to clipboard.

Share this post


Link to post
Share on other sites

Or would something like this help? This script is triggered by "^c" (could be any other key). it sends "^c" to the active window and then displays the content of the clipboard.

So it is independant of the application in the active window.

HotKeySet("^c", "_Copy")
HotKeySet("{ESC}", "_Exit")

While 1
    Sleep(10)
WEnd

Func _Copy()
    HotKeySet("^c")
    Send("^c")
    $aClipBoard = ClipGet()
    MsgBox(0, "Content of Clipboard", $aClipBoard)
    HotKeySet("^c", "_Copy")
EndFunc   ;==>_Copy

Func _Exit()
    Exit
EndFunc   ;==>_Exit

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0