Jump to content

Changeable Sleep timer


Recommended Posts

So right now I've got a script that does what I need it to do, but some times I need there to be a time period before it actually starts. So I'm wondering if I can use a GUIctrlCreateinput and input the wait time before I'd like the program to start.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

GUICreate("",200,100)
$ButtonOk = GUICtrlCreateButton("OK",70,65,60, 30)
$DelayInput = GUICtrlCreateInput("Delay in minutes",10,40,180,20)
GUISetState(@SW_SHOW)
While 1
$Msg = GUIGetMsg()
Select
Case $Msg = $ButtonOk
     $Delay = GUICtrlRead($DelayInput)
     If $Delay <> "Delay in minutes" then
     $Delay = $Delay * 60000
     MsgBox("","", " " & $Delay)
     EndIf
Case $Msg = $GUI_EVENT_CLOSE
     Exit
EndSelect

This is what I've got so far, It's basically ripped from another thread that I thought was similar to my problem but I can't seem to figure out how to make the input number become the sleep time.

Link to comment
Share on other sites

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

GUICreate("",200,100)
$ButtonOk = GUICtrlCreateButton("OK",70,65,60, 30)
$DelayInput = GUICtrlCreateInput("Delay in minutes",10,40,180,20)
GUISetState(@SW_SHOW)
While 1
$Msg = GUIGetMsg()
Select
Case $Msg = $ButtonOk
     $Delay = GUICtrlRead($DelayInput)
     If $Delay <> "Delay in minutes" then
         $Delay = Int($Delay) * 60000 ; <==
         MsgBox("","", " " & $Delay)
         Sleep($Delay) ; <==
     EndIf
Case $Msg = $GUI_EVENT_CLOSE
     Exit
EndSelect

I changed and added a line and marked them with "<=="

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

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

GUICreate("",200,100)
$ButtonOk = GUICtrlCreateButton("OK",70,65,60, 30)
$DelayInput = GUICtrlCreateInput("Delay in minutes",10,40,180,20)
GUISetState(@SW_SHOW)
While 1
$Msg = GUIGetMsg()
Select
Case $Msg = $ButtonOk
     $Delay = GUICtrlRead($DelayInput)
     If $Delay <> "Delay in minutes" then
$Delay = Int($Delay) * 60000 ; <==
MsgBox("","", " " & $Delay)
         Sleep($Delay) ; <==
     EndIf
Case $Msg = $GUI_EVENT_CLOSE
     Exit
EndSelect

I changed and added a line and marked them with "<=="

Thanks for the reply, it seems to be somewhat working but it doesn't seem to wait until I've enter how long I want to wait before it starts the rest of the script now.
Link to comment
Share on other sites

I'm not sure I understand your problem.

You start a script that lets the user input the delay time. When "OK" is pressed Sleep starts to wait the specified time. Then you want to process the rest of the script?

What/where is the rest of the script?

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

I'm not sure I understand your problem.

You start a script that lets the user input the delay time. When "OK" is pressed Sleep starts to wait the specified time. Then you want to process the rest of the script?

What/where is the rest of the script?

Yes sorry I did not link the rest of the script, I will do that now.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
GUICreate("",200,100)
$ButtonOk = GUICtrlCreateButton("OK",70,65,60, 30)
$DelayInput = GUICtrlCreateInput("Delay in minutes",10,40,180,20)
GUISetState(@SW_SHOW)
$Msg = GUIGetMsg()
Select
Case $Msg = $ButtonOk
     $Delay = GUICtrlRead($DelayInput)
     If $Delay <> "Delay in minutes" then
$Delay = Int($Delay) * 60000
MsgBox("","", " " & $Delay)
         Sleep($Delay)
     EndIf
Case $Msg = $GUI_EVENT_CLOSE
     Exit
EndSelect
  
   while 1 <=6
   mouseclick("left" ,1020, 815)
   Sleep(60000)
   mouseclick("left" ,765, 765)
   Sleep(5000)
   1 = 1 + 1
   WEnd

The script does not wait for the input before starting to click. I'm sorry for being rather hard to understand.

Link to comment
Share on other sites

The code you posted gives me syntax errors ("1 = 1 + 1" isn't valid).

What do you try to do with your script? Maybe there's a simpler way to do it.

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

The code you posted gives me syntax errors ("1 = 1 + 1" isn't valid).

What do you try to do with your script? Maybe there's a simpler way to do it.

Ah I'm just trying to set the timer for how long to wait before doing 2 quick mouse clicks in a loop of 6 times then rest.

Link to comment
Share on other sites

Give this a try:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
GUICreate("",200,100)
$ButtonOk = GUICtrlCreateButton("OK",70,65,60, 30)
$DelayInput = GUICtrlCreateInput("Delay in minutes",10,40,180,20)
GUISetState(@SW_SHOW)
While 1
$Msg = GUIGetMsg()
Select
     Case $Msg = $ButtonOk
$Delay = GUICtrlRead($DelayInput)
     If $Delay <> "Delay in minutes" then
         $Delay = Int($Delay) * 60000
         MsgBox("","", " " & $Delay)
         Sleep($Delay)
         ExitLoop
EndIf
Case $Msg = $GUI_EVENT_CLOSE
         Exit
EndSelect
WEnd

For $i = 1 to 6
mouseclick("left" ,1020, 815)
Sleep(60000)
mouseclick("left" ,765, 765)
Sleep(5000)
Next

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

Give this a try:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
GUICreate("",200,100)
$ButtonOk = GUICtrlCreateButton("OK",70,65,60, 30)
$DelayInput = GUICtrlCreateInput("Delay in minutes",10,40,180,20)
GUISetState(@SW_SHOW)
While 1
$Msg = GUIGetMsg()
Select
     Case $Msg = $ButtonOk
$Delay = GUICtrlRead($DelayInput)
     If $Delay <> "Delay in minutes" then
         $Delay = Int($Delay) * 60000
         MsgBox("","", " " & $Delay)
         Sleep($Delay)
         ExitLoop
EndIf
Case $Msg = $GUI_EVENT_CLOSE
         Exit
EndSelect
WEnd

For $i = 1 to 6
mouseclick("left" ,1020, 815)
Sleep(60000)
mouseclick("left" ,765, 765)
Sleep(5000)
Next

Works perfectly, thanks a lot. I'm assuming the problem was that I didn't have the first part looping to wait for my input of the sleep time and it was just skipping right to the clicks instead?
Link to comment
Share on other sites

The While loop enclosing the select was missing. So the script didn't wait until the OK button was pressed and just processed all statements once and then did the mouseclicks.

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...