svenjatzu Posted January 30, 2020 Share Posted January 30, 2020 Hi im looking for a way to open a program then close it, open the next program, close it, open next program close it and after 10 minutes when the first program gor closed it should open the first program again. Could you help me on building the concept for it? this is my code in my thoughts: while 1 shellexec(prog1) close(prog1) while 1 sleep(10 min) shellexec(prog1) wend shellexec(prog2) close(prog2) wend Link to comment Share on other sites More sharing options...
svenjatzu Posted January 30, 2020 Author Share Posted January 30, 2020 well i think its gonna be more sencefull to do it this way like running 3 different scripts where each script waits 10 min before restarting? Link to comment Share on other sites More sharing options...
Subz Posted January 30, 2020 Share Posted January 30, 2020 Basic example, for testing I've set it to 10 seconds. HotKeySet("{ESC}", "_ExitScript") ;~ Global $g_iTimerDiff = 1000 * 60 * 10 ;~ 10 minutes Global $g_iTimerDiff = 1000 * 10 ;~ 10 seconds for testing Global $g_hTimerInit, $fTimerDiff = $g_iTimerDiff Global $g_iProcessId Global $g_aPrograms[2] = ["Notepad.exe", @ComSpec & " /k"] Global $i = (UBound($g_aPrograms) - 1) While 1 If $fTimerDiff >= $g_iTimerDiff Then ProcessClose($g_iProcessId) $i = $i = (UBound($g_aPrograms) - 1) ? 0 : $i + 1 _RunProgram($g_aPrograms[$i]) EndIf Sleep(100) $fTimerDiff = TimerDiff($g_hTimerInit) WEnd Func _RunProgram($_sProgram) $g_hTimerInit = TimerInit() $g_iProcessId = Run($_sProgram) EndFunc Func _ExitScript() Exit EndFunc svenjatzu 1 Link to comment Share on other sites More sharing options...
svenjatzu Posted January 30, 2020 Author Share Posted January 30, 2020 Thanks for your quick response : ) that works like a charm : ) almost : ) i wanna run chrome with profile 1 and then chrome with profile 2 the links to the profiles are placed on the desktop. ShellExecute("C:\Users\User\Desktop\acc 1 - Chrome.lnk") ShellExecute("C:\Users\User\Desktop\acc 2 - Chrome.lnk") if i replace the line Global $g_aPrograms[2] = ["Notepad.exe", @ComSpec & " /k"] with Global $g_aPrograms[2] = ["C:\Users\User\Desktop\acc 1 - Chrome.lnk", "C:\Users\User\Desktop\acc 2 - Chrome.lnk" & " /k"] then nothing happens on the run Link to comment Share on other sites More sharing options...
Earthshine Posted January 30, 2020 Share Posted January 30, 2020 right, so by being so vague in your first post and not giving sufficient detail people have to guess at what you want. you should be able to use what was given and modify it to do what you need. My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
svenjatzu Posted January 30, 2020 Author Share Posted January 30, 2020 (edited) thanks earthshine, well ur right, i first had to think how to generally run my thoughts in a script : ) now ive changed it to.... and this works perfectly : ) HotKeySet("{ESC}", "_ExitScript") ;~ Global $g_iTimerDiff = 1000 * 60 * 10 ;~ 10 minutes Global $g_iTimerDiff = 1000 * 10 ;~ 10 seconds for testing Global $g_hTimerInit, $fTimerDiff = $g_iTimerDiff Global $g_iProcessId $linktorun1 = '"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --profile-directory="Profile 1"' $linktorun2 = '"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --profile-directory="Profile 2"' Global $g_aPrograms[2] = [$linktorun1, $linktorun2& " /k"] Global $i = (UBound($g_aPrograms) - 1) While 1 If $fTimerDiff >= $g_iTimerDiff Then ProcessClose($g_iProcessId) $i = $i = (UBound($g_aPrograms) - 1) ? 0 : $i + 1 _RunProgram($g_aPrograms[$i]) EndIf Sleep(100) $fTimerDiff = TimerDiff($g_hTimerInit) WEnd Func _RunProgram($_sProgram) $g_hTimerInit = TimerInit() $g_iProcessId = Run($_sProgram) EndFunc Func _ExitScript() Exit EndFunc Edited January 30, 2020 by svenjatzu Earthshine 1 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