"Taskkill" #IfWinExist dont Work!!

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
Reloaded
Posts: 283
Joined: 25 Aug 2017, 08:48

"Taskkill" #IfWinExist dont Work!!

24 Sep 2017, 11:26

Hey guys :)

Can some one Help me cause my Script wont Work, would be nice ^^

Code: Select all

#IfWinExist, dllhost.exe
#IfWinExist, SearchFilterHost.exe
#IfWinExist, sppsvc.exe
#IfWInExist, SearchProtocolHost.exe
#IfWinExist, SearchFilterHost.exe
#IfWinExist, SearchProtocolHost.exe
#IfWinExist, SearchIndexer.exe
#IfWinExist, TiWorker.exe
#IfWinExist, WMIADAP.exe

Run, Cleaner
Sleep, 5000
Return


MButton::ExitApp
The Problem is, the Programms are open but my Programm (Cleaner) wont Start, and no its not the Programm (Cleaner) its #IfWinExist or so....
A_AhkUser
Posts: 1147
Joined: 06 Mar 2017, 16:18
Location: France
Contact:

Re: "Taskkill" #IfWinExist dont Work!!

24 Sep 2017, 11:54

Hi Reloaded,

The #IfWin directives are positional: they affect all hotkeys and hotstrings physically beneath them in the script. They are also mutually exclusive; that is, only the most recent one will be in effect.
source:#IfWinActive/Exist

Use Process, Exist instead - for example:

Code: Select all

for index, program in ["chrome.exe", "notepad.exe"]
{
Process, Exist, % program
if not (ErrorLevel) ;  ErrorLevel to the Process ID - evaluated as true here - if a matching process exists, or 0 - false - otherwise.
return ; at least one of the program does not exist
}
; otherwise...
MsgBox,

run command wrote: Parameters
Target
A document, URL, executable file (.exe, .com, .bat, etc.), shortcut (.lnk)
In your source your program lacks its extension. Besides, if your program is not in one of the PATH folders or in the script's working directory, the full path must be specified:

Code: Select all

Run, Cleaner.exe ; supposed to be in the script own directory
	run, notepad ; one of the "integrated" program, in the system32
my scripts
User avatar
Reloaded
Posts: 283
Joined: 25 Aug 2017, 08:48

Re: "Taskkill" #IfWinExist dont Work!!

24 Sep 2017, 13:54

Umm... Thx for the Help but its not Work D:

But i think i make something Wrong..

Code: Select all

for index, program in [dllhost.exe, SearchFilterHost.exe, sppsvc.exe, SearchProtocolHost.exe, SearchFilterHost.exe, SearchProtocolHost.exe, SearchIndexer.exe, TiWorker.exe, WMIADAP.exe, RuntimeBroker.exe]
{
Process, Exist, % program
if not (ErrorLevel) 

Run, Cleaner
Sleep, 5000

return 
}
I want if 1 of this Programms open it start my Programm (Cleaner) i would make it self but i cant. Cause this i ask you for Help !
A_AhkUser
Posts: 1147
Joined: 06 Mar 2017, 16:18
Location: France
Contact:

Re: "Taskkill" #IfWinExist dont Work!!

24 Sep 2017, 14:39

Array elements as literal strings must be enclosed in double quotes to distinguish them from variables.

Code: Select all

myPrograms := ["dllhost.exe", "SearchFilterHost.exe", "sppsvc.exe", "SearchProtocolHost.exe", "SearchFilterHost.exe", "SearchProtocolHost.exe", "SearchIndexer.exe", "TiWorker.exe", "WMIADAP.exe", "RuntimeBroker.exe"] ;  array elements as literal strings must be enclosed in double quotes to distinguish them from variables
for index, program in myPrograms
{
Process, Exist, % program
	if (ErrorLevel)
	{ ; if one of these programms exist
	Run, notepad
	Sleep, 5000
	return
	}
}
; otherwise...
; your code
my scripts
User avatar
Reloaded
Posts: 283
Joined: 25 Aug 2017, 08:48

Re: "Taskkill" #IfWinExist dont Work!!

25 Sep 2017, 01:40

Hi!

Im so sry, its me again but when i start the Script its start "Unknow Editor"

I ReInstalled Ahk but its the same Problem but just with This Script all my other Scripts Work perfect, would be nice if you Help me :)

http://tinypic.com/view.php?pic=rtqi4g&s=9#.WcikDYy0OUm

Then i Start the Script.

http://tinypic.com/view.php?pic=a2wwb7&s=9#.WcikK4y0OUm
A_AhkUser
Posts: 1147
Joined: 06 Mar 2017, 16:18
Location: France
Contact:

Re: "Taskkill" #IfWinExist dont Work!!

26 Sep 2017, 13:02

Code: Select all

Run, %A_Destktop%\cleaner.lnk
instead of:

Code: Select all

run, notepad
my scripts
User avatar
Reloaded
Posts: 283
Joined: 25 Aug 2017, 08:48

Re: "Taskkill" #IfWinExist dont Work!!

27 Sep 2017, 06:53

Hello!

Thank you !, but the Script dont work !.
If 1 of these programms are open the programm didn`t start and that´s bad :(

So the Script look like by me now.

Code: Select all

myPrograms := ["dllhost.exe", "SearchFilterHost.exe", "sppsvc.exe", "SearchProtocolHost.exe", "SearchFilterHost.exe", "SearchProtocolHost.exe", "SearchIndexer.exe", "TiWorker.exe", "WMIADAP.exe", "RuntimeBroker.exe"]

{
Process, Exist, % program
	if (ErrorLevel)
	{ 
	Run, Clenaer
	Sleep, 5000
	return
	}
}
return
User avatar
KuroiLight
Posts: 327
Joined: 12 Apr 2015, 20:24
Contact:

Re: "Taskkill" #IfWinExist dont Work!!

27 Sep 2017, 11:33

you don't give enough context to see whats wrong, we need the whole script
this is all I can do with what you posted
copy & paste

Code: Select all

myPrograms := ["dllhost.exe", "SearchFilterHost.exe", "sppsvc.exe", "SearchProtocolHost.exe", "SearchFilterHost.exe", "SearchProtocolHost.exe", "SearchIndexer.exe", "TiWorker.exe", "WMIADAP.exe", "RuntimeBroker.exe"]

for i, v in myPrograms {
    Process, Exist, %v%
    if(ErrorLevel) {
        Run, .\Cleaner.lnk
        Sleep, 5000
        return
    }
}
return
Windows 10, Ryzen 1600, 16GB G.Skill DDR4, 8GB RX 480 | [MyScripts][MySublimeSettings] [Unlicense][MIT License]
01/24/18
[/color]
User avatar
Reloaded
Posts: 283
Joined: 25 Aug 2017, 08:48

Re: "Taskkill" #IfWinExist dont Work!!

27 Sep 2017, 11:41

Thx to try help me ! but my problem is, i designed a (Cleaner) it close all other porgramms i didnt need, but i need to start the programm "Manuel" and i want to make a Script, if 1 of these Programms open it start the (Cleaner).

I have try it with, #IfWinExist , #IfWinActive , ErrorLevel and much more but nothing Work, maybe it help you with this Script !

Code: Select all

q::
	WinGet, PID, PID, A
	Process, Close, %PID%
Return
Maybe you can help me and this Script be usefull for you idk.. i try my best.

Thx!
User avatar
KuroiLight
Posts: 327
Joined: 12 Apr 2015, 20:24
Contact:

Re: "Taskkill" #IfWinExist dont Work!!

27 Sep 2017, 11:52

Do you want to script to run all the time?
Windows 10, Ryzen 1600, 16GB G.Skill DDR4, 8GB RX 480 | [MyScripts][MySublimeSettings] [Unlicense][MIT License]
01/24/18
[/color]
User avatar
Reloaded
Posts: 283
Joined: 25 Aug 2017, 08:48

Re: "Taskkill" #IfWinExist dont Work!!

27 Sep 2017, 11:58

Like so it Check all "1 Min" if 1 of these programms open.
User avatar
KuroiLight
Posts: 327
Joined: 12 Apr 2015, 20:24
Contact:

Re: "Taskkill" #IfWinExist dont Work!!

27 Sep 2017, 11:59

Here:

Code: Select all

#Persistent
#NoEnv
SetWorkingDir %A_ScriptDir%
myPrograms := ["dllhost.exe", "SearchFilterHost.exe", "sppsvc.exe", "SearchProtocolHost.exe", "SearchFilterHost.exe", "SearchProtocolHost.exe", "SearchIndexer.exe", "TiWorker.exe", "WMIADAP.exe", "RuntimeBroker.exe"]

SetTimer, KILLLOOP, 5000
Return

KILLLOOP:
    for i, v in myPrograms {
        Process, Exist, %v%
        if(ErrorLevel) {
            Run, %A_Desktop%\Cleaner.lnk
            return
        }
    }
return
I do not recommend killing dllhost or sppsvc as this can actually cause some things to crash/break, and some of these can be safely disabled altogether in services.msc, refer to my post here: https://autohotkey.com/boards/viewtopic.php?f=5&t=37303
Last edited by KuroiLight on 27 Sep 2017, 12:02, edited 1 time in total.
Windows 10, Ryzen 1600, 16GB G.Skill DDR4, 8GB RX 480 | [MyScripts][MySublimeSettings] [Unlicense][MIT License]
01/24/18
[/color]
User avatar
Reloaded
Posts: 283
Joined: 25 Aug 2017, 08:48

Re: "Taskkill" #IfWinExist dont Work!!

27 Sep 2017, 12:01

Error at line 3.

Line Text: #SetWorkingDir, %A_ScriptDir%
Error: This line does not contain a recoganized action.

The programm will exit.
User avatar
KuroiLight
Posts: 327
Joined: 12 Apr 2015, 20:24
Contact:

Re: "Taskkill" #IfWinExist dont Work!!

27 Sep 2017, 12:02

its fixed, recopy
and if you want 1 minute, change 5000 to 60000
Windows 10, Ryzen 1600, 16GB G.Skill DDR4, 8GB RX 480 | [MyScripts][MySublimeSettings] [Unlicense][MIT License]
01/24/18
[/color]
User avatar
Reloaded
Posts: 283
Joined: 25 Aug 2017, 08:48

Re: "Taskkill" #IfWinExist dont Work!!

27 Sep 2017, 12:05

Omg! It`s Work. Thank you ! I love you now xD
User avatar
Reloaded
Posts: 283
Joined: 25 Aug 2017, 08:48

Re: "Taskkill" #IfWinExist dont Work!!

27 Sep 2017, 12:14

Hey, it`s me again, you know how to make a ImageSearch Script ? .

I asked for help in other Forum but they laughed me out cause i dont know how to make an so "Easy" Script.
User avatar
KuroiLight
Posts: 327
Joined: 12 Apr 2015, 20:24
Contact:

Re: "Taskkill" #IfWinExist dont Work!!

27 Sep 2017, 12:28

Ive not yet used ImageSearch, but if you want help with it please make a new thread;
I think you got the reply you did because you didn't provide any code you tried, you should provide an example of what you tried and a description of what you are trying to do so the person helping will have some context for what you need.
Always start at the docs, and if you can't figure it out search for posts via google: search with keywords ahk ImageSearch
https://autohotkey.com/docs/commands/ImageSearch.htm
Windows 10, Ryzen 1600, 16GB G.Skill DDR4, 8GB RX 480 | [MyScripts][MySublimeSettings] [Unlicense][MIT License]
01/24/18
[/color]
User avatar
Reloaded
Posts: 283
Joined: 25 Aug 2017, 08:48

Re: "Taskkill" #IfWinExist dont Work!!

27 Sep 2017, 12:36

Ohh, trust me, i tried so much ImageSearch codes but no one work and i dont know why, but thx i give my best and Thank you for the great Help!.

And i releas in 1H a list of very usefull Scripts for beginners maybe you can look in Scripts and Functions. ;D

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: FanaticGuru, mikeyww, OrangeCat and 128 guests