1

Please help me, I want to modify this file should be like this

  1. Run script
  2. Execute For Loop 5 times
  3. Waiting 5 minutes
  4. Execute For Loop 5 times again
  5. waiting 5 minutes
  6. Execute For Loop 5 times again
  7. If script has running For Loop 3 Times, exit script

Hope you can help me

dim wsh
jumlah=5
delay=2000
set wsh=wscript.createobject("wscript.shell")
wscript.sleep 5000
for i=1 to jumlah
WScript.Sleep 3000
wsh.run "nircmd.exe setcursor 100 398"
WScript.Sleep 1000
wsh.run "nircmd.exe sendmouse left down"
WScript.Sleep 1000
wsh.run "nircmd.exe sendmouse left up"
WScript.Sleep 1000
wsh.sendkeys "Semoga sukses selalu dan ditambah rezekinya yg banyak "
wsh.sendkeys "{ENTER}"
wsh.sendkeys "Semoga sukses selalu dan ditambah rezekinya yg banyak "
wsh.sendkeys "{ENTER}"
wsh.sendkeys "Semoga sukses selalu dan ditambah rezekinya yg banyak "
wsh.sendkeys "{ENTER}"
wsh.sendkeys "ig: raihanrj1999 "
WScript.Sleep delay
wsh.run "nircmd.exe setcursor 834 504"
WScript.Sleep 3000
wsh.run "nircmd.exe sendmouse left down"
WScript.Sleep 1000
wsh.run "nircmd.exe sendmouse left up"
WScript.Sleep 1000
next
'END        

1 Answers1

0

i created a solution spliting the problem in three functions:

  1. isEndProcess, that controls the condition to stop the algoritm
  2. process, where you will put your code that you wanna run
  3. loopManager, that controls when to call process function You can change the values of constants to fit in your needs.

const EXECUTIONS_TO_STOP = 3
const EXECUTIONS_EACH_LOOP = 5
const TIME = 1000


let executions = 0
const isEndProcess = () => {
  return executions >= EXECUTIONS_TO_STOP
}

const process = () => {
  console.log(executions)
}

const loopManager = () => {
  if(isEndProcess()){
    return clearInterval(interval)
  }
  
  executions++
  
  for(let i=0; i<EXECUTIONS_EACH_LOOP; i++){
    process()
  }
}

const interval = setInterval(loopManager, TIME)
Rafael Umbelino
  • 771
  • 7
  • 14