Jump to content

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

being more specific for a #IfWinActive


  • Please log in to reply
5 replies to this topic
Oliver
  • Members
  • 402 posts
  • Last active: Oct 26 2015 04:38 AM
  • Joined: 07 Aug 2011

at the docs I could not find if it is possible to be very specific with #IfWinActive adding not only the Window Title but also the Window Class and the Window Process so as to avoid that that script runs at an undesired dialog box

#IfWinActive Save As
!o:: Send {Return}
!u:: Send {BackSpace}
#IfWinActive

I would like to add to the Window Title ALSO Window Process which are:

 

ahk_class #32770
ahk_exe WINWORD.EXE
 


Exaskryz
  • Members
  • 3249 posts
  • Last active: Nov 20 2015 05:30 AM
  • Joined: 23 Aug 2012

You should be able to do this, at least that's what I've seen from other users on the forums:

 

#IfWinActive Save As ahk_class #32770 ahk_exe WINWORD.EXE

 

Edit: Tested it between Microsoft Word and Microsoft Excel's Save As dialogs. This did make my test hotkey q::MsgBox work only when having active the Word Save As.



scriptor
  • Members
  • 668 posts
  • Last active: Feb 15 2016 01:02 AM
  • Joined: 20 Jun 2013

you could also try it like this.. does this work? (untested):

GroupAdd, Group, ahk_class #32770
GroupAdd, Group, Save As
GroupAdd, Group, ahk_exe WINWORD.EXE

#IfWinActive ahk_group Group
!o:: Send {Return}
!u:: Send {BackSpace}
#IfWinActive ;not sure if we need this line but try it with and without it
 
 


Exaskryz
  • Members
  • 3249 posts
  • Last active: Nov 20 2015 05:30 AM
  • Joined: 23 Aug 2012

I do not believe the Group method will work. I'm pretty sure the hotkeys will become active if any of those WinTItles match, not if all of them match.



scriptor
  • Members
  • 668 posts
  • Last active: Feb 15 2016 01:02 AM
  • Joined: 20 Jun 2013

sorry, now I get it - is this because the "Save As" dialog box has the same wintitle as many other programs which also use the same dialog box.. but he only wants this to work when the Microsoft Word "Save As" dialog box is open..?



Exaskryz
  • Members
  • 3249 posts
  • Last active: Nov 20 2015 05:30 AM
  • Joined: 23 Aug 2012

Yes. He wants to get very specific. There are multiple windows that WinWord.exe creates, many windows that can be called "Save As". Some windows are in the class #32770 which I don't know very much about, but I think that's kind of a generic windows dialog class.

 

It would be like a Venn diagram. Three circles overlaying each other, and we want only the (hopefully one) window(s) that are within all three circles.