 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Should this be continued? |
| Yes |
|
93% |
[ 14 ] |
| No |
|
6% |
[ 1 ] |
|
| Total Votes : 15 |
|
| Author |
Message |
confused no0b Guest
|
Posted: Wed Feb 10, 2010 1:20 pm Post subject: |
|
|
| this thread got lot replies, but please can someone explain to this no0b like myself, how exactly to use all this? i've Office 2010 and I would liek to use some text-to-speech kinda thing with AHK? |
|
| Back to top |
|
 |
sinkfaze
Joined: 18 Mar 2008 Posts: 5044 Location: the tunnel(?=light)
|
Posted: Wed Feb 10, 2010 10:24 pm Post subject: |
|
|
This will save (and optionally open) attachments from the currently active Outlook email. rStr is a regular expression string to search for the attached item in the list of possible attachments. dir is to specify the save directory (default is the temporary folder) and rename is to specify a new name for the file (default is the name of the attachment as displayed). It's not highly flexible at the moment, any suggestions for improvement are more than welcome:
| Code: | /* Example usages
Outlook_SaveAttachment("\.tif$",true) ; will open the first attached .tif file
Outlook_SaveAttachment("important info\.txt"
,false
,"C:\Documents and Settings\sinkfaze\Desktop\"
,"itsmebaloney.txt") ; will rename 'important info.txt' to 'itsmebaloney.txt' and save it to the desktop
*/
Outlook_SaveAttachment(rStr,open=false,dir="",rename="") {
COM_CoInitialize()
olItem:=COM_GetActiveObject("Outlook.Application")
olItem:=COM_Invoke(olItem,"ActiveInspector.CurrentItem.Attachments")
Loop % COM_Invoke(olItem,"Count") {
att:=COM_Invoke(olItem,"Item",A_Index)
if RegExMatch(name:=COM_Invoke(att,"DisplayName"),rStr)
break
}
COM_Invoke(att,"SaveAsFile",(!dir ? A_Temp : dir) (!rename ? name : rename))
COM_Release(name),COM_Release(att),COM_Release(olItem)
COM_CoUninitialize()
if open
Run % (!dir ? A_Temp : dir) (!rename ? name : rename)
return
} |
_________________ Try Quick Search for Autohotkey or see the tutorial for newbies. |
|
| Back to top |
|
 |
Gabor
Joined: 09 Feb 2010 Posts: 3
|
Posted: Thu Feb 11, 2010 5:15 am Post subject: |
|
|
...i found it the solution:
| Code: | Word_TextBox(Left,Top,Width, Height,Text,Aligment){
Word := Word_Attach("A")
ActiveDocument := com_invoke(Word,"ActiveDocument")
Shape := com_invoke(ActiveDocument,"Shapes")
AddTextBox := com_invoke(Shape,"AddTextBox",1, Left, Top, Width, Height)
;TextBox line
Line := com_invoke(AddTextBox,"Line")
COM_Invoke(Line,"Visible",0)
;TextBox fill
Fill := COM_Invoke(AddTextBox, "Fill")
COM_Invoke(Fill,"Visible",0)
TextFrame := com_invoke(AddTextBox,"TextFrame")
;TextBox margins
COM_Invoke(TextFrame,"MarginBottom=", 0)
COM_Invoke(TextFrame,"MarginLeft=", 0)
COM_Invoke(TextFrame,"MarginRight=", 0)
COM_Invoke(TextFrame,"MarginTop=", 0)
TextRange := com_invoke(TextFrame,"TextRange")
;Text aligment in textbox (center)
Paragraphs := COM_Invoke(TextRange, "Paragraphs", 1)
COM_Invoke(Paragraphs,"Alignment=",Aligment)
Text := com_invoke(TextRange,"Text=",Text)
;Fix font property
Font := COM_Invoke(TextRange,"Font")
COM_Invoke(Font,"Name=", "Tahoma")
COM_Invoke(Font,"Size=", 10)
COM_Invoke(Font,"Bold=", False)
COM_Invoke(Font,"Italic=", False)
COM_Invoke(Font,"AllCaps=", False)
COM_Release(ActiveDocument)
COM_Release(Word)
COM_Release(Shapes)
COM_Release(AddTextBox)
COM_Release(TextRange)
} |
|
|
| Back to top |
|
 |
Mr Elmo
Joined: 25 Oct 2006 Posts: 18
|
Posted: Wed Feb 17, 2010 7:24 am Post subject: PPT Functions |
|
|
Hi!
I have put together a small library of PPT functions. I'm still updating a few things here and there, but it's got a good few useful calls in here, and I notice the PPT post being empty.
I work PowerPoint presentations at my church, and AHK/COM has been incredibly valuable to my work.
I have a slide-changing remote clicker that sends PgUp/PgDn keystrokes to control PPT.
The Past:
I often have to edit the slide show while it is displaying, so I must constantly alt-tab in time for the songleader to hit the button. Having AHK alt-tab for me was not much better.
The Present:
Using PgUp/PgDn as hotkeys as seen below, I can do whatever I ever want without worrying about the slides advancing correctly, and I'm never interrupted either.
| Code: | *PgDn:: PPT_Move("Next")
*PgUp:: PPT_Move("Previous")
|
Current version can be downloaded from my dropbox:
http://dl.getdropbox.com/u/827923/PPT.ahk
A couple of my functions use nested COM_Invoke's. Is this an acceptable procedure or do I need to use variables and release them afterward? _________________ %MemorablePhrase% |
|
| Back to top |
|
 |
Gabor
Joined: 09 Feb 2010 Posts: 3
|
Posted: Wed Feb 17, 2010 6:49 pm Post subject: |
|
|
ERROR:
The autohotkey encountered a problem and needs to close.
Anyone has idea?
Or what do I wrong?
| Code: |
Word_Replace(FindText,ReplaceWith){
Word := Word_Attach("A")
Selection := COM_Invoke(Word,"Selection")
Find := COM_Invoke(Selection,"Find")
Replacement := com_invoke(Find,"Replacement")
com_invoke(Find,"Text=",FindText)
com_invoke(Find,"ClearFormatting")
com_invoke(Replacement,"Text=",ReplaceWith)
com_invoke(Replacement,"ClearFormatting")
Execute := com_invoke(Find,"Execute",FindText,1,2)
COM_Release(Execute)
COM_Release(Find)
COM_Release(Selection)
COM_Release(Word)
}
com_CoInitialize()
Word_Open()
txt := "abc def ghi def abc"
Word_InsertText(txt)
FindText = def
ReplaceWith = xxx
Word_Replace(FindText,ReplaceWith)
com_CoUnInitialize()
exitapp |
And how to enter numbers only word?
| Code: |
com_CoInitialize()
Word_Open()
Word_InsertText("123456")
com_CoUnInitialize() |
|
|
| Back to top |
|
 |
LSW
Joined: 03 Feb 2010 Posts: 9
|
Posted: Mon Feb 22, 2010 9:11 am Post subject: |
|
|
Hi SinkFaze...
With regards to ur attachment program.. I have tried it out and is very useful for me.. but I have one enquiry..
I am not able to download multiple attachment in an email. As of now, when I use code, I am only able to download one attachment if I have two of it..
Is there a way to modify the program such that I can download more than 1 attachment in an email? or anyone able to help me in this? I need to auto download more than 1 attachment in one email.
thanks for your help! |
|
| Back to top |
|
 |
sinkfaze
Joined: 18 Mar 2008 Posts: 5044 Location: the tunnel(?=light)
|
Posted: Mon Feb 22, 2010 1:21 pm Post subject: |
|
|
You'll notice in the function that attachments is an optional parameter:
| Code: | | Outlook_SetEmail(NewMail="true",To="",Subj="",Body="",Cc="",Bcc="",Att="") |
So if you specify a number greater than one, it will prompt you more than once to attach a file to an email:
| Code: | | Outlook_SetEmail(true,"chris@autohotkey.com","AutoHotkey","AutoHotkey RULZ!!!",0,0,2) |
_________________ Try Quick Search for Autohotkey or see the tutorial for newbies. |
|
| Back to top |
|
 |
LSW
Joined: 03 Feb 2010 Posts: 9
|
Posted: Mon Feb 22, 2010 2:14 pm Post subject: |
|
|
Hi sinkfaze
Thanks for your reply.
I guess I have to rephrase my question.
Actually I was referring to the Outlook_SaveAttachment function.
When I tried to use that function, it only download one attachment, but in the email it consist of more than 1 attachment.
So do u have any idea how do I modify it, so that it can download more than 1 attachment?
Sorry kinda new to AHK.. :>[/u] |
|
| Back to top |
|
 |
sinkfaze
Joined: 18 Mar 2008 Posts: 5044 Location: the tunnel(?=light)
|
Posted: Mon Feb 22, 2010 3:50 pm Post subject: |
|
|
Ah, my mistake in misunderstanding your question!
The one thing you have to understand about Outlook emails is that all non-native components of an email (such as images in the body) are seen as attachments i.e. one email with 24 images in the body and three pdf files specifically in the attachments box has 27 attachments. When you access the list of attachments there is no logical order in which the actual attachments can be distinguished from "body attachments", so I was loathe to try to program in a filter that would allow to download multiple attachments in a single call.
One thing you could do is set up a couple of input boxes that will ask how many attachments and the identifying string (if any) to feed that to a loop that calls the function. Here's an example:
| Code: | InputBox, n
, Outlook_SaveAttachments
, How many attachments?
, , 300, 151
if (ErrorLevel || !n || RegExMatch(n,"^\D+$")) ; if user presses cancel, var is left blank or if var is non-digits
return
Loop % n { ; will loop for number of attachments
InputBox, s
, Outlook_SaveAttachments
, Enter a match string for the attachment.
if (ErrorLevel || !s) ; if user presses cancel or var is left blank
break
Outlook_SaveAttachment(s,false,<< some directory (optional) >>,<< some new file name (optional) >>)
}
return |
_________________ Try Quick Search for Autohotkey or see the tutorial for newbies. |
|
| Back to top |
|
 |
LSW
Joined: 03 Feb 2010 Posts: 9
|
Posted: Tue Feb 23, 2010 12:43 am Post subject: |
|
|
Hi sinkfaze
Really appreciate it..
I will try out the program.. thank u so much! |
|
| Back to top |
|
 |
LSW
Joined: 03 Feb 2010 Posts: 9
|
Posted: Tue Feb 23, 2010 9:33 am Post subject: |
|
|
Hi sinkfaze
Excellent Work!
However, can I just download all the documents in the attachment instead of doing a match string? I tried to bypass the comparision but it gives me an error? How can i go about bypassing the comaparison?
really appreciate ur help..
thanks! |
|
| Back to top |
|
 |
Jeremiah
Joined: 20 Apr 2009 Posts: 797 Location: North Dakota, USA
|
Posted: Wed Mar 10, 2010 4:23 pm Post subject: |
|
|
| ahklerner wrote: | ; Start a new instance of word
;
; Syntax:
; Word_Open()
|
For some reason this does not work for me. Any ideas? Here is my code...
| Code: | FileRead, test, C:test.txt
COM_CoInitialize()
Word_Open()
Bold := True
FontSize := 10
Word_InsertText("%test%")
COM_CoUnInitialize()
ExitApp |
I do have COM installed as well. I use it for IE functions along with iWeb. Will this not work with docx files? _________________ -Jeremiah |
|
| Back to top |
|
 |
sinkfaze
Joined: 18 Mar 2008 Posts: 5044 Location: the tunnel(?=light)
|
Posted: Wed Mar 10, 2010 4:30 pm Post subject: |
|
|
These functions are no different than any other functions, literal text must be quoted, variables do not require percent signs:
| Code: | Word_InsertText("%test%") ; incorrect
Word_InsertText(test) ; correct |
_________________ Try Quick Search for Autohotkey or see the tutorial for newbies. |
|
| Back to top |
|
 |
Jeremiah
Joined: 20 Apr 2009 Posts: 797 Location: North Dakota, USA
|
Posted: Wed Mar 10, 2010 4:33 pm Post subject: |
|
|
Good to know. I keep forgetting that. However, my issue happens with
The program won't go passed that point. _________________ -Jeremiah |
|
| Back to top |
|
 |
sinkfaze
Joined: 18 Mar 2008 Posts: 5044 Location: the tunnel(?=light)
|
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|