AutoHotkey Community

It is currently May 26th, 2012, 11:59 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: March 10th, 2005, 6:59 pm 
Offline
User avatar

Joined: August 11th, 2004, 1:47 am
Posts: 5347
Location: UK
I think this topic has been come accross before but I don't know much about it.

Suppose your script has #SingleInstance off (allow multiple instances) and you assign hotkeys [each with IfWinActive(...)] it will affect other instances when intended to trigger a command on a single script.

Advantages of hotkeys that only work on the script that's activated (and has gui) means less code and support for the reason mentioned above.

_________________
GitHubScriptsIronAHK Contact by email not private message.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 11th, 2005, 2:00 am 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
It is planned to support accelerator keys in Gui menu bars. These keys are things such as Notepad's Ctrl+S to save.

I've also made a note of your idea, which is to allow application specific hotkeys that take effect only when one of the script's windows is active. Such hotkeys should work globally across all the script's windows (if it has more than one).

Thanks.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 12th, 2005, 7:19 pm 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
The application specific hotkey idea is really good. It would simplify my scripts greatly. Something like !z:: becomes !z:Winword.exe:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 1st, 2006, 1:15 am 
Offline

Joined: March 31st, 2006, 3:39 pm
Posts: 144
Location: New York
Any progress on this one? I too think that internal hotkeys specific to a GUI window would be extremely useful.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 1st, 2006, 4:03 am 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
Not yet, but if you go to the Menu section of the GUI page, it demonstrates how to do it via context-sensitive hotkeys:
Code:
Menu, FileMenu, Add, &Open    Ctrl+O, MenuFileOpen  ; See remarks below about Ctrl+O.
Menu, FileMenu, Add, E&xit, MenuHandler
Menu, HelpMenu, Add, &About, MenuHandler
Menu, MyMenuBar, Add, &File, :FileMenu  ; Attach the two sub-menus that were created above.
Menu, MyMenuBar, Add, &Help, :HelpMenu
Gui, Menu, MyMenuBar

; In the first line above, notice that &Open is followed by Ctrl+O (with a tab character in between). This indicates a keyboard shortcut that the user may press instead of selecting the menu item. To enable such a shortcut in the script, use a context-sensitive hotkey:

#IfWinActive GUI Window's Title ahk_class AutoHotkeyGUI
^o::  ; The Ctrl+O hotkey.
MenuFileOpen:
Gui +OwnDialogs  ; Force the user to dismiss the FileSelectFile dialog before returning to the main window.
FileSelectFile, SelectedFile
MsgBox You selected the file %SelectedFile%.
return

; The following part is needed only if the script will be run on Windows 95/98/Me:
#IfWinActive
$^o::Send ^o


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 1st, 2009, 9:08 pm 
Offline

Joined: March 31st, 2006, 3:39 pm
Posts: 144
Location: New York
SO has this one been forgotten about in the shuffle? I still think that this would be one of the more useful additions to AutoHotkey. After all hotkeys is what this application is all about right?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 2nd, 2009, 9:17 am 
Offline
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8666
Location: Salem, MA
I don't think it's been forgotten. Chris gave a good example of how to set it up with context sensitive keys.

To make it more robust for multiple copies of the same script, I would add the AHK GUI's window handle to a Window Group (GroupAdd), then make the hotkey #IfWinActive based on the Window group.

This will give you complete control over the scope of the hotkey, including in multiple GUI scripts (adding the PID of the script to the Window group instead of the window handle). You can also make the same hotkey do different things in different GUIs of the same script by adding the window handles to different groups, and restricting the hotkeys that way.

I don't think this will be added to AHK, since there are many different things people would want to do, and allowing you to do it in AHK gives you all the flexibility you want, without adding new syntax.

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 2nd, 2009, 11:54 am 
Offline

Joined: March 31st, 2006, 3:39 pm
Posts: 144
Location: New York
Thanks. You know after a couple of years of using AutoHotkey, using groups with the ID or PID never occurred to me as a method for insuring hotkeys stay locked to a Gui produced by a specific script. This has indeed been my primary concern.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 3 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:
Powered by phpBB® Forum Software © phpBB Group