Jump to content

Action when a user presses the X on the right of a program


Recommended Posts

Hi all,

Is it possible to let a Traytip appear when users are trying to close a window by clicking on the X sign of the program. It's another thing for that security program where I told you guys about.

Thanks,

PcExpert

Link to comment
Share on other sites

#include <GUIConstants.au3>
; == GUI generated with Koda ==);
$Form1 = GUICreate("AForm1", 253, 198, 192, 125)
GUISetState(@SW_SHOW)
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        TrayTip("I'm a title", "I'm the message", 5, 1)
    Case Else
    ;;;;;;;
    EndSelect
WEnd


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
Share on other sites

Thats for my program. But If they have to leave another window open how do I do that then?

I am sorry but I do not understand what you want.


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
Share on other sites

If you want to some else window stay open:

;BigDod's code start
#include <GUIConstants.au3>
; == GUI generated with Koda ==);
$Form1 = GUICreate("AForm1", 253, 198, 192, 125)
GUISetState(@SW_SHOW)
;BigDod code end
;My modified code
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        TrayTip("I'm a title", "I'm the message", 5, 1)
        GuiDelete($Form1) ;This deletes only that window
    Case Else
    ;;;;;;;
    EndSelect
WEnd

Not tested.

i542

I can do signature me.

Link to comment
Share on other sites

Sorry, that's not what I mean. (maybe I'm giving you to little information) What I mean is for Example:

Open Firefox. When you're trying to close it with the X presented at the upper right corner of the program, it will not close. Instead of closing the program it displays a tooltip. So the user will not be able to close it.

Edited by PcExpert
Link to comment
Share on other sites

Ooh, sorry. What I want is the same as what you discribe, but then with a program for example notepad, Firefox or IE

You could create a small window in the topright corner which covers the x-button and captures the press, displays the tooltip and does any other thing you like. And if you want to close the window anyway, just Send alt+F4.

Alzo

Don't take my pic to serious...~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~You Looked, but you did not see!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Link to comment
Share on other sites

OK, thanks! That's an option too. Does somebody know a method to do that without a GUI?

Take a closer look at the Windows API functions SetWindowsHookEx (WH_CALLWNDPRO) and CallWndProc.

Cheers

Kurt

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Link to comment
Share on other sites

OK, thanks. I tried something with Pixel get color, but that didn't seem to work the way I wanted. So I understand that there's no other way in autoit then do it with the functions discribed in the post of /dev/null

Edited by PcExpert
Link to comment
Share on other sites

  • Moderators

OK, thanks. I tried something with Pixel get color, but that didn't seem to work the way I wanted. So I understand that there's no other way in autoit then do it with the functions discribed in the post of /dev/null

That definately looks like the way to do it to me for an outside process/window, but I remember someone else several months ago asking the same question... Unfortunately, I can't for the life of me remember the title or the person that made the question :D

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

OK, now I got it working with the code from i542, but if I activeate the firefox window then the titlebar from my program disappears behind firefox. Is there a way to let it always be active, even if you activate another window, so the titlebar will allways be visible?

Link to comment
Share on other sites

  • Moderators

WinSetOnTop()?

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

OK, thanks. I putted that in the script, but it doesn't work:

#include <GUIConstants.au3>

HotKeySet("!{F4}", "ALT")
WinSetOnTop ( "Habbo ~ Habbo Hotel - Mozilla Firefox", "", 1)
GUICreate("Habbo ~ Habbo Hotel - Mozilla Firefox", @DesktopWidth, 1, 0, 0)  ; will create a dialog box that when displayed is centered
GUISetState (@SW_SHOW)       ; will display an empty dialog box

; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()
    
    If $msg = $GUI_EVENT_CLOSE Then MyFunction()
Wend

WinSetOnTop ( "Habbo ~ Habbo Hotel - Mozilla Firefox", "", 1)

Func alt()
    TrayTip("Beveiliging", "Handig he, zo'n beveiliging tegen lastige zusjes", "", 2)
    Sleep(3000)
    TrayTip("", "", "")
EndFunc    

Func MyFunction()
    TrayTip("Beveiliging", "Handig he, zo'n beveiliging tegen lastige zusjes", "")
    Sleep(3000)
    TrayTip("", "", "")
EndFunc
Link to comment
Share on other sites

  • Moderators

Try putting WinSetOnTop() after GUISetState(@SW_SHOW), because the window doesn't exist yet the way you have it.

Example:

#include <GUIConstants.au3>

HotKeySet("!{F4}", "ALT")
$GUI = GUICreate("Habbo ~ Habbo Hotel - Mozilla Firefox", @DesktopWidth, 1, 0, 0)  ; will create a dialog box that when displayed is centered
GUISetState (@SW_SHOW)       ; will display an empty dialog box

WinSetOnTop ($GUI, "", 1)
; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()
   
    If $msg = $GUI_EVENT_CLOSE Then MyFunction()
Wend

Func alt()
    TrayTip("Beveiliging", "Handig he, zo'n beveiliging tegen lastige zusjes", "", 2)
    Sleep(3000)
    TrayTip("", "", "")
EndFunc   

Func MyFunction()
    TrayTip("Beveiliging", "Handig he, zo'n beveiliging tegen lastige zusjes", "")
    Sleep(3000)
    TrayTip("", "", "")
EndFunc

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...