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 

#IfWinUnder

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Wish List
View previous topic :: View next topic  
Author Message
Tester



Joined: 06 Jul 2006
Posts: 48
Location: Poland

PostPosted: Thu Jul 13, 2006 11:29 pm    Post subject: #IfWinUnder Reply with quote

I have often this problem.
Code:
#IfWinActive Graphic
RButton::Send {o down}{LButton down}
RButton up::Send {o up}{LButton up}
#IfWinActive
Consider this situtation:
- some other application have focus, and window of Graphic is partialy visible beneath active window.
- when RButton is clicked on inactive Graphic window then hotkey isn't fire up, because in time of clicking Graphic window haven't focus, so as a result RButton-down (or maybe only RButton-up, but this doesn't matter) is passed to the Graphic window instead of hotkey defined for this window! (btw in case of software which I use now RButton makes very destructive operation)
- so in this cases (to be more precisely: only in cases of mouse operations, because only mouse click can change windows focus) it would be very useful new hotkeys directive #IfWinUnder.

Of course there is a workaround for this:
Code:
RButton::
   [get window under mouse]
   [set focus for window/control under mouse]
   if under_title=Graphics
      Send {o down}{LButton down}
   elseif under_title=other_app
      Send {something down}
   elseif under_title=other_app2
      Send ...
   elseif ....
   ...
   else
      Send {RButton down}
return
RButton up::
   if active_title=Graphics
      Send {o up}{LButton up}
   elseif under_title=other_app
      Send {something up}
   elseif inder_title=other_app2
      Send ...
   elseif ....
   ...
   else
      Send {RButton up}
return

So there should be only one global RButton definition instead many contextual definitions. So in real situations #IfWinActive directive is not so much useful in case of mouse clicks.

In fact I have defined this big, multiple elseif statements hotkey for almost all my mouse buttons, but this approach is very difficult for editing and maintaining.
Moreover the biggest disadvantage for me is that I can't make my script modular by using different #Include files for different applications, because I must have context actions in one hotkey in one file. When I share my script with other people, then simply deleting Included file is not enough - I must edit mouse hotkeys and remove manually parts which I don't want to share.

Other solution for this can be setting focus for under-clicked window (if it is inactive) in event function like upcoming OnKeystroke()/OnMouseClick() and only then process hotkeys, so in this time #IfWinActive directive would work fine - so #IfWinUnder would be unnecessary.

Or maybe someone have other elegant solution.

So what do you think about #IfWinUnder directive?
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10467

PostPosted: Sat Jul 15, 2006 4:26 am    Post subject: Reply with quote

Tester wrote:
Other solution for this can be setting focus for under-clicked window (if it is inactive) in event function like upcoming OnKeystroke()/OnMouseClick() and only then process hotkeys...
It's a useful and creative idea. A related idea proposed long ago was to have hotkeys become context-sensitive depending on the part of the window the mouse is over (such as scroll bar or title bar).

As you said, other features like OnKeystroke might be of help when they get implemented. Even so, I'll put your idea in my notes about future improvements to context sensitivity. In the meantime, you probably know that an alternate approach to "else if" is to use SetTimer to watch the window under the mouse, and then use the Hotkey command to enable/disable your mouse button hotkeys accordingly.

Also, it might be of some help (though not much) that you could use #IfWinExist instead of #IfWinActive.
Back to top
View user's profile Send private message Send e-mail
ruespe
Guest





PostPosted: Tue Jun 10, 2008 8:43 am    Post subject: Reply with quote

Chris wrote:
It's a useful and creative idea. A related idea proposed long ago was to have hotkeys become context-sensitive depending on the part of the window the mouse is over (such as scroll bar or title bar).

As you said, other features like OnKeystroke might be of help when they get implemented. Even so, I'll put your idea in my notes about future improvements to context sensitivity. In the meantime, you probably know that an alternate approach to "else if" is to use SetTimer to watch the window under the mouse, and then use the Hotkey command to enable/disable your mouse button hotkeys accordingly.

Also, it might be of some help (though not much) that you could use #IfWinExist instead of #IfWinActive.


Hello Chris,
a few days before the 2nd birthday of this thread Laughing I would like to push it back to the top. In the help-forum http://www.autohotkey.com/forum/post-201015.html#201015 I just posted the similar wish, because I find it absolutely nessessary
Quote:
So I would like to place a Change Request for one of the next (possibly the next?) versions,

- either to add a new option to #IfWinActive like WinUnderMouse 0/1
- or to add a new command like #IfWinUnderMouse

The optimum would be, when these clauses only had effect for mouse-hotkeys.

Thank you very much.


Please remember this topic in the next version

Rog
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Wish List 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