Hyflex Posted June 24, 2014 Share Posted June 24, 2014 (edited) I have the following code running on my computer to get rid of certain annoying nags and frustrations fasteish... expandcollapse popup#include <ImageSearch.au3> ; Misc Variables Opt("TrayOnEventMode", 1) Opt("TrayMenuMode", 1) Opt("TrayAutoPause", 0) TraySetClick(8) $Tray_Exit = TrayCreateItem("Exit") TrayItemSetOnEvent(-1, "Terminate") $SleepDelay = 100 If Not FileExists(@StartupDir & "\Anti-Sh1t.lnk") Then FileCreateShortcut( @ScriptDir & "\Anti-Sh1t.exe", @StartupDir & "\Anti-Sh1t.lnk") ConsoleWrite("Created" & @CRLF) Else ConsoleWrite("NOT Created" & @CRLF) EndIf While 1 If WinExists("Sponsored session") Then WinActivate("Sponsored session") WinWaitActive("Sponsored session") Sleep($SleepDelay) ControlClick("Sponsored session", "", "[CLASS:Button; INSTANCE:4]") Sleep($SleepDelay) EndIf If WinExists("Commercial use") Then WinActivate("Commercial use") WinWaitActive("Commercial use") Sleep($SleepDelay) ControlClick("Commercial use", "", "[CLASS:Button; INSTANCE:4]") Sleep($SleepDelay) EndIf If WinExists("Skype™ - Update") Then $XCoords= "" $YCoords= "" RWinWaitActivate("Skype™ - Update") $SkypeNoUpdate = _ImageSearch(@DesktopDir & "\Images\" & "SkypeNoUpdate.png", 1, $XCoords, $YCoords, 25) While $SkypeNoUpdate = 0 $SkypeNoUpdate = _ImageSearch(@DesktopDir & "\Images\" & "SkypeNoUpdate.png", 1, $XCoords, $YCoords, 25) Sleep(100) WEnd MouseClick("Left", $XCoords, $YCoords, 1, 1) EndIf If WinExists("Windows Update") Then RunWait(@ComSpec & ' /c ' & "net stop wuauserv", @TempDir, @SW_HIDE) EndIf Sleep($SleepDelay) WEnd Func RWinWaitActivate($WWAVariable) WinWait($WWAVariable) WinActivate(WWAVariable) WinWaitActive($WWAVariable) Sleep(500) EndFunc ;==>RWinWaitActivate ; Exit Func Terminate() Exit 0 EndFuncI'm trying to incorporate another feature to the script but am not quite sure how to do what I want to do... #include <MsgBoxConstants.au3> MsgBox($MB_OKCANCEL, "Force Close '101.exe'?", "Press 'Okay' if you want to force close '101.exe`" & @LF & @LF & "Press 'Cancel' if you want to delay this action by a further 30 minutes" & @LF & @LF & "If you fail to choose within 10 minutes '101.exe' will be automatically killed.", 600)Using the above, I basically want the following abilities:1) At 08:30(am) till 11:30(am) it will start checking for "101.exe" and if present the above popup will appear.2) If "Okay" is pressed, it would force close "101.exe"3) If "Cancel" is pressed, it would stop the popup from appearing on the next loop(s) for 30 minutes, after that 30mins has been it should start again...4) If neither button is pressed, it should automatically force close "101.exe"I have no idea how to do the timer/time aspect of it... Edited June 29, 2014 by Hyflex Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted June 24, 2014 Moderators Share Posted June 24, 2014 Can you clarify what you mean by "timer/time aspect"? If you mean this: 1) At 08:30(am) till 11:30(am) it will start checking for "101.exe" and if present the above popup will appear. You can either compile the script and schedule when to run it through Task Scheduler, or look at _Now or _NowTime in the help file. If you mean how long the MsgBox waits, it seems you already have this set at 600 seconds. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Hyflex Posted June 24, 2014 Author Share Posted June 24, 2014 Hey JLogan3o13,Sorry, I was having trouble wording it... Uhm.The script/code is running 24/7 so I don't want to run it through task scheduler, I'll have a look at _Now and _NowTime for my first part.In regards to the MsgBox waits... The timeout is set to 600 seconds yes but how do I detect if it timed out and if they press Cancel I want the popup to be suppressed for 30 minutes before popping up again#include <MsgBoxConstants.au3> $ForceClosePop = MsgBox($MB_OKCANCEL, "Force Close '101.exe'?", "Press 'Okay' if you want to force close '101.exe`" & @LF & @LF & "Press 'Cancel' if you want to delay this action by a further 30 minutes" & @LF & @LF & "If you fail to choose within 10 minutes '101.exe' will be automatically killed.", 600) If $ForceClosePop = 1 Then ; Okay was pressed... ElseIf $ForceClosePop = 2 Then ; Cancel was pressed... ElseIf $ForceClosePop = XXX Then ; Timeout? EndIf Link to comment Share on other sites More sharing options...
KaFu Posted June 24, 2014 Share Posted June 24, 2014 Failure: Returns -1 if the message box timed out. OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted June 24, 2014 Moderators Share Posted June 24, 2014 Ok, that makes more sense. As KaFu points out (ltns, btw), check the return of your MsgBox to see if it timed out, and then move on accordingly. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Hyflex Posted June 24, 2014 Author Share Posted June 24, 2014 (edited) I don't understand the benefit of using NowTime... #include <Date.au3> If _NowTime() >= "08:00:00" Then ConsoleWrite(_NowTime() & @CRLF) EndIf If @HOUR & ":" & @MIN & ":" & @SEC >= "08:00:00" Then ConsoleWrite(@HOUR & ":" & @MIN & ":" & @SEC & @CRLF) EndIfThey both do the same thing...? Edited June 24, 2014 by Hyflex Link to comment Share on other sites More sharing options...
iamtheky Posted June 24, 2014 Share Posted June 24, 2014 Global $msg _msg() Func _msg() $msg = msgbox (1, '' , "timeout or button press?" , 5) If $msg <> -1 Then sleep(5000) _msg() Else tooltip("msgbox timed out, after 5 seconds the script will exit" , 0 ,0) sleep (5000) Exit EndIf EndFunc ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted June 24, 2014 Moderators Share Posted June 24, 2014 I don't understand the benefit of using NowTime... #include <Date.au3> If _NowTime() >= "08:00:00" Then ConsoleWrite(_NowTime() & @CRLF) EndIf If @HOUR & ":" & @MIN & ":" & @SEC >= "08:00:00" Then ConsoleWrite(@HOUR & ":" & @MIN & ":" & @SEC & @CRLF) EndIf They both do the same thing...? I suggested that before you made clear what you were intending. Please disregard. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Hyflex Posted June 24, 2014 Author Share Posted June 24, 2014 (edited) #include <MsgBoxConstants.au3> If @HOUR & ":" & @MIN & ":" & @SEC >= "08:00:00" and @HOUR & ":" & @MIN & ":" & @SEC <= "11:30:00" Then If ProcessExists("EXCEL.EXE") Then $ForceClosePop = MsgBox($MB_OKCANCEL, "Force Close 'EXCEL.EXE'?", "Press 'Okay' if you want to force close 'EXCEL.EXE`" & @LF & @LF & "Press 'Cancel' if you want to delay this action by a further 30 minutes" & @LF & @LF & "If you fail to choose within 10 minutes 'EXCEL.EXE' will be automatically killed.", 600) If $ForceClosePop = 1 Then ; Okay was pressed... If ProcessExists("EXCEL.EXE") Then Do ProcessClose('EXCEL.EXE') Until Not ProcessExists('EXCEL.EXE') EndIf ElseIf $ForceClosePop = 2 Then ; Cancel was pressed... ; I need to add a sort of sleep for 30 mins... but I don't wait it to stop/interupt the other part of the while loop. ElseIf $ForceClosePop = -1 Then ; Timeout If ProcessExists("EXCEL.EXE") Then Do ProcessClose('EXCEL.EXE') Until Not ProcessExists('EXCEL.EXE') EndIf EndIf EndIf EndIfStruggling still with the If cancel was pressed part, I've had a look into using Timer but don't know how do it (can't even think of a logical way of doing it in my brain)I need to add a sort of sleep for 30 mins... but I don't wait it to stop/interrupt the other part of the while loop from my original post.EDIT: Testing with Excel for the meantime lol Edited June 24, 2014 by Hyflex 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