Sign in to follow this  
Followers 0
Infinitex0

Closing a file.

8 posts in this topic

(Hi) I trying to make a scipt that is present at startup and closes a certain file whenever it is activated

WinWait( "X")
If WinActive("X") Then
WinKill( "X")
Sleep(3000)
EndIf

whenever I run it, I open x and the autoit icon disappears, but x is still open.

PLEASE don't give me a new code, just tell me what I am doing wrong :lmao:


The below statement is False.The above statement is True.a lesson I learned from Greenmachine; give a man a code and he'll solve one problem. Teach a man to code and he'll solve all his problems.P.S please don't use autoIt as a virus creator/spyware maker(keyLogger especially)Cick this and help me[center]My Scripts:[/center][center]Port Scanner[/center]

Share this post


Link to post
Share on other sites



Three things:

1. Are you sure "X" is active when it starts up? If not, the winkill won't work.

2. According to the helpfile, some windows, notably explorer windows, cannot be killed. If your window is one of these special ones, you might want to try WinClose instead.

3. To guarantee that "X" is active when you need it to be, I would use WinWaitActive instead.

Share this post


Link to post
Share on other sites

The following works for me (when opening the file "test.txt" in Notepad:

While 1
    If WinExists ( "test.txt - Notepad", "" ) Then
        Sleep(200)
        WinKill( "test.txt - Notepad", "" )
    EndIf
WEnd

Try using WinExists and a While-WEnd loop.

Cheers,

Def

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Thanks greenmachine and DeFuser.

Edited by Infinitex0

The below statement is False.The above statement is True.a lesson I learned from Greenmachine; give a man a code and he'll solve one problem. Teach a man to code and he'll solve all his problems.P.S please don't use autoIt as a virus creator/spyware maker(keyLogger especially)Cick this and help me[center]My Scripts:[/center][center]Port Scanner[/center]

Share this post


Link to post
Share on other sites

I'm glad to assist. More than you know actually, because this is the first time I've actually been able to contribute (as opposed to ask questions). :lmao:

Cheers,

Def

Share this post


Link to post
Share on other sites

I'm glad to assist. More than you know actually, because this is the first time I've actually been able to contribute (as opposed to ask questions). :lmao:

Cheers,

Def

You only joined 2 days ago DeFuser... You'll contribute much more soon, I'm sure!! ;)


[center]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.[/center]

Share this post


Link to post
Share on other sites

You only joined 2 days ago DeFuser... You'll contribute much more soon, I'm sure!! ;)

Ahhh, thanks for the encouragement! I figure that while true proficiency is still a (long) way off, at least the code snippets I stumple across are beginning to look less gibberishish ... and that's a definite good sign!

:lmao:

Share this post


Link to post
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
Sign in to follow this  
Followers 0