Jump to content
Sign in to follow this  
great77

Timer not working during while loop

Recommended Posts

great77

I have a loop that is working perfectly, however I want to set the timer. I do not know why the timer is not working in this instance.  Please see the code below :

#NoTrayIcon
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseX64=n
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
Opt("WinTitleMatchMode", 2) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase
Opt("MouseCoordMode", 0)
AutoItSetOption('PixelCoordMode', 0) ;Uses pixel coords relative to the defined Window; Utilizes pixel coords based on the entire window in which you are active in.
#include <GUIConstantsEx.au3>
#include <GUIComboBox.au3>


#include <array.au3>
#include <Timers.au3>
#include <File.au3>
#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>
#include <date.au3>

$begin = TimerInit() ;This is just a timer. Imagine starting a stop watch here. $begin is the name of the "stop watch"
While 1


WinActivate("Load and Store New Data")
sleep(1000)

ControlClick("Load and Store New Data", "", "[CLASS:ThunderRT6DirListBox; INSTANCE:1]", "left", 2, 28, 7)  ;; flight download for the home page
ControlClick("Load and Store New Data", "", "[CLASS:ThunderRT6DirListBox; INSTANCE:1]", "left", 2, 28, 7)  ;; flight download for the home page
sleep(1000)
ControlClick("Load and Store New Data", "", "[CLASS:ThunderRT6DirListBox; INSTANCE:1]", "left", 2, 41, 22)
ControlClick("Load and Store New Data", "", "[CLASS:ThunderRT6DirListBox; INSTANCE:1]", "left", 2, 41, 22)



$dif = TimerDiff($begin)
if $dif >= 120000 then exit


Wend

 

What is the problem. Is there other option apart from TimerDiff. Thanks 

Share this post


Link to post
Share on other sites
SlackerAl

I changed your code a tiny bit so I could test it:

#NoTrayIcon
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseX64=n
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
Opt("WinTitleMatchMode", 2) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase
Opt("MouseCoordMode", 0)
AutoItSetOption('PixelCoordMode', 0) ;Uses pixel coords relative to the defined Window; Utilizes pixel coords based on the entire window in which you are active in.
#include <GUIConstantsEx.au3>
#include <GUIComboBox.au3>


#include <array.au3>
#include <Timers.au3>
#include <File.au3>
#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>
#include <date.au3>

$begin = TimerInit() ;This is just a timer. Imagine starting a stop watch here. $begin is the name of the "stop watch"
While 1


WinActivate("Calculator")
sleep(1000)

ControlClick("Load and Store New Data", "", "[CLASS:ThunderRT6DirListBox; INSTANCE:1]", "left", 2, 28, 7)  ;; flight download for the home page
ControlClick("Load and Store New Data", "", "[CLASS:ThunderRT6DirListBox; INSTANCE:1]", "left", 2, 28, 7)  ;; flight download for the home page
sleep(1000)
ControlClick("Load and Store New Data", "", "[CLASS:ThunderRT6DirListBox; INSTANCE:1]", "left", 2, 41, 22)
ControlClick("Load and Store New Data", "", "[CLASS:ThunderRT6DirListBox; INSTANCE:1]", "left", 2, 41, 22)



$dif = TimerDiff($begin)
if $dif >= 15000 then
     exit
else 
  MsgBox($MB_SYSTEMMODAL, "Test", "Here @ " & $dif)
endif

Wend

Which seems to work OK for me.... thoughts?

Edit: In case it is not obvious, I changed the WinActivate to Calculator, and added the message box in the final if condition.

 

Edited by SlackerAl

Problem solving step 1: Write a simple, self-contained, running, replicator of your problem.

Share this post


Link to post
Share on other sites
great77
3 hours ago, SlackerAl said:

I changed your code a tiny bit so I could test it:

#NoTrayIcon
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseX64=n
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
Opt("WinTitleMatchMode", 2) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase
Opt("MouseCoordMode", 0)
AutoItSetOption('PixelCoordMode', 0) ;Uses pixel coords relative to the defined Window; Utilizes pixel coords based on the entire window in which you are active in.
#include <GUIConstantsEx.au3>
#include <GUIComboBox.au3>


#include <array.au3>
#include <Timers.au3>
#include <File.au3>
#include <FileConstants.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>
#include <date.au3>

$begin = TimerInit() ;This is just a timer. Imagine starting a stop watch here. $begin is the name of the "stop watch"
While 1


WinActivate("Calculator")
sleep(1000)

ControlClick("Load and Store New Data", "", "[CLASS:ThunderRT6DirListBox; INSTANCE:1]", "left", 2, 28, 7)  ;; flight download for the home page
ControlClick("Load and Store New Data", "", "[CLASS:ThunderRT6DirListBox; INSTANCE:1]", "left", 2, 28, 7)  ;; flight download for the home page
sleep(1000)
ControlClick("Load and Store New Data", "", "[CLASS:ThunderRT6DirListBox; INSTANCE:1]", "left", 2, 41, 22)
ControlClick("Load and Store New Data", "", "[CLASS:ThunderRT6DirListBox; INSTANCE:1]", "left", 2, 41, 22)



$dif = TimerDiff($begin)
if $dif >= 15000 then
     exit
else 
  MsgBox($MB_SYSTEMMODAL, "Test", "Here @ " & $dif)
endif

Wend

Which seems to work OK for me.... thoughts?

Edit: In case it is not obvious, I changed the WinActivate to Calculator, and added the message box in the final if condition.

 

 

Thanks is working . Thanks for the correction. The exit was in the same line with then

if $dif >= 15000 then
     exit

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  

  • Similar Content

    • PramodR
      By PramodR
      Hello,
      I have to execute below block of code in elevated previllage, as that particular wmic class will work only with admin previlage.
      i am getting out put when i launch autoit as administrator,  but i will not be able to launch autoit as admin in this particular case but my user have admin rights.
      is there any better way i can run those command as administrator.?
      tried below steps:
      i have tried #RequireAdmin but that creates a user prompt  Tried using Runas command but gives error as wrong username or password , stuck with that step.  
       
    • DynamicRookie
      By DynamicRookie
      Hey there!
       
      Is there a way to detect movement only for 1 specific window?

      HWnd is not really working, it still detects movement in all the windows within the region

      This is my script:
       
      ;Checksum actual HotKeySet("{f2}", 'exit_') MsgBox(0, '', '0') Beep(500, 2000) $Hwnd = WinActive('') while 1 $Checksum = PixelChecksum(211, 650, 1094, 914, 1, $Hwnd) If PixelChecksum(211, 650, 1094, 914, 1, $Hwnd) <> $Checksum Then For $i = 1 To 100 Beep(1000, 50) Next MsgBox(0, '', 'New message!', 1) EndIf WEnd Func exit_() Beep(500, 1000) Exit 0 EndFunc I just want to check whenever a message comes because the app i use doesn't give notifications properly.

      Any help is really appreciated!
    • PramodR
      By PramodR
      Can you please see whats wrong im doing in the below code? i can read few registry entry but not all for eg, i am able to get value of "Shell" Key from the registry path  but not AutoAdminLogon which has the value of "1", is there any change i have to do to read numeric values?
       Global  $shello = RegRead ("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon","Shell" )
       ConsoleWrite("This is Hello"& $shello)
      above command returns proper value , but same command with AutoAdminLogon returns null as shown in below ? infact registry has the value of 1.
       Global  $shello = RegRead ("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon","AutoAdminLogon" )
       ConsoleWrite("This is Hello"& $shello)
    • Eminence
      By Eminence
      Hello,
      I've been searching on how to select the first row in my database which includes a time column based on the latest start_time date for today's date.
      This is my current code:
      Local $iCurrentDate = _Now() Local $sqlHandle = _dbOpen($sDbPath) Local $aResult, $iRows, $iCols _SQLite_GetTable2d($sqlHandle, "SELECT start_time FROM " & $srawDb & " ORDER BY datetime(start_time) DESC LIMIT 1", $aResult, $iRows, $iCols) _ArrayDisplay($aResult) _dbClose($sDbpath) What it does is it gets the first row entry in the database however it does not select the latest start_time entry in the database, it always select the first row. I've tried changing DESC to ASC to see if that will do it but the issue still remains. Any thoughts on this? Thanks in advance.
       
      *EDIT
      The date format in the database is by MM/DD/YYYY HH:MM:SS.
    • Trisha
      By Trisha
      Hello,
      I Have clicked on save as option to save a file, while doing that I need to rename a file appending with sysdate. I have searched in google find the below one line of code:
      FileMove("C:\somefile.txt", "C:\somefile1.txt"), When I am trying to append with sysdate. It is not happening. Please help me out  with the small issue.
×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.