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 

Make MsgBox AlwaysOnTop + Inactive

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



Joined: 02 Feb 2008
Posts: 626

PostPosted: Sat Jan 30, 2010 2:22 am    Post subject: Make MsgBox AlwaysOnTop + Inactive Reply with quote

As the title says
Back to top
View user's profile Send private message Visit poster's website
geekdude



Joined: 23 Nov 2009
Posts: 64

PostPosted: Sat Jan 30, 2010 3:56 am    Post subject: Reply with quote

umm... because you are well known, i will givu u script, but next time, show some effort

Code:
WinGetActiveTitle, Title
MsgBox, The active window is "%Title%".
winset, alwaysontop, a
winactivate, %title%
return

_________________
  /\ /\ This is Kitty
(>';'<) Cut, copy, and paste kitty onto your sig.
((")(")) Help Kitty gain World Domination.

(\__/) This is Bunny.
(='.'=) Cut, copy, and paste bunny onto your sig.
(")_(") Help Bunny gain World Domination.
Back to top
View user's profile Send private message
MasterFocus



Joined: 08 Apr 2009
Posts: 3035
Location: Rio de Janeiro - RJ - Brasil

PostPosted: Sat Jan 30, 2010 4:26 am    Post subject: Reply with quote

I was going to provide a similar code,
but I suppose that you want the MsgBox to appear without being activated...
right?
_________________
"Read the manual. Read it again. Search the forum.
Try something before asking. Show what you've tried.
"

Antonio França
My stuff: Google Profile
Back to top
View user's profile Send private message Visit poster's website
jethrow



Joined: 24 May 2009
Posts: 1907
Location: Iowa, USA

PostPosted: Sat Jan 30, 2010 6:39 am    Post subject: Reply with quote

Quote:
I suppose that you want the MsgBox to appear without being activated...

Wink
Code:
FileAppend, % "#NoTrayIcon`nWinActivate, ahk_id" WinExist( "A" ), temporary.ahk
FileSetAttrib, +H, temporary.ahk
Run, temporary.ahk
MsgBox, 262144, Title, Message
FileDelete, temporary.ahk


EDIT - For some reason I thought MsgBox would supersede a timer Embarassed . This is inspired by TheHangman's post below:
Code:
hwnd := WinExist( "A" )
SetTimer, DeactivateMsgBox, 10
MsgBox, 262144, Title, Message
Return

DeactivateMsgBox:
   If Not WinActive( "ahk_class #32770" )
      Return
   WinActivate, ahk_id %hwnd%
   SetTimer, DeactivateMsgBox, Off
Return

_________________
Very Happy - in case I forgot to smile
Basic Webpage Controls
COM Object Reference


Last edited by jethrow on Sat Jan 30, 2010 8:26 am; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
SoLong&Thx4AllTheFish



Joined: 27 May 2007
Posts: 4999

PostPosted: Sat Jan 30, 2010 7:26 am    Post subject: Reply with quote

Have a look at Notify(), pretty, always on top and you can make it "clickable" as well but doesn't get in the way due to its toaster popup style.
_________________
AHK Wiki FAQ
TF : Text files & strings lib, TF Forum
Back to top
View user's profile Send private message
TheHangman
Guest





PostPosted: Sat Jan 30, 2010 7:40 am    Post subject: Reply with quote

hmm.... that code (by geekdude) will not work. He forgot that the script (thread) halts until the msgbox is dismissed. This (crude) code shows a way to do it, basicly it starts a new thread to continue running the main code.
Code:

WinGetActiveTitle, Title
msgboxTitle = Always On Top

SetTimer, Continue, -50
MsgBox,, %msgboxTitle%, The active window is "%Title%".

Continue:
WinWait, %msgboxTitle%
WinSet, alwaysontop, On, %msgboxTitle%
winactivate, %title%
ToolTip, original window activated and script continues
WinWaitClose, %msgboxTitle%
ToolTip
MsgBox, the Always On Top msgbox has been closed

ExitApp
Back to top
a_h_k



Joined: 02 Feb 2008
Posts: 626

PostPosted: Mon Feb 01, 2010 6:44 am    Post subject: Reply with quote

This is what i had when i posted this thread
Code:
SetTitleMatchMode, 3
GroupAdd, MsgBox_group,, Hotkey is now running

SetTimer, here, -1000     ;use no less than ~1000, so doesn't open MsgBox as hidden

MsgBox,,, Hotkey is now running, 2

here:
  WinWait,, Hotkey is now running
  WinSet, AlwaysOnTop, On,, Hotkey is now running
  GroupDeactivate, MsgBox_group, R
Return

Tweaked it a bit, and currently using...
Code:
SetTitleMatchMode, 3
GroupAdd, MsgBox_group,, Hotkey is now running

SetTimer, here, -1

MsgBox, 262144,, Hotkey is now running, 2     ;thnks jethrow! (saves an extra line)

here:
  WinShow,, Hotkey is now running     ;so can use SetTimer...-1
  WinWait,, Hotkey is now running
  GroupDeactivate, MsgBox_group, R
Return


It's not perfect, but it works ok

MasterFocus wrote:
I suppose that you want the MsgBox to appear without being activated?
Ideally, it would appear inactive right from the get-go (i think this could be done using "Gui")

hugov wrote:
Have a look at Notify(), pretty, always on top and you can make it "clickable" as well but doesn't get in the way due to its toaster popup style
Before i would consider sth like that, i would like to exhaust all possible options using ahk's standard MsgBox & identical-to-MsgBox GUI
Back to top
View user's profile Send private message Visit poster's website
a_h_k



Joined: 02 Feb 2008
Posts: 626

PostPosted: Mon Feb 01, 2010 7:12 am    Post subject: Reply with quote

For interest, my other "parallel" thread --> Script not Exiting
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
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