Jump to content

Change both sleep time at once


Recommended Posts

I have script Like This :

Opt("TrayAutoPause",0)
$var = Ping("www.google.com")

If not @error Then
WinActivate ( "testapp")
ControlClick ( "testapp", "", "[Savetest]")
ControlSend ( " :: Gujarat TPDS  - eFPS :: Version - 2.2.0.0  - [eFPS Bill]", "", "[NAME:btnSavebyFP]", "{enter}")
WinWait(":: Aadhar/EID/Verification Number Entry ::")
ControlClick(":: Aadhar/EID/Verification Number Entry ::", "", "[NAME:btnNext]")
If WinExists ("Aadhar : Length Check") Then
   ControlClick("Aadhar : Length Check", "", "[CLASS:Button; INSTANCE:1]")
   ControlSend(":: Aadhar/EID/Verification Number Entry ::", "", "[NAME:txtAadharNumber]", "{backspace}")
   ControlSend(":: Aadhar/EID/Verification Number Entry ::", "", "[NAME:txtAadharNumber]", "^v")
   ControlClick(":: Aadhar/EID/Verification Number Entry ::", "", "[NAME:btnNext]")
   WinWait(" :: Barcoded Ration Card Members - Biometric Verification/Check Utility ::")
   ControlSend("[Class:WindowsForms10.Window.8.app.0.378734a]", "", "[NAME:PictureBox2]", "{tab} {enter}")
   Sleep(5600)
   RunWait("rasdial /disconnect", "", @SW_HIDE) ; Stop connect from start
   RunWait("rasdial Internet", "", @SW_HIDE) ; Connect again
   Exit
EndIf
WinWait(" :: Barcoded Ration Card Members - Biometric Verification/Check Utility ::", "", 1)
ControlSend("[Class:WindowsForms10.Window.8.app.0.378734a]", "", "[NAME:PictureBox2]", "{tab} {enter}")
Sleep(5600)
RunWait("rasdial /disconnect", "", @SW_HIDE) ; Stop connect from start
RunWait("rasdial Internet", "", @SW_HIDE) ; Connect again
Exit
Else
   #include <MsgBoxConstants.au3>
   MsgBox($MB_TOPMOST, "Connection Status", "Internet is not Connected")
Exit
Endif

Link to comment
Share on other sites

I have script Like This :

Opt("TrayAutoPause",0)
$var = Ping("www.google.com")

If not @error Then
WinActivate ( "testapp")
ControlClick ( "testapp", "", "[Savetest]")

Sleep(3000)

ControlSend ( "testapp", "", "[SaveFP]", "{enter}")
WinWait("Verification Entry")
ControlClick("Verification Entry", "", "[Next]")
If WinExists ("Check") Then
   ControlClick("Check", "", "[CLASS:B; INSTANCE:1]")
   ControlSend("Verification Number Entry ", "", "[NAME:txtNumber]", "{backspace}")
 
   Sleep(3000)

   RunWait("rasdial Internet", "", @SW_HIDE)
   Exit
EndIf
WinWait("Verification/Check Utility ", "", 1)
ControlSend("[Class:Win.Window.84a]", "", "[PictureBox55]", "{tab}")
RunWait("rasdial Internet", "", @SW_HIDE)
Exit
Else
   #include <MsgBoxConstants.au3>
   MsgBox($MB_TOPMOST, "Connection Status", "Internet is not Connected")
Exit
Endif

Can i Change both Sleep(time) at once ?

Link to comment
Share on other sites

Store your sleep time in a variable

Opt("TrayAutoPause", 0)

Global $iSleepTime = 3000

$var = Ping("www.google.com")

If Not @error Then
    WinActivate("testapp")
    ControlClick("testapp", "", "[Savetest]")
    $sSleepTime = 1000

    Sleep($sSleepTime)

    ControlSend("testapp", "", "[SaveFP]", "{enter}")
    WinWait("Verification Entry")
    ControlClick("Verification Entry", "", "[Next]")
    If WinExists("Check") Then
        ControlClick("Check", "", "[CLASS:B; INSTANCE:1]")
        ControlSend("Verification Number Entry ", "", "[NAME:txtNumber]", "{backspace}")

        Sleep($sSleepTime)

        RunWait("rasdial Internet", "", @SW_HIDE)
        Exit
    EndIf
    WinWait("Verification/Check Utility ", "", 1)
    ControlSend("[Class:Win.Window.84a]", "", "[PictureBox55]", "{tab}")
    RunWait("rasdial Internet", "", @SW_HIDE)
    Exit
Else
    #include <MsgBoxConstants.au3>
    MsgBox($MB_TOPMOST, "Connection Status", "Internet is not Connected")
    Exit
EndIf

Edit: My bad, I put $sSleepTime instead of $iSleepTime (it's late, forgive me :()

Edited by InunoTaishou
Link to comment
Share on other sites

WIthout using Global you are not explicitly declaring your variable (and initializing in this case, since we give it a value). AutoIt is a very forgiving langauge and this is okay, but it's good practice to declare your variables using Global and Local

Also, use the proper prefix for the variables

$sSleepTime

Would be used for strings (since it starts with $s)

$iSleepTime

Would be used for numbers, since it starts with $i (integer)

Edit: Realized I'm the one who put $sSleepTime instead of $iSleepTime

Edited by InunoTaishou
Link to comment
Share on other sites

I have script Like This :

Opt("TrayAutoPause",0)
$var = Ping("www.google.com")

If not @error Then
WinActivate ( "testapp")
ControlClick ( "testapp", "", "[Savetest]")

Sleep(3000)

ControlSend ( "testapp", "", "[SaveFP]", "{enter}")
WinWait("Verification Entry")
ControlClick("Verification Entry", "", "[Next]")
If WinExists ("Check") Then
   ControlClick("Check", "", "[CLASS:B; INSTANCE:1]")
   ControlSend("Verification Number Entry ", "", "[NAME:txtNumber]", "{backspace}")
 
   Sleep(3000)

   RunWait("rasdial Internet", "", @SW_HIDE)
   Exit
EndIf
WinWait("Verification/Check Utility ", "", 1)
ControlSend("[Class:Win.Window.84a]", "", "[PictureBox55]", "{tab}")
RunWait("rasdial Internet", "", @SW_HIDE)
Exit
Else
   #include <MsgBoxConstants.au3>
   MsgBox($MB_TOPMOST, "Connection Status", "Internet is not Connected")
Exit
Endif

Can i Change both Sleep(time) at once ?

Link to comment
Share on other sites

Yes you can. Use a variable for the slep time and assign a new valie when needed.

BTW: Please use Code Tags when posting code (the "<>" button in the editor). Makes your code easier to read.

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

BTW:
The conditional include of th MsgBoxConstants doesn#t work this way.
In a preprocessing step all #include statements are resolved and replaced by the specified file.
Good practice is to move all #include statements to the top of your 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

30 minutes ago, Nareshm said:

Can i Change both Sleep(time) at once ?

Assign sleep time to a variable!

#include <MsgBoxConstants.au3>

Opt("TrayAutoPause", 0)

Global $iSleep = 3000

TrayTip("Internet", "Working....", 5)
Global $var = Ping("www.google.com", 2000)
If Not @error Then
    WinActivate("testapp")
    ControlClick("testapp", "", "[Savetest]")
    Sleep($iSleep)
    ControlSend("testapp", "", "[SaveFP]", "{enter}")
    WinWait("Verification Entry")
    ControlClick("Verification Entry", "", "[Next]")
    If WinExists("Check") Then
        ControlClick("Check", "", "[CLASS:B; INSTANCE:1]")
        ControlSend("Verification Number Entry ", "", "[NAME:txtNumber]", "{backspace}")
        Sleep($iSleep)
        MsgBox($MB_TOPMOST, RunWait("rasdial Internet", "", @SW_HIDE), "Internet is Connected", 2)
        Exit
    EndIf
    WinWait("Verification/Check Utility ", "", 1)
    ControlSend("[Class:Win.Window.84a]", "", "[PictureBox55]", "{tab}")
    MsgBox($MB_TOPMOST, RunWait("rasdial Internet", "", @SW_HIDE), "Internet is Connected", 2)
    Exit
Else
    MsgBox($MB_TOPMOST, "Connection Status", "Internet is not Connected")
    Exit
EndIf

 

Regards,
 

Link to comment
Share on other sites

And the question is?

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

Did you report this "Spam"?

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

  • Developers

Please ONLY report threads and do not comment on it in the thread itself .... Thanks :)

Merged: now back on topic pls.

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Moderators

@VIP what benefit is there in simply parroting what InunoTaishou already said, especially when the OP obviously doesn't understand?

Edit: too early in the morning, I see the threads were merged.

Edit2: @Nareshm I have now found a third thread with the same question. Don't post any more, stick to one thread.

Edited by JLogan3o13

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

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

×
×
  • Create New...