Jump to content

Kill Program


Recommended Posts

Can auto it kill a program or close a program. I am not taliknig about a window.

#NoTrayIcon

HotKeySet("^e", "Terminate")
While 1
If WinExists("NETI - Eesti Interneti Kataloog ja Otsingusüsteem - Mozilla Firefox") Then 
WinClose("NETI - Eesti Interneti Kataloog ja Otsingusüsteem - Mozilla Firefox")
MsgBox(16, "Halt!", "No internet for you!") 
EndIf 
If WinExists("NETI - Eesti Interneti Kataloog ja Otsingusüsteem - Microsoft Internet Explorer") Then 
WinClose("NETI - Eesti Interneti Kataloog ja Otsingusüsteem - Microsoft Internet Explorer")
MsgBox(16, "Halt!", "No internet for you!") 
EndIf 
 
WEnd
Func Terminate()
Exit
EndFunc

as u can see it closes when the homepages is reached, so basically, one could do so thats he opens a folder browses for favs and one could ignore the restrict. So, can i close a program, not only a window?

Link to comment
Share on other sites

  • Moderators

Check out ProcessClose() in the help file.

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

yes thanks. Thats what i was looking for.

#NoTrayIcon

HotKeySet("^e", "Terminate")
While 1
If ProcessExists("firefox.exe") Then 
ProcessClose("firefox.exe")
MsgBox(16, "Halt!", "No internet for you!") 
EndIf 
If ProcessExists("iexplore.exe") Then 
ProcessClose("iexplore.exe")

MsgBox(16, "Halt!", "No internet for you!") 
EndIf 
 
WEnd
Func Terminate()
Exit 
EndFunc

now my script is like this. But, i can't get the result i want. Basically, when u go to internet through favs no internet .exe will be executed, sadly. Anyone ideas how to cover this?

Link to comment
Share on other sites

  • Moderators

@MyPM: (Ahh... Now I understand my PM from someone :mellow::) )

@iverson_est: This might be a good opportunity to explain (in detail) step by step EXACTLY what you are trying to accomplish.

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

Maybe getting the pid from the window when it gets active?

Perhaps something like:

WinWaitActive("Google - Microsoft Internet Explorer", "")
$pid = WinGetProcess("Google - Microsoft Internet Explorer", "")
If $PID Then ProcessClose($PID)
MsgBox(16, "Halt!", "No internet for you!")
Link to comment
Share on other sites

now my script is like this. But, i can't get the result i want. Basically, when u go to internet through favs no internet .exe will be executed, sadly. Anyone ideas how to cover this?

Sounds like you want to watch for certain window title then process close

#NoTrayIcon

HotKeySet("^e", "Terminate")
While 1
    If WinExists("NETI - Eesti Interneti Kataloog ja Otsingusüsteem - Mozilla Firefox") Then 
        ProcessClose("firefox.exe")
        MsgBox(16, "Halt!", "No internet for you!") 
    EndIf 
    If WinExists("NETI - Eesti Interneti Kataloog ja Otsingusüsteem - Microsoft Internet Explorer") Then 
        ProcessClose("iexplore.exe")
        MsgBox(16, "Halt!", "No internet for you!") 
    EndIf 
    
WEnd
Func Terminate()
    Exit 
EndFunc

Edit: A Sleep in the loop might be a good idea also :)

Edited by MHz
Link to comment
Share on other sites

actually i want to prevent my sister to acess internet from MY computer :mellow:

Well my prob is that she could acess internet from any folder from favourites, pick 1 adress and ur in...

edit:

to where should place the sleep, i've tried it but where ever i put it, my hotkey wouldn't work :)

Edited by iverson_est
Link to comment
Share on other sites

  • Moderators

actually i want to prevent my sister to acess internet from MY computer :mellow:

Well my prob is that she could acess internet from any folder from favourites, pick 1 adress and ur in...

Could always take the cable from the modem or the phone coord with you when you leave the computer :)

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

I think Favorites (or Internet Shortcuts) open with this command: "rundll32.exe shdocvw.dll,OpenURL %l"

(look @ file types)

You could change it in the file types from a menu Tools -> Folder Options

Hence I doubt killing firefox.exe or iexplore.exe by process name would work :)

Edit: or even disable Favourites from the start menu, if you're using xp: Posted Image

Edited by forger
Link to comment
Share on other sites

This is a windows registry file (.reg)

(for xp pro, I'm almost 90% sure it could work on windows 2000 and the home versions of windows xp :\)

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Safer\CodeIdentifiers\0\Paths]

[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Safer\CodeIdentifiers\0\Paths\{18d8cfb8-cfce-4a97-ad63-00dc9a1fda0c}]
"LastModified"=hex(b):ec,94,f9,ea,9a,55,c6,01
"Description"=""
"SaferFlags"=dword:00000000
"ItemData"="iexplore.exe"

[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Safer\CodeIdentifiers\0\Paths\{5a6d7f2e-c931-42a6-ba1c-297d27a56c72}]
"LastModified"=hex(b):36,43,7b,67,9a,55,c6,01
"Description"=""
"SaferFlags"=dword:00000000
"ItemData"="firefox.exe"

Now, if someone can translate this into AutoIT code.. :)

after that you run: gpupdate /force

and that's it

Link to comment
Share on other sites

  • 3 weeks later...
  • 3 months later...

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