Jump to content

Preventing application to close


Iwan
 Share

Recommended Posts

Cheers,

I would like to make a program that prevents a program to close

when a user hits the X mark on the top right of the window is this

at al possible using AutoIt? And if possible how to accomplish this. :">

Greetz,

Iwan

Link to comment
Share on other sites

I can understand why this seems to be a malicious coding script :lmao:

But at my work we use citrix sessions all the time but users keep

closing these sessions using the X button. I would like them to logoff

and not leaving their sessions opent (this saves resources on the servers). I thought of something like capturing the WM_CLOSE message send to the ica client and not forwarding it to the client. But is this possible?

Cheers,

iwan

Link to comment
Share on other sites

i think there is a way... not completely sure how Intricate your program is.. network etc

everyone has their respective "specialties" here

there are others here, whom possibly could help you better

if i can think of something, i will let you know

( i did find your WM_ClOSE in the help file)

8)

NEWHeader1.png

Link to comment
Share on other sites

i think there is a way... not completely sure how Intricate your program is.. network etc

everyone has their respective "specialties" here

there are others here, whom possibly could help you better

if i can think of something, i will let you know

( i did find your WM_ClOSE in the help file)

8)

I hope there is a way to solve this :lmao: It is not meant to be executed via network. Running it

local on the fat-client will be sufficient. Anybody got an idea how to peek in the message queue

of a different program or intercept a message send to the citrix client?!

Regards

Link to comment
Share on other sites

  • Moderators

oh sorry .. Make an new progam that detect if it is close , if its closed restart your progam with the other ?

The whole point is to make sure it 'Doesn't' close without logging off first I believe.

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

Hmm its tcp ip is it ?

You can it allways .. you cant block a kill or close event

And if you got it , you got always a restet knop on your pc

if its tcp ip you can make a server that checks if anyone is dropedout

-jaenster

Link to comment
Share on other sites

Checkout This topic


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

Checkout This topic

Pretty nice, but ALT+F4 will still work I think.

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

how about just using MouseTrap() to confine the mouse to the workable window area, and using this:

#include<file.au3>
Opt("WinTitleMatchMode",4)
HotKeySet("!{F4}","DoNotCloseYourCitrixWindowWithHotkeysYouBastard")
Func DoNotCloseYourCitrixWindowWithHotkeysYouBastard()
If WinGetTitle("active") = "Citrix Title") Then
msgbox(0,"Stop it!!!","Log out of your citrix connection correctly.")
_FileWriteLog("l:\RandomShare\Log.txt",@UserName & " tried to close citrix with a hotkey, fire them as soon as possible to keep the others in line.")
EndIf
EndFunc
Link to comment
Share on other sites

how about just using MouseTrap() to confine the mouse to the workable window area, and using this:

#include<file.au3>
Opt("WinTitleMatchMode",4)
HotKeySet("!{F4}","DoNotCloseYourCitrixWindowWithHotkeysYouBastard")
Func DoNotCloseYourCitrixWindowWithHotkeysYouBastard()
If WinGetTitle("active") = "Citrix Title") Then
msgbox(0,"Stop it!!!","Log out of your citrix connection correctly.")
_FileWriteLog("l:\RandomShare\Log.txt",@UserName & " tried to close citrix with a hotkey, fire them as soon as possible to keep the others in line.")
EndIf
EndFunc
:lmao: *muhahaha* that might help. I like your function name and reading the log.txt will be fun every noon.

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

...but ALT+F4 will still work I think...

AutoItSetOption("WinTitleMatchMode", 4)

Run("calc")
WinWait("Calculator")
$calcHwnd = WinGetHandle("Calculator")

$menu = DllCall("user32.dll", "hwnd", _
        "GetSystemMenu", "hwnd", _
        $calcHwnd, "int", 0)
DllCall("user32.dll", "int", _
        "RemoveMenu", "hwnd", _
        $menu[0], "int", _
        0xF060, "int", 0x0);SC_CLOSE

While 1
    If WinActive($calcHwnd) Then
        HotKeySet("!{F4}", "trap")
    Else
        HotKeySet("!{F4}")
    EndIf
    Sleep(30)
WEnd

Func trap()
EndFunc  ;==>trap
DllCall courtesy of CyberSlug.

Edit1: The Alt-F4 won't get passed to the app.

Edit2: Changed code to let Alt-F4 work for other apps...

Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

:lmao: *muhahaha* that might help. I like your function name and reading the log.txt will be fun every noon.

So long,

Mega

with the mousetrap() keeping the mouse off of the X, that should about do it. unless they really want to be defiant and use the task manager, but they'd probably have already tried alt-f4 by that point, so it's ok to let them think they've defeated your scheme until they're fired.
Link to comment
Share on other sites

@herewasplato: That´s cool. Maybe I can use something like that for playing a joke on my friends. ;)

@cameronsdad: So, schadenfreude seems to be the same all over the world. :lmao:

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

I changed the code in the post above a bit to allow Atl-F4 to work on other windows/apps...

...but I have a somewhat related question:

Is this loop better than using one If/Else/EndIf?

While 1
    If WinActive($calcHwnd) Then HotKeySet("!{F4}", "trap")
    If Not WinActive($calcHwnd) Then HotKeySet("!{F4}")
    Sleep(30)
WEnd
The help files states:

This version of the If statement is used to execute a single statement without the overhead of an EndIf.

@Mega: "schadenfreude" - I had to go look that one up.

Yes, it seems to be the same the world over. :-)

[size="1"][font="Arial"].[u].[/u][/font][/size]

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...