Sign in to follow this  
Followers 0
iverson_est

Kill Program

15 posts in this topic

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?

Share this post


Link to post
Share on other sites



Check out ProcessClose() in the help file.


[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

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?

Share this post


Link to post
Share on other sites

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


[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

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!")

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

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

Share this post


Link to post
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...

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

[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

#9 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

yeah but she is smart enough to plug it in :)

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Er, although it may be a little too late to ask for, but why don't you use a password to protect your account(s)? :)

Share this post


Link to post
Share on other sites

i dont want to protect account, mainly just doing it to learn autoit better :)

Share this post


Link to post
Share on other sites

Well you could use Valuater's Computer Lock program. You can view the source and change the pass to whatever you like. Very useful, and almost impossible to get through. OR, just set password to screensaver (if you on XP). HEHE :whistle:


- Dan [Website]

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