Jump to content
Sign in to follow this  
hutralospi

Timings get incremented when using sleep()

Recommended Posts

For the purpose of taking consecutive 3 screenshots at specific intervals of time, I wrote this script:

===============

#include <Constants.au3>

#include <MsgBoxConstants.au3>

HotKeySet("^g", "Take3Screenshots") ; Ctrl+g
HotKeySet("^+g", "RegularIntervalsSS") ; Ctrl+Shift+g

While 1
 Sleep(100)
WEnd

Func Take3Screenshots()

Sleep(500)
Send("^+s")

Sleep(500)
Send("^+s")

Sleep(500)
Send("^+s")

Sleep(500)

EndFunc   ;==>Take3Screenshots

Func RegularIntervalsSS()

While 1
Send("^g")
Sleep(60000)        ;60 seconds =1 minute
WEnd

EndFunc   ;==>RegularIntervalsSS

===============

When I execute the above script, the screenshots taken are at the times:  

034931, 034932, 034933, 035035, 035036, 035037, 035138, 035139, 035140

As can be seen, the time for the screenshot at the next minute is automatically incremented. ie., instead of the screenshots being taken at 035031 and 035131, they are taken at 035035 and 035138.

As I need to take continual screenshots, these time differences increment every minute which doesn't hence serve the purpose of taking consecutive 3 screenshots at specific intervals of time.

How can this be solved?

Any help is welcome.  Thanks in advance.

 

Share this post


Link to post
Share on other sites

I guess i got your problem. 

You have to change your options.

I explain you, If you are in any software. If a key is used to do somthing. You have to let this key free in your script. I always had problem doing this. when i had that problem it is ofen becose i attach hotkey before testing them.

 

Let's make is easy:

If you are in a software using A B C as shordcut key. 

If autoIT use A B C It wont play your function but it will do software action or both or conflict. Becose they aren't free.

To make this work you have to make autoIT use D E F to send the command A B C but not as a duplicated shordcut.

 

This could work better.

#include <Constants.au3>

#include <MsgBoxConstants.au3>

HotKeySet("A", "Take3Screenshots") ; Ctrl+g But now Ctrl+g is free in your script.
HotKeySet("B", "RegularIntervalsSS") ; Ctrl+Shift+g But now Ctrl+Shift+g is free in your script.

While 1
 Sleep(100)
WEnd

Func Take3Screenshots()

Sleep(500)
Send("^+s")

Sleep(500)
Send("^+s")

Sleep(500)
Send("^+s")

Sleep(500)

EndFunc   ;==>Take3Screenshots

Func RegularIntervalsSS()

While 1
Send("^g")
Sleep(60000)        ;60 seconds =1 minute
WEnd

EndFunc   ;==>RegularIntervalsSS

Let me know.

And i whould change this:

While 1
Send("^g")
Sleep(60000)        ;60 seconds =1 minute
WEnd

By this (But in this case rethink the script a bit ;p ):

AdlibRegister ("MyScreen", 60000 ) 

While 1
    Sleep(10)
WEnd

Func MyScreen ()
    Send("^g")
EndFunc

And even improve ;)

HotKeySet("C", "UnregisterMyScreen")

Func UnregisterMyScreen ()
    AdlibUnRegister ("MyScreen") 
EndFunc

 

Edited by caramen

My video tutorials : HERE ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites

@hutralospi @caramen

_ScreenCapture_Capture should do the trick too :)


Click here to see my signature:

Spoiler

Thoughts:

  • I will always thank you for the time you spent for me.
    I'm here to ask, and from your response, I'd like to learn.
    By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

ALWAYS GOOD TO READ:

 

Share this post


Link to post
Share on other sites
1 minute ago, FrancescoDiMuro said:

@hutralospi @caramen

_ScreenCapture_Capture should do the trick too :)

But the udf wont implement screens inside the software bro ?

Personally i use screencapture too :P 


My video tutorials : HERE ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
2 hours ago, caramen said:

But the udf wont implement screens inside the software bro ?

Are you talking about take a screen of a window instead of all the screen or... ? :)


Click here to see my signature:

Spoiler

Thoughts:

  • I will always thank you for the time you spent for me.
    I'm here to ask, and from your response, I'd like to learn.
    By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

ALWAYS GOOD TO READ:

 

Share this post


Link to post
Share on other sites

Just noticing you he is using a software to take screens and not an udf so... may he got some code with that already. But who knwo; 


My video tutorials : HERE ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...