SolarFox Posted February 1, 2022 Share Posted February 1, 2022 Hello, I`m new here, and need small help with few lines. If application-process excel.exe is found wait for ONE minute and kill and repeat forever. That`s all. This i made is works but only once and stop. Sleep(60000) If ProcessExists("excel.exe") Then ProcessClose("excel.exe") EndIf Can someone help me with rest? Thank you. Link to comment Share on other sites More sharing options...
Developers Jos Posted February 1, 2022 Developers Share Posted February 1, 2022 Please explain why it is you want this and I can't see the real purpose of this? SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
SolarFox Posted February 1, 2022 Author Share Posted February 1, 2022 Got some small machine that log some parameters in excel ( old XLS format) and i have few peoples here who open that excel just to see parameters but no one changing anything and if they left excel open and go away machine won`t log any more because file is locked until excel is closed. Link to comment Share on other sites More sharing options...
Developers Jos Posted February 1, 2022 Developers Share Posted February 1, 2022 Is the logging process not using Excel as else you would likely kill the update process at some point in time? Check the helpfile for While --- Wend to create a permanent loop around your posted code. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
SOLVE-SMART Posted February 1, 2022 Share Posted February 1, 2022 (edited) Hi @SolarFox, welcome to the forum 👋 . In the first point of view it looks like a "prank on friends, a kind of an annoying virus" 😒 . But you explained your purpose, fine. hi @Jos, you were faster than me 😅 . SolarFox, it could also be a good idea to create a exit function to leave the while loop. Just in case it doesn't work like you expect. Have a look for HotKeySet for example. Best regards Sven ________________Stay innovative! Edited February 1, 2022 by SOLVE-SMART Stay innovative! Spoiler 🌍 Au3Forums 🎲 AutoIt (en) Cheat Sheet 📊 AutoIt limits/defaults 💎 Code Katas: [...] (comming soon) 🎭 Collection of GitHub users with AutoIt projects 🐞 False-Positives 🔮 Me on GitHub 💬 Opinion about new forum sub category 📑 UDF wiki list ✂ VSCode-AutoItSnippets 📑 WebDriver FAQs 👨🏫 WebDriver Tutorial (coming soon) Link to comment Share on other sites More sharing options...
SolarFox Posted February 1, 2022 Author Share Posted February 1, 2022 It`s not for prank. Just peoples simple forget to close excel and we need that logs to see parameters. I check once again a little deeper. No, excel is not used when application is creating log file, it have his own engine integrated, even no office need to be installed on that PC. Link to comment Share on other sites More sharing options...
SolarFox Posted February 1, 2022 Author Share Posted February 1, 2022 44 minutes ago, SOLVE-SMART said: @SolarFox👋😒@Jos😅olarFox, it could also be a good idea to create a exit function to leave the while loop. Just in case it doesn't work like you expect. Have a look for HotKeySet for example. Best regards Sven ________________Stay innovative! I compiled exe file, that`s more than fine. There is exit button in tray if we don`t need to run it forever. Link to comment Share on other sites More sharing options...
ad777 Posted February 1, 2022 Share Posted February 1, 2022 (edited) @SolarFox use While: While 1 Sleep(60000) If ProcessExists("excel.exe") Then ProcessClose("excel.exe") EndIf WEnd Edited February 1, 2022 by ad777 iam ِAutoit programmer. best thing in life is to use your Brain to Achieve everything you want. Link to comment Share on other sites More sharing options...
Solution SolarFox Posted February 1, 2022 Author Solution Share Posted February 1, 2022 2 minutes ago, ad777 said: @SolarFox use While: While 1 Sleep(60000) If ProcessExists("excel.exe") Then ProcessClose("excel.exe") EndIf WEnd Thanx, It`s working. You are the man :) Link to comment Share on other sites More sharing options...
Musashi Posted February 1, 2022 Share Posted February 1, 2022 (edited) 23 minutes ago, SolarFox said: Thanx, It`s working. As an extension you could add the suggestion from @SOLVE-SMART : 1 hour ago, SOLVE-SMART said: it could also be a good idea to create a exit function to leave the while loop. HotKeySet("{ESC}", "_Terminate") ; Escape While True Sleep(60000) If ProcessExists("excel.exe") Then ProcessClose("excel.exe") EndIf WEnd Func _Terminate() Exit EndFunc @SolarFox Edit : Or HotKeySet("{ESC}", "_Terminate") ; Escape While True Sleep(60000) If ProcessExists("excel.exe") Then ProcessClose("excel.exe") EndIf WEnd Func _Terminate() If ProcessExists("excel.exe") Then ProcessClose("excel.exe") Exit EndFunc Edited February 1, 2022 by Musashi typo "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
SolarFox Posted February 1, 2022 Author Share Posted February 1, 2022 (edited) OK, i`ll ttry all versions and will see which one is best. Thanx .. Edited February 10, 2022 by SolarFox Link to comment Share on other sites More sharing options...
water Posted February 1, 2022 Share Posted February 1, 2022 I suggest to use the Excel UDF to close Excel. #include <Excel.au3> HotKeySet("{ESC}", "_Terminate") ; Escape Global $oExcel While True Sleep(60000) If ProcessExists("excel.exe") Then $oExcel = _Excel_Open() ; Connect to the running Excel instance ; Close the Excel instance without saving open workbooks and force close the insance even when it is not created by _Excel_Open _Excel_Close($oExcel, False, True) EndIf WEnd Func _Terminate() If ProcessExists("excel.exe") Then $oExcel = _Excel_Open() ; Connect to the running Excel instance ; Close the Excel instance without saving open workbooks and force close the insance even when it is not created by _Excel_Open _Excel_Close($oExcel, False, True) EndIf Exit EndFunc SolarFox 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now