 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
emirvisir
Joined: 07 Dec 2006 Posts: 42
|
Posted: Tue Oct 09, 2007 3:52 pm Post subject: Toolbars for different windows... |
|
|
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 |
|
 |
Superfraggle
Joined: 02 Nov 2004 Posts: 962 Location: London, UK
|
Posted: Tue Oct 09, 2007 4:08 pm Post subject: |
|
|
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 |
|
 |
emirvisir
Joined: 07 Dec 2006 Posts: 42
|
Posted: Tue Oct 09, 2007 10:55 pm Post subject: |
|
|
| Thanks! I will try to adapt your code to my script and tell you the result... that was very helpful |
|
| Back to top |
|
 |
emirvisir
Joined: 07 Dec 2006 Posts: 42
|
Posted: Wed Oct 10, 2007 2:50 pm Post subject: |
|
|
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 |
|
 |
HugoV
Joined: 27 May 2007 Posts: 617
|
|
| Back to top |
|
 |
emirvisir
Joined: 07 Dec 2006 Posts: 42
|
Posted: Wed Oct 10, 2007 4:03 pm Post subject: |
|
|
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 |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|