I have problem with script turn off all programs

Get help with using AutoHotkey and its commands and hotkeys
ThewarII
Posts: 38
Joined: 01 Oct 2014, 09:33
Facebook: [email protected]

I have problem with script turn off all programs

15 Oct 2018, 04:34

Hello everyone, I got problem when use this script. It close some programs i don't want it close.

Code: Select all

WinGet, id, list, , ,%excluded%
Loop, %id%
{
	StringTrimRight, this_id, id%a_index%, 0
	WinGetTitle, this_title, ahk_id %this_id%
	Winclose,%this_title%
}
Return
That script made by someone, not me.
Example problem:
When i use it. It close GeForce Experience & another programs without system.
But i don't want it close GeForce Experience.
How can I exclude close it ?

Lists i want it won't close:
- Task Manager
- Program Manager
- GeForce Experience

Sorry my english isn't good.
I :superhappy: when I know about AHK.
I have been using AHK for do anything in microsoft window.
The first time I know it in around year 2013.
eelrod
Posts: 65
Joined: 10 Apr 2018, 11:17

Re: I have problem with script turn off all programs

15 Oct 2018, 07:37

Is this the full code? In the first line, there is a variable called "excluded". Somewhere above this portion of code, you can set the excluded variable to include the titles you mentioned that you don't want to close.
ThewarII
Posts: 38
Joined: 01 Oct 2014, 09:33
Facebook: [email protected]

Re: I have problem with script turn off all programs

16 Oct 2018, 01:59

Yes it's full by someone.
I tried excluded but i can't
i have another way
use with if & Array

Code: Select all

ArrayT := ["Task Manager", "Program Manager", "NVIDIA GeForce Overlay"]
WinGet, id, List,,, %excluded%
Loop, %id%
{
	TurnOff := 0
	StringTrimRight, this_id, id%a_index%, 0
	WinGetTitle, this_title, ahk_id %this_id%
	Loop % ArrayT.Length()
	{
		Xtitle := ArrayT[A_Index]
		If (this_title = Xtitle)
		{
			TurnOff++
		}
	}
	If (TurnOff < 1)
	{
		WinClose, %this_title%
	}
	Else
	{
		MsgBox, 64, We won't close it, %this_title%, 3
	}
}
But who can teach me to use multi exclude of WinGet ?
I :superhappy: when I know about AHK.
I have been using AHK for do anything in microsoft window.
The first time I know it in around year 2013.
eelrod
Posts: 65
Joined: 10 Apr 2018, 11:17

Re: I have problem with script turn off all programs

16 Oct 2018, 09:01

I see, it appears that there isn't a built-in way to include multiple names in the exclude parameter. Based on what you did above, here's what I was thinking:

Code: Select all

ArrayT := ["Task Manager" , "Program Manager" , "NVIDIA GeForce Overlay"]
WinGet , id , List
Loop % id
{
	this_id := id%A_Index%
	WinGetTitle, this_title, ahk_id %this_id%
	Loop % ArrayT.Length()
		If (ArrayT[A_Index] = this_title)
			Continue , 2
;	WinClose , %this_title%
	MsgBox, 64 , We won't close it , %this_title% , 3
}

Return to “Ask For Help”

Who is online

Users browsing this forum: flyingDman, newraiden and 252 guests