Jump to content

Add .wav file and timer function


Recommended Posts

I have an unprofessional script I use personally that interacts with a website using various data from an excel sheet and various mouse clicks and downloads / save actions.

The site sometimes slows down which causes issue and messes things up and my script gets out of order.

I have a winwait that is helpful to stop this before the next loop but sometimes steps before causes this step to not happen and essentially stops the loop action of my script.

I generally keep an eye on this script but start doing other things on my other computer only to find out the system has been idled for a while.

What I would like to do is add some type of timer that will sound a window .wav file to give me an audio signal that something is not working. For instance if after code line "send("{F5}")" the timer will start and after 90 seconds if the code line "WinWaitActive("Save As")" does not appear then a .wav file will activate and give me an audio signal.

I hope this makes since :)

Thank you.

#Include <Excel.au3>

;YOU MAY CHANGE THIS:
$sExcelFileName = "keyword Seed.xlsx"  ; SHOULD BE SAVED IN THE SAME DIRECTORY AS THE AUTOIT SCRIPT
$sRootSaveDir = "c:\raw_keywords"     ; THIS DIRECTORY SHOULD EXIST. DO NOT ADD TRAILING SLASH



$sExcelFilePath = @ScriptDir & "\" & $sExcelFileName
If Not FileExists($sExcelFilePath) Then
    MsgBox(16 + 4096 + 262144,"ERROR: Input File Missing", $sExcelFilePath & " does NOT exists")
    Exit
EndIf

$oExcel = _ExcelBookAttach($sExcelFilePath)
If @error = 1 Then
    $oExcel = _ExcelBookOpen($sExcelFilePath, 1)
    If @error = 1 Then
        MsgBox (16 + 4096 + 262144,"ERROR","Cannot open " & $sExcelFilePath & "!")
        Exit
    EndIf
EndIf


$nExcelBaseColumn = 1
$nExcelRow = 2
$sBaseWord = StringStripWS(_ExcelReadCell($oExcel, $nExcelRow, $nExcelBaseColumn),7)
WinMove("Google AdWords: Keyword Tool - Windows Internet Explorer", "", 2, 1, 1276, 1017)

While StringLen($sBaseWord) > 0

    $nExcelSeedColumn = 2
    $sSeedWord = StringStripWS(_ExcelReadCell($oExcel, $nExcelRow, $nExcelSeedColumn),7)
    While StringLen($sSeedWord) > 0
        $sCSVFilePath = $sRootSaveDir & "\" & StringLower(StringReplace($sBaseWord & "_" & $sSeedWord & ".csv"," ","_"))



        ;YOUR WEB FORM SEARCH AND EXPORT SCRIPT starts HERE:






        mouseclick("left", 328,405,1)
        send("{F5}")
        sleep(random (15000, 25000,1))
        mouseclick("left", 328,405,1)
        send($sSeedWord)  ; send
        Sleep(random (700, 4000, 1))
        send("{tab 4}")
        sleep(random (700, 4000, 1))
        send("{ENTER}") ;search button
        sleep(random (25000, 40000, 1)) ;sleep while searching
        send("{TAB 2}")
        send("{ENTER}") ;download button
        sleep(500)
        send("{DOWN}") ;choose "all"
        send("{ENTER}")
        sleep(random(1500, 3500, 1))
        send("{TAB}") ;download pop up window
        sleep (1000)
        send("{ENTER}")
        sleep (2500)

        ;because of hang ups with ie9 download bar at the bottom this
        ;will move the mouse to this position wait and then click.
        ;it kept missing the bar because of IE9 various speeds.
        MouseMove(998, 987, 40)
        sleep(3500)



        ;this is the coordinance to click on the internet download bar in IE9
        mouseclick("left",998, 987, 1)
        sleep (2500)
        mouseclick("left", 1070,967, 1)



        sleep(2000)
        WinWaitActive("Save As")
        sleep(1000)
        ;send("&Save")
        sleep(1500)
        WinWaitActive("Save As")
        sleep(1000)
        send ($sCSVFilePath)
        sleep(1500)
        send ("!s")
        sleep(2000)

        send("{enter}")





        ;YOUR WEB FORM SEARCH AND EXPORT SCRIPT ends HERE:


        $nExcelSeedColumn += 1
        $sSeedWord = StringStripWS(_ExcelReadCell($oExcel, $nExcelRow, $nExcelSeedColumn),7)
    WEnd
    $nExcelRow += 1
    $sBaseWord = StringStripWS(_ExcelReadCell($oExcel, $nExcelRow, $nExcelBaseColumn),7)
WEnd
Edited by gripper
Link to comment
Share on other sites

How would I set up the timer function as well. I looked and I cannot figure out how to start a timer and then signal it to either make the audio notification or to turn off and do nothing because the winwait command showed up before the timer expired.

Any thoughts

Link to comment
Share on other sites

This is a simple example, in fact, it's really just a compilation of examples from the Helpfile.

$wait = 5 * 1000 ; 5 seconds
$begin = TimerInit()
Do
    $dif = TimerDiff($begin)
    Sleep(10)
Until $dif >= $wait
Beep(500, 1000)

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Link to comment
Share on other sites

  • 3 weeks later...

Is there any way that you could make a timer but still keep the script from holding till the timer reaches that time.

I been trying to write a script that has multiple timers on hotkeys but if one is active then the other timers cannot be activated.

I guess I could have one script for each hotkey but that wouldn't be as rewarding.

Here's the code I've made:

;;;;Potion and Food cooldown timer
#include <Timers.au3>

HotKeySet("u", "STPot")
HotKeySet("i", "HPPot")
HotKeySet("o", "Food")
$Food = 0
$Pot = 0
While 1
    Sleep(100)

WEnd
;;;;;;;;; Functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Func HPPot()
    Send("i")
    $Pot = $Pot + 1
    If $Pot = 1 Then
        ConsoleWrite(" HP  Pot Used" & @CRLF)
        _Timer_SetTimer("Darkfall", "90000", "Sound2")
    Else
        ConsoleWrite("Pot Already On cooldown" & @CRLF)
    EndIf

EndFunc   ;==>HPPot

Func StPot()
    Send("u")
    $Pot = $Pot + 1
    If $Pot = 1 Then
        ConsoleWrite(" Pot Used" & @CRLF)
        _Timer_SetTimer("Darkfall", "90000", "Sound2")
    Else
        ConsoleWrite("Pot Already On cooldown" & @CRLF)
    EndIf

EndFunc   ;==>StPot
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Func Food()
    Send("o")
    $Food = $Food + 1
    If $Food = 1 Then
        ConsoleWrite("%1Food Used" & @CRLF)
        _Timer_SetTimer("Darkfall", "90000", "Sound2")
    Else
        ConsoleWrite("Food Already On cooldown" & @CRLF)
    EndIf
EndFunc   ;==>Food
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Func Sound1()
    ConsoleWrite("Sound1 start" & @CRLF)
    Beep(500, 50)
    Beep(500, 50)
    Beep(500, 50)
    Beep(500, 50)
    ConsoleWrite("Sound1 stop" & @CRLF)
    $Pot = 0
EndFunc   ;==>Sound1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Func sound2()
    ConsoleWrite("Sound2 start" & @CRLF)
    Beep(250, 200)
    Beep(900, 200)
    Beep(250, 200)
    ConsoleWrite("Sound2 stop" & @CRLF)
    $Food = 0

EndFunc   ;==>sound2

It's actually going to be used for Darkfall. Right now the game doesn't have anything to let you know your potions and food are off cooldown.

Whatcha think?

-Attck

ps- sorry the codes ugly

A true renaissance man

Link to comment
Share on other sites

  • 1 year later...

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...