Sign in to follow this  
Followers 0
IsmokeIdrank

Changeable Sleep timer

10 posts in this topic

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.

Share this post


Link to post
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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
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.

Share this post


Link to post
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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
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.

Share this post


Link to post
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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
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.

Share this post


Link to post
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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
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?

Share this post


Link to post
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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
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
Sign in to follow this  
Followers 0