AutoHotkey Community

It is currently May 27th, 2012, 4:46 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 296 posts ]  Go to page Previous  1 ... 10, 11, 12, 13, 14, 15, 16 ... 20  Next

Should this be continued?
Poll ended at June 18th, 2008, 11:34 pm
Yes 93%  93%  [ 14 ]
No 7%  7%  [ 1 ]
Total votes : 15
Author Message
 Post subject:
PostPosted: February 10th, 2010, 2:20 pm 
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?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 10th, 2010, 11:24 pm 
Offline
User avatar

Joined: March 19th, 2008, 12:43 am
Posts: 5480
Location: the tunnel(?=light)
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

}

_________________
Image
Try Quick Search for Autohotkey or see the tutorial for newbies.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 11th, 2010, 6:15 am 
Offline

Joined: February 9th, 2010, 6:04 am
Posts: 3
Gabor wrote:
Hi, can somebody help me?
It an method does not work and I cannot solve it unfortunately:

http://msdn.microsoft.com/en-us/library ... 11%29.aspx



...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)
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject: PPT Functions
PostPosted: February 17th, 2010, 8:24 am 
Offline

Joined: October 25th, 2006, 4:34 pm
Posts: 18
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%


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 17th, 2010, 7:49 pm 
Offline

Joined: February 9th, 2010, 6:04 am
Posts: 3
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()


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 22nd, 2010, 10:11 am 
Offline

Joined: February 3rd, 2010, 4:06 am
Posts: 9
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!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 22nd, 2010, 2:21 pm 
Offline
User avatar

Joined: March 19th, 2008, 12:43 am
Posts: 5480
Location: the tunnel(?=light)
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)

_________________
Image
Try Quick Search for Autohotkey or see the tutorial for newbies.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 22nd, 2010, 3:14 pm 
Offline

Joined: February 3rd, 2010, 4:06 am
Posts: 9
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]


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 22nd, 2010, 4:50 pm 
Offline
User avatar

Joined: March 19th, 2008, 12:43 am
Posts: 5480
Location: the tunnel(?=light)
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

_________________
Image
Try Quick Search for Autohotkey or see the tutorial for newbies.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 23rd, 2010, 1:43 am 
Offline

Joined: February 3rd, 2010, 4:06 am
Posts: 9
Hi sinkfaze
Really appreciate it..
I will try out the program.. thank u so much!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 23rd, 2010, 10:33 am 
Offline

Joined: February 3rd, 2010, 4:06 am
Posts: 9
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!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 10th, 2010, 5:23 pm 
Offline

Joined: April 20th, 2009, 1:10 pm
Posts: 817
Location: North Dakota, USA
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 10th, 2010, 5:30 pm 
Offline
User avatar

Joined: March 19th, 2008, 12:43 am
Posts: 5480
Location: the tunnel(?=light)
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

_________________
Image
Try Quick Search for Autohotkey or see the tutorial for newbies.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 10th, 2010, 5:33 pm 
Offline

Joined: April 20th, 2009, 1:10 pm
Posts: 817
Location: North Dakota, USA
Good to know. I keep forgetting that. However, my issue happens with
Code:
Word_Open()

The program won't go passed that point.

_________________
-Jeremiah


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 10th, 2010, 6:13 pm 
Offline
User avatar

Joined: March 19th, 2008, 12:43 am
Posts: 5480
Location: the tunnel(?=light)
Are you getting any error messages?

_________________
Image
Try Quick Search for Autohotkey or see the tutorial for newbies.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 296 posts ]  Go to page Previous  1 ... 10, 11, 12, 13, 14, 15, 16 ... 20  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 13 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
cron
Powered by phpBB® Forum Software © phpBB Group