Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

#include - not working what am I doing wrong?


  • Please log in to reply
7 replies to this topic
scripty2020
  • Members
  • 2 posts
  • Last active: Jan 23 2015 05:26 PM
  • Joined: 21 Jan 2015

Hi there.

 

I am experimenting with simple (!) autohotkey macros. I want to build up a library of functions and then call them from a "master" ahk file. I thought I could do this with the #Include feature but it is not working please help !

 

c:\utils\master.ahk:

--------

/*** put include files here ***/
#Include c:\utils\notepad.ahk
/*** put include files here ***/

/*** actual running section here ***/
doNotePad()
ExitApp
/*** actual running section here ***/

---------------

c:\utils\notepad.ahk:

---------------

doNotePad()
{
 Run, Notepad "%tmp%\doc1.txt"
 Sleep 1000
 Send ^{End}
 Send {Return}
 Send now is the winter of our discontent
 Send {Return}
 Send made glorious summer by this son of York
 Send {Return}
 Send ^s
 Sleep 1000
 Send !{F4}
}

-----------------

 

Its not working ! If I try to run master.ahk I get nothing.

 

But! If I copy the  

doNotePad()
ExitApp

directly into the notepad.ahk and run it directly **without** the master.ahk, it works fine.

 

So it appears that the #include feature does not work ??

 

What am I doing wrong ?

 

Very confused...

 

Scripty...

 

 

 

 



wuvixx
  • Members
  • 140 posts
  • Last active: Mar 12 2015 10:31 AM
  • Joined: 15 Sep 2014

Try to place all your #Include's at the very bottom of your script and test it again.


“Je suis Charlie”


flyingDman
  • Spam Officer
  • 2186 posts
  • Last active: Nov 07 2015 08:15 AM
  • Joined: 27 Feb 2009

Remove the comments in your script....

 

The # include can be anywhere (in this case).

 

The #Include directive may be used (even at the top of a script) to load functions from an external file

 

edit: wrong link: http://www.autohotke...ts.htm#Comments


Marine Corps Gen. Joseph Dunford told senators at his Joint Chiefs of Staff confirmation hearing : “If you want to talk about a nation that could pose an existential threat to the United States, I'd have to point to Russia. And if you look at their behavior, it's nothing short of alarming.”


wuvixx
  • Members
  • 140 posts
  • Last active: Mar 12 2015 10:31 AM
  • Joined: 15 Sep 2014

Remove the comments in your script....

 

The # include can be anywhere.

 

I have read that not at all cases that is true. Correct me if I'm wrong: http://www.autohotke...clude-location/


“Je suis Charlie”


scripty2020
  • Members
  • 2 posts
  • Last active: Jan 23 2015 05:26 PM
  • Joined: 21 Jan 2015

ok found the problem ( ? defect ? )

 

If I remove the nice /*********comments*******/ lines from both scripts it works. Why would that happen ?

 

Is there a better method for comments than /*** blah ***/ ?

 

This does not work:

doNotePad()

/******test****/
#Include C:\utils\notepad.ahk

error: call to nonexistent function.

 

Specifically: doNotePad()

 

But this works:

 

doNotePad()


#Include C:\utils\notepad.ahk


Oldman
  • Members
  • 2475 posts
  • Last active: Feb 18 2015 04:57 PM
  • Joined: 01 Dec 2013

See Comments in scripts, It works like this :

/*** put include files here
*/
;#Include c:\utils\notepad.ahk
#Include notepad.ahk
/*** put include files here
*/

/*** actual running section here
*/
doNotePad()
ExitApp
/*** actual running section here
*/

Si ton labeur est dur et que tes résultats sont minces, souviens toi du grand chêne qui avant n'était qu'un gland....comme toi ! (anonyme) ;)

L'art de lire, c'est l'art de penser avec un peu d'aide. (É. Faguet)

Windows 3.1. Collector's Edition.     (www.avaaz.org)


flyingDman
  • Spam Officer
  • 2186 posts
  • Last active: Nov 07 2015 08:15 AM
  • Joined: 27 Feb 2009

@wuvxx:  because this is just a function the #include can go anywhere.  Otherwise the location is relevant (see HotKeyIt's comment).


Marine Corps Gen. Joseph Dunford told senators at his Joint Chiefs of Staff confirmation hearing : “If you want to talk about a nation that could pose an existential threat to the United States, I'd have to point to Russia. And if you look at their behavior, it's nothing short of alarming.”


wuvixx
  • Members
  • 140 posts
  • Last active: Mar 12 2015 10:31 AM
  • Joined: 15 Sep 2014

@wuvxx:  because this is just a function the #include can go anywhere.  Otherwise the location is relevant (see HotKeyIt's comment).

Oh that explains it. Thanks. :)


“Je suis Charlie”