Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: autoit script help!

29 May 2017   #1
savinio0

windows xp c86
 
 
autoit script help!

Hi all
On this wonderful forum i found this autoit interesting script:
How to close a software automatically when it's idle? - Windows 7 Help Forums

Can someone modify this script to STOP and Close automatically ''My-Xtool.exe'' from processes?not from aplications,but only when is idle for more then 1 min.,is possible that?
I run My-Xtool.exe and i see how bytes values are changing,but sometimes that values are static they don't change value anymore that means my .exe goes IDLE,then i want to stop the process automatically,can anyone help me with that please?
thank you


My System SpecsSystem Spec
.
30 May 2017   #2
Pyprohly

Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
 
 

@UsernameIssues’ original script used the window title to identify a process, but it appears you want to identify a process by its name instead (“My-Xtool.exe”), so I’ve written a new solution that does this.

Code:
;;;
Local $sProcessName = 'notepad.exe'
Local $iTimeDelta = 60 * 1000 ; one minute
;;;

Func _WinHwndListFromPID($iPID)
   Local $aWinHwndList[1][2]

   Local $aWinList = WinList()
   For $i = 1 To $aWinList[0][0]
	  If (WinGetProcess($aWinList[$i][1]) = $iPID) And BitAND(WinGetState($aWinList[$i][1]), 1) Then
		 $iListSize = UBound($aWinHwndList)
		 ReDim $aWinHwndList[$iListSize + 1][2]
		 $aWinHwndList[$iListSize][0] = $aWinList[$i][0]
		 $aWinHwndList[$iListSize][1] = $aWinList[$i][1]
	  EndIf
   Next

   $aWinHwndList[0][0] = UBound($aWinHwndList) - 1

   Return $aWinHwndList
EndFunc

If Not ProcessExists($sProcessName) Then
   MsgBox(48, 'Process not found', 'The process "' & $sProcessName & '" could not be found. The script will continue executing.')
EndIf

Local $fTimer = TimerInit()
While 1
   ConsoleWrite(TimerDiff($fTimer) & @CRLF)

   $aWinList = _WinHwndListFromPID(ProcessExists($sProcessName))

   If $aWinList[0][0] Then
	  If BitAND(WinGetState($aWinList[1][1]), 8) Then
		 $fTimer = TimerInit()
	  EndIf
   EndIf

   If TimerDiff($fTimer) >= $iTimeDelta Then
	  ProcessClose($sProcessName)
   EndIf

   Sleep(1000)
WEnd
My System SpecsSystem Spec
Reply

 autoit script help!




Thread Tools




Similar help and support threads
Thread Forum
Windows Script Host: Can not find script file ?
Hello & Thanks , win7 x64 Starting yesterday , I keep getting the following message: Windows Script Host Can not find script file "C:\ProgramData\{95137DD0-C591-AC56-7417-DCD4A4950F5A}\2.0.1.9\lare.txt". Any idea why and how to fix it ? Thanks/ ...Vern Tags: win7 x64, Download Games...
General Discussion
Dos script help
Hi, Below is my folder path, D:/Sample I have .sql files in that folder and i need to get the file names based on modified/created date i pass. for ex : i need to get the file names created/modified on or after 10/01/2014(mm/dd/yyyy). Can any please give me some sample script to make this...
General Discussion
I search autoit programmers for free software
English: Hello guys, I'm new to the forum, but I have lots of good intentions for the community. I was looking for people who know how to program autoit to create useful programs for Windows users. I do not know if this is the correct section but I hope to find what I'm looking for! ;) Italy:...
Software
AutoIt or Autohotkey?
I'm looking to start to automate some of my computer work and wondered which would be a better language to learn, that of autohotkey or Autoit. Comments and suggestions welcome... Thx D
Software
In need of a script...
I am looking for a script which can delete cookies, Windows + browser cache automatically on a regular (scheduled) basis. Can this be done through Windows itself or would i have to implement a custom script or something? I am looking to replace CCleaner and similar software package(s). Just now...
Performance & Maintenance


Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd

All times are GMT -5. The time now is 15:18.
Twitter Facebook Google+ Seven Forums iOS App Seven Forums Android App