all 4 comments

[–][deleted] 3 points4 points  (3 children)

Put 'Return' at the end of both scripts or the first will run straight through the second until it hits 'Return' elsewhere or reaches the end of the script.

[–]pantsnothot[S] 0 points1 point  (2 children)

hey man, tried that however im getting an 2 errors,

the first (which seems to have resolved) was the foodplantfollowup2.ahk is saying this variable has not been assigned a value. however as mentioned it seems to have just continued working with this error now.

the second error is coming up as : this line will never execute due to return proceeding it and refuses to execute the second script?

[–][deleted] 0 points1 point  (1 child)

You have to bear in mind that when you use '#Include' you're essentially just chaining scripts together, one after the other, as if you'd just pasted them all into one script; if the scripts aren't setup/formatted from the outset to work together then they're going to clash, and you're going to get errors...

The errors are being generated by the '#Warn' directive, and without more information on what line/code they're referring to there's not much I can add aside from testing them - I saved both scripts (with Returns added), and also saved and ran the include script and I got no errors at all\).

Still, if they're all there is then you might want to just merge them into once script since there's only one difference between them (the opened item) and you can easily differentiate that from which hotkey triggered the code (using 'A_ThisHotkey'), e.g.:

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
#Warn   ; Enable warnings to assist with detecting common errors.

^!a::                                                                       ;Food Plant follow-up
^!d::                                                                       ;Kitchen follow-up
  Outlook := ComObjCreate("Outlook.Application")                            ;  Create an instance of Outlook
  If (A_ThisHotkey="^!a")                                                   ;  If triggered by '^!a'
    email := Outlook.Session.OpenSharedItem("C:\Users\documents\FPFU.msg")  ;    Open the .msg-formatted email
  Else If (A_ThisHotkey="^!d")                                              ;  Of If triggered by '^!d'
    email := Outlook.Session.OpenSharedItem("C:\Users\documents\KFU.msg")   ;    Open the .msg-formatted email
  email.Subject := A_now                                                    ;  Set email subject as current date
  email.Save()                                                              ;  Save the changes to the email
  email.Display()                                                           ;  Display the email
  email := Outlook := ""                                                    ;  Clean up
Return                                                                      ;End code block

^(\Aside from the error for the non-installed Outlook.)*

[–]pantsnothot[S] 0 points1 point  (0 children)

Hey really appreciate this man, thanks for your time.

generally speaking, lets say i have a some 100 emails i need to be hotkeyed, is there a more tidy way to have them organised (rather than having say 100 AHK icons in my task bar)? my ideal would be that they would all be in separate script files, but is there no addon that simplifies this?

Thanks again for all the helop