AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Hotkey doesn't work when #Included

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
ArchCarrier



Joined: 03 Jun 2008
Posts: 27

PostPosted: Sat Jan 17, 2009 2:16 pm    Post subject: Hotkey doesn't work when #Included Reply with quote

I've made a quick popup menu that I like to access using Win+A. I #Include the menu code in the top of my autohotkey.ini
Now, the weird thing is that the hotkey doesn't work when using #Include. Only when I run the menu script by itself the hotkey becomes active.

I have tried all combinations: including all the menu code directly in the .ini file, keeping the menu code apart but only including the hotkey in the .ini file, etc.
I'm out of options; what can be the problem?
Back to top
View user's profile Send private message
animeaime



Joined: 04 Nov 2008
Posts: 1045

PostPosted: Sat Jan 17, 2009 4:21 pm    Post subject: Reply with quote

Can you post the code?
_________________
As always, if you have any further questions, don't hesitate to ask.

Add OOP to your scripts via the Class Library. Check out my scripts.
Back to top
View user's profile Send private message Send e-mail
ArchCarrier



Joined: 03 Jun 2008
Posts: 27

PostPosted: Sun Jan 18, 2009 8:21 am    Post subject: Reply with quote

Of course. Here are the very first two lines of my Autohotkey.ini:
Code:
#Include c:\Program Files\AutoHotkey\Scripts\Functions.ahk
#Include c:\Program Files\AutoHotkey\Scripts\StartMenu.ahk

A couple of lines down I have this:
Code:
#a::Menu, MyMenu, Show, 0, 1024


Here is the code in StartMenu.ahk:
Code:
CoordMode, Menu, Screen

; Create submenu
Menu, Submenu1, Add, &AutoHotkey.ini, AutoHotkey
Menu, Submenu1, Add, &Start Menu, StartMenu
Menu, Submenu1, Add, U&RL Filter, URLfilter
Menu, Submenu1, Add, &Telefoonnummers, EditTelefoonnummers

; Display submenu
Menu, MyMenu, Add, &Edit files, :Submenu1

; Add separator
Menu, MyMenu, Add

Menu, MyMenu, Add, Play &DVD, PlayDVD
Menu, MyMenu, Add, &Photoshop, Photoshop
Menu, MyMenu, Add, &Illustrator, Illustrator
Menu, MyMenu, Add, &Lightroom, Lightroom
Menu, MyMenu, Add, &Writer, Writer
Menu, MyMenu, Add, &Calc, Calc
Menu, MyMenu, Add, Mnemos&yne, Mnemosyne
Menu, MyMenu, Add, Super&Memo, SuperMemo
Menu, MyMenu, Add, &Skype, Skype
Menu, MyMenu, Add, Tas&k Scheduler, TaskScheduler
Menu, MyMenu, Add, &XAMPP, StartXampp

return

Followed by all the menu handlers and nothing else.

As I said, I have tried putting the hotkey line everywhere I could think of, but I always get the same error: "Error in #Include file c:\Program Files\AutoHotkey\Scripts\StartMenu.ahk: Menu does not exist."
Back to top
View user's profile Send private message
animeaime



Joined: 04 Nov 2008
Posts: 1045

PostPosted: Sun Jan 18, 2009 9:13 am    Post subject: Reply with quote

I added the hotkey after the menu creation (after the return statement in StartMenu.ahk) and had no problem. If I remember correctly, if you put in a hotkey, it ends the auto-exec section. This means, if you put your hotkey anywhere but after the entire auto-exec section is done, you won't have what follows evaluated. Below is a simple script to illustrate this point.

Code:
#a::MsgBox, Test
MsgBox, This is NEVER seen!!
return


Code:
MsgBox, But this is :)
return
#a::MsgBox, Test

_________________
As always, if you have any further questions, don't hesitate to ask.

Add OOP to your scripts via the Class Library. Check out my scripts.
Back to top
View user's profile Send private message Send e-mail
ArchCarrier



Joined: 03 Jun 2008
Posts: 27

PostPosted: Sun Jan 18, 2009 12:32 pm    Post subject: Reply with quote

That was indeed the solution, but not in the pieces of code I posted: in the Functions.ahk that's included in the first line of my .ini file, I had put a hotkey. I was working on both files at the same time, so I didn't realise it was the Functions part that caused the problem.

Thanks anyway!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group