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 

How to find the window title name last but one ...

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



Joined: 23 Jan 2006
Posts: 37
Location: Vadodara - Gujarat (INDIA)

PostPosted: Thu Aug 24, 2006 10:49 am    Post subject: How to find the window title name last but one ... Reply with quote

Hello Friends,

I have a small problem. I know how to find last activated window. But I need to know last but one activated window title.
For an Example :
--------------------
Step : 1 I opened Excel application, so my active window title would be 'Microsoft Excel - Book1'
2 Now I click 'File --> Print', so my active window title would be 'Print'.

My objective is to find : last_but_one_window := 'Microsoft Excel - Book1'.
I need to close the 'Print' window if it is activated from Excel application only & not in case my 'Print' window is activated from any other application.

How do I do it ?

Thanks well in Advance !

Kind Regards,

Raju C Padaria
Back to top
View user's profile Send private message
BoBo
Guest





PostPosted: Thu Aug 24, 2006 11:03 am    Post subject: Reply with quote

Code:
SetTimer, PrevWin, 500
Return

PrevWin:
WinGetActiveStats, Title, Width, Height, X, Y
If Title = %PrevTitle%
   Return
PrevTitle := Title
Return

!y::ToolTip %PrevTitle
Might be nonsense ...
Back to top
SanskritFritz



Joined: 17 Feb 2005
Posts: 283
Location: Hungary, Budapest

PostPosted: Thu Aug 24, 2006 11:09 am    Post subject: Reply with quote

In Excel you are able to define a button / menu entry / shortcut to print to the default printer, without the dialog box. This will start printing immediately. It that is what you want.
_________________
Is there another word for synonym?
Back to top
View user's profile Send private message
padarrju



Joined: 23 Jan 2006
Posts: 37
Location: Vadodara - Gujarat (INDIA)

PostPosted: Thu Aug 24, 2006 11:13 am    Post subject: Reply with quote

SanskritFritz wrote:
In Excel you are able to define a button / menu entry / shortcut to print to the default printer, without the dialog box. This will start printing immediately. It that is what you want.


No, When I open, Excel & then try to print the worksheet, my script should stop me with a message 'This function is disabled ...'. But if I open any other application, say, MS word & then try to print the document, it should allow me to print.

Thanks !

Best Regards,

Raju C Padaria
Back to top
View user's profile Send private message
SanskritFritz



Joined: 17 Feb 2005
Posts: 283
Location: Hungary, Budapest

PostPosted: Thu Aug 24, 2006 11:15 am    Post subject: Reply with quote

Another idea: the parent window of Excel's Print dialog is Excel itself. So my question is: how to find out the parent of a dialog window? A Dll call perhaps?
_________________
Is there another word for synonym?
Back to top
View user's profile Send private message
BoBo
Guest





PostPosted: Thu Aug 24, 2006 11:21 am    Post subject: Reply with quote

[How to close a window based on previously opened window ...]
What was the outcome of that/your previous request, which is quite similar to this one ? (thought to ask first before getting really p..sed Confused)
Back to top
BoBo
Guest





PostPosted: Thu Aug 24, 2006 11:26 am    Post subject: Reply with quote

Looks like I've hit the 70.000 post with my previous one Shocked
Back to top
SanskritFritz



Joined: 17 Feb 2005
Posts: 283
Location: Hungary, Budapest

PostPosted: Thu Aug 24, 2006 11:31 am    Post subject: Reply with quote

Found it: hw_parent := DllCall( "GetParent", "uint", hw_active )
So, get the hwnd of the active Print dialog, get the hwnd of the parent and if it is excel (WinGetClass), close the dialog. Let us know if this works, I'm not sure if GetParent can be used this way.
_________________
Is there another word for synonym?
Back to top
View user's profile Send private message
PhiLho



Joined: 27 Dec 2005
Posts: 6721
Location: France (near Paris)

PostPosted: Thu Aug 24, 2006 12:18 pm    Post subject: Reply with quote

BoBo wrote:
Looks like I've hit the 70.000 post with my previous one Shocked
How do you know this?
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Back to top
View user's profile Send private message Visit poster's website
SKAN



Joined: 26 Dec 2005
Posts: 6223

PostPosted: Thu Aug 24, 2006 12:38 pm    Post subject: Reply with quote

PhiLho wrote:
BoBo wrote:
Looks like I've hit the 70.000 post with my previous one Shocked
How do you know this?


http://img242.imageshack.us/img242/9715/70000gk9.png

Regards, Smile
_________________
Back to top
View user's profile Send private message
SanskritFritz



Joined: 17 Feb 2005
Posts: 283
Location: Hungary, Budapest

PostPosted: Fri Aug 25, 2006 7:54 am    Post subject: Reply with quote

padarrju, people are trying to help here in the forum. If you dont give any feedback (and checking your posts, lately your are prone to do that), soon you will not get any help. We feed our ego on positive (or negative) reactions Wink . Just a quick "thanks it worked, here is my code", or "that didnt help at all, can you give me other advices?" would suffice, just for us to see that we did not try to help in vain Smile
_________________
Is there another word for synonym?
Back to top
View user's profile Send private message
PhiLho



Joined: 27 Dec 2005
Posts: 6721
Location: France (near Paris)

PostPosted: Fri Aug 25, 2006 8:40 am    Post subject: Reply with quote

SanskritFritz wrote:
[We feed our ego on positive (or negative) reactions Wink
Well put...
Well, sometime people take time to answer, being busy, absent, in holidays...
I see no answers as "it worked", otherwise we would have another question...

@Goyyah: you understood BoBo better than me, I naively thought that he posted 70,000 messages... Indeed, it was stupid.
Note: I suppose that ImageShack images won't be kept eternally, so for the curious, I reproduce the relevant line: Our users have posted a total of 70000 articles from the "Who is Online" box of the forum home page.
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Back to top
View user's profile Send private message Visit poster's website
padarrju



Joined: 23 Jan 2006
Posts: 37
Location: Vadodara - Gujarat (INDIA)

PostPosted: Sat Aug 26, 2006 5:40 am    Post subject: Reply with quote

SanskritFritz wrote:
padarrju, people are trying to help here in the forum. If you dont give any feedback (and checking your posts, lately your are prone to do that), soon you will not get any help. We feed our ego on positive (or negative) reactions Wink . Just a quick "thanks it worked, here is my code", or "that didnt help at all, can you give me other advices?" would suffice, just for us to see that we did not try to help in vain Smile


You are right but sometime people take time to answer, being busy, absent, on leaves, etc. as one of our friends (Mr. PhilHo) has already point out it. Sorry for not replying early. I will take care in future.

Hoever, till the time I was working on my requirement & I have found out the solution with your valuable support, I never forget. The program code is given below : (May be helpful to any one of us for such requirement).
Code:
#SingleInstance ignore
#NoTrayIcon

Loop
{
     ifwinactive, Print
     {
          IfWinExist, gp_frq: Previewer
           {
    WinKill, Print
    BlockInput,On
;                 msgbox,4096, , This function is disabled ...`n`nPlease Close the report of`nLeave / Muster / GatePass / Comp. Off`nfirst & then Proceed ...,5
    SplashTextOn, 300,150, Printing Disabled,This function is disabled`n`nPlease Close the report of`nLeave / Muster / GatePass / Comp. Off`nfirst && then Proceed ...
    Sleep,5000
    SplashTextOff
    Sleep,1000
    BlockInput, Off
    IfWinNotActive, gp_frq: Previewer
                      {
                WinActivate, gp_frq: Previewer
                             sleep,500
                      }
                 else
                      {
               sleep, 500
                      }
           }
     }

     ifwinactive, Save
     {
          IfWinExist, gp_frq: Previewer
           {
    WinKill, Save
    BlockInput,On
;                 msgbox,4096, , This function is disabled ...`n`nPlease Close the report of`nLeave / Muster / GatePass / Comp. Off`nfirst & then Proceed ...,5
    SplashTextOn, 300,150, Printing Disabled,This function is disabled ...`n`nPlease Close the report of`nLeave / Muster / GatePass / Comp. Off`nfirst && then Proceed ...
    Sleep,5000
    SplashTextOff
    Sleep,1000
    BlockInput, Off
    IfWinNotActive, gp_frq: Previewer
                      {
                WinActivate, gp_frq: Previewer
                             sleep,500
                      }
                 else
                      {
               sleep, 500
                      }
           }
     }
}
[Moderator's note: added code section around the script for better readability (indentation).]


Thanks a lot !

Best Regards,

Raju C Padaria
Back to top
View user's profile Send private message
SanskritFritz



Joined: 17 Feb 2005
Posts: 283
Location: Hungary, Budapest

PostPosted: Mon Aug 28, 2006 7:58 am    Post subject: Reply with quote

ohhhh, now my ego is well fed Wink
even tho i dont see any of my advices in your code, hehe
_________________
Is there another word for synonym?
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