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 

Toolbars for different windows...

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



Joined: 07 Dec 2006
Posts: 42

PostPosted: Tue Oct 09, 2007 3:52 pm    Post subject: Toolbars for different windows... Reply with quote

Hi there,

I have a big script which does a number of things to transfer text between Outlook and another application with forms, as well as automatizing the writing of email. I think that it's value is very limited to the specific work environment of my company though...

Every different little thing it does has a key combination. I would like to switch to windows which act like contextual toolbars. That way some people who will have to use it won't have to go through the hassle of thinking "was that Alt G or CTRL W?" I know how to do a plain GUI with buttons which stays on top all the time, but I would like to have only the functions that apply to a given environment in the GUI. Thus when the focus is on Outlook, the buttons would be "search in Remedy", "send to Remedy form", "search and send email body", etc ; when I am focusing let's say notepad then it'd be hidden (or perhaps just closed), and when I am focusing Remedy then it'd display other buttons.

I tried to use ifwinactive and ifwinnotactive, but it didn't work. What's the best way to do this? Have you got a working example of a script with contextual GUIs that I can have a look at?

Thanks in advance for the help...

Miguel
Back to top
View user's profile Send private message
Superfraggle



Joined: 02 Nov 2004
Posts: 962
Location: London, UK

PostPosted: Tue Oct 09, 2007 4:08 pm    Post subject: Reply with quote

I have a script that does exactly this. I'll post it if I get a chance.

EDIT:

Code:
Gui +LastFound
hWnd := WinExist()
DllCall( "RegisterShellHookWindow", UInt,hWnd )
MsgNum := DllCall( "RegisterWindowMessage", Str,"SHELLHOOK" )
OnMessage( MsgNum, "ShellMessage" )
;### Create Guis ###
Gui,10:Add,Button,,OK
Gui 10: Color, EEAA99
gui,10:+ToolWindow +Alwaysontop -Caption +LastFound
WinSet TransColor, EEAA99,
Gui,11:Add,Button,gbmc,BMC
Gui 11: Color, EEAA99
gui,11:+ToolWindow +Alwaysontop -Caption +LastFound
WinSet TransColor, EEAA99,
Return

BMC:
11buttonok:
10Buttonok:
Event:=A_GuiControl
return

ShellMessage(wParam,lParam) {
  static oldhwnd,guishown,oldtitle
  global Event
  If (wparam = 4 or wparam = 32772){
      If WinActive("2081 ahk_class TSSHELLWND") or WinActive("App Helper"){
        if (guishown = 11){
          Gui,%guishown%:Cancel
        }
        WinGetPos,x,y,,,2081 ahk_class TSSHELLWND
        Gui,10:Show,NoActivate x%x% y%y%,App Helper
        guishown:=10
        if WinActive("App Helper"){
          keywait,LButton,T1
          Winactivate,ahk_id %oldhwnd%
          lparam:=oldhwnd
          If Event
            PerformEvent(Event)
        }
      }
      Else If winactive("2073 ahk_class TSSHELLWND") or winactive("Peregrine Tool"){
        if (guishown = 10){
          Gui,%guishown%:Cancel
        }
        WinGetPos,x,y,,,2073 ahk_class TSSHELLWND
        Gui,11:Show,NoActivate x%x% y%y%,Peregrine Tool
        guishown:=11
        if WinActive("Peregrine Tool"){
          keywait,LButton,T1
          Winactivate,ahk_id %oldhwnd%
          lparam:=oldhwnd
          If Event
            PerformEvent(Event)
        }
      }
      Else if (guishown){
        Gui,%guishown%:Cancel
      }
      oldhwnd:=lparam
      WinGetActiveTitle,oldtitle
  }
  Else {
   
  }
  Event:=""
}

_________________
Steve F AKA Superfraggle

http://r.yuwie.com/superfraggle
Back to top
View user's profile Send private message MSN Messenger
emirvisir



Joined: 07 Dec 2006
Posts: 42

PostPosted: Tue Oct 09, 2007 10:55 pm    Post subject: Reply with quote

Thanks! I will try to adapt your code to my script and tell you the result... that was very helpful
Back to top
View user's profile Send private message
emirvisir



Joined: 07 Dec 2006
Posts: 42

PostPosted: Wed Oct 10, 2007 2:50 pm    Post subject: Reply with quote

I came up with this crummy code:
Code:

;Outlook Toolbar
OutlookGUI:
winwaitactive ahk_class rctrl_renwnd32 ;waits for Outlook to be activated
Gui, Add, Button, x-4 y-3 w90 h30 gnuevo_ticket_EARS, send to Remedy
Gui, Add, Button, x86 y-3 w90 h30 gBuscar_en_ears, Search in Remedy
Gui, Add, Button, x176 y-3 w90 h30 gmodificar_EARS, Modify in Remedy
Gui, Add, Button, x266 y-3 w100 h30 gbuscar_y_modificar, search and modify in remedy
Gui, Show, x244 y165 h26 w365,Toolbar Outlook
gui, +alwaysontop
winwaitactive ahk_class rctrl_renwnd32
winwaitnotactive ahk_class rctrl_renwnd32
winclose Toolbar Outlook
gosub OutlookGUI
Return


I would like to know how can I do this so that moving the toolbar works, and how to minimize the toolbar and store the toolbar's position after closing it... basically when I change focus from Outlook I close the toolbar and redraw it every single time I focus Outlook again, because this GUI fires subroutines with GUIs of their own.

Cheers,

Miguel
Back to top
View user's profile Send private message
HugoV



Joined: 27 May 2007
Posts: 617

PostPosted: Wed Oct 10, 2007 3:33 pm    Post subject: Reply with quote

Perhaps not entirely what you're after, but the Dock module might be something you want to look into:

[module] Dock 1.0 b2
http://www.autohotkey.com/forum/viewtopic.php?t=19400&highlight=dock

TitleButton 0.31
http://www.autohotkey.com/forum/viewtopic.php?t=19430&highlight=dock
Back to top
View user's profile Send private message
emirvisir



Joined: 07 Dec 2006
Posts: 42

PostPosted: Wed Oct 10, 2007 4:03 pm    Post subject: Reply with quote

This all looks ver very nice, lots of ideas for window handling... I'll let you know if there is anything I can use here. My guess is that what I am really looking after is a context sensitive GUI for other AHK scripts

Thanks,

Miguel
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   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