Sign in to follow this  
Followers 0
Natas70

sound with keypress (turn off)

7 posts in this topic

I have wrote a script with autoit to create a gui for an exercise bike i am building. It uses an i-pac 4 keyboard input board, connected to a magnetic reed switch to read the magnet on the bike wheel as it completes each rotation. eventually it will include an mp3 player and others. I have been programming this on my laptop, that has headphones plugged into it,so i never noticed it before, but for some reason i had just put my headphones in and noticed that there is a sound being played each time a key press has been made. I am not sure where to look to see how to disable this sound. i searched this forum (general support) and found how to have it make a sound, but i have not been coding anything to make a sound.

I have an i-pac 4 on a arcade cabinet i built a couple of years ago and it does not play a sound each time a key is pressed, The sound does not happen as i am typing this to you now in the forums, so i am sure it is happening inside the script. If you like i can post the script, just not sure if it is necessary to post all of it if there is a simple solution that causes this.

Many thanx in advance to anyone that can help

James

Share this post


Link to post
Share on other sites



James, I am pretty confident that, unless you coded it, this is not happening in your script. An easy way to check: Turn the script off and try again.

Share this post


Link to post
Share on other sites

James, I am pretty confident that, unless you coded it, this is not happening in your script. An easy way to check: Turn the script off and try again.

ok i close the script it doesn't happen, i run the script with the script "active" and it beeps, i open a text document with the script in the background, and type normally and it doesn't make the beep, i go back to "active" on the script and press the "s" key and it beeps each time again. so i am including the full script except the empty functions (for the labels and other stuff in the gui). if you wouldn't mind quickly scan to see what might be causing the beep.

just a little about my programming experience - i started programming in junior high on commodores and apple 2e's, i went to college to program cobol on mainframes before i dropped out due to funding... up until autoit, i dabbled in learning a little bit of visual basic to make a program and then didn't program until autoit. so I am not a Professional, but love to code so i am learning. sorry if this coding seems juvenile, but other than the beep, it works fine.

thanx in advance.

James

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GUIComboBox.au3>
#include <Misc.au3>


Opt("GUIOnEventMode", 1)
#Region ### START Koda GUI section ### Form=c:\users\jamtop\documents\autoit projects\tcptesting\bikegui.kxf
$Form1 = GUICreate("ExerCycle", 1001, 551, 184, 113)
GUISetFont(16, 400, 0, "Digital-7")
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "Form1Minimize")
GUISetOnEvent($GUI_EVENT_MAXIMIZE, "Form1Maximize")
GUISetOnEvent($GUI_EVENT_RESTORE, "Form1Restore")
$userlbl = GUICtrlCreateLabel("Rider", 50, 26, 49, 28, $SS_RIGHTJUST)
GUICtrlSetFont(-1, 16, 400, 0, "Digital-7")
GUICtrlSetOnEvent(-1, "userlblClick")
$dislbl = GUICtrlCreateLabel("Distance to Ride", 374, 25, 140, 28, $SS_RIGHTJUST)
GUICtrlSetFont(-1, 18, 400, 0, "Digital-7")
GUICtrlSetOnEvent(-1, "dislblClick")
$disinp = GUICtrlCreateInput("", 524, 25, 75, 32)
GUICtrlSetFont(-1, 18, 400, 0, "Digital-7")
GUICtrlSetOnEvent(-1, "disinpChange")
$timelbl = GUICtrlCreateLabel("Time to Ride", 775, 25, 111, 28, $SS_RIGHTJUST)
GUICtrlSetFont(-1, 18, 400, 0, "Digital-7")
GUICtrlSetOnEvent(-1, "timelblClick")
$timeinp = GUICtrlCreateInput("", 901, 25, 75, 32)
GUICtrlSetFont(-1, 18, 400, 0, "Digital-7")
GUICtrlSetOnEvent(-1, "timeinpChange")
$curspdlbl = GUICtrlCreateLabel("Current Speed", 50, 100, 127, 28, $SS_RIGHTJUST)
GUICtrlSetFont(-1, 18, 400, 0, "Digital-7")
GUICtrlSetOnEvent(-1, "curspdlblClick")
$avgspdlbl = GUICtrlCreateLabel("Average Speed", 375, 100, 136, 28, $SS_RIGHTJUST)
GUICtrlSetFont(-1, 18, 400, 0, "Digital-7")
GUICtrlSetOnEvent(-1, "avgspdlblClick")
$disrodelbl = GUICtrlCreateLabel("Distance Rode", 50, 225, 127, 28, $SS_RIGHTJUST)
GUICtrlSetFont(-1, 18, 400, 0, "Digital-7")
GUICtrlSetOnEvent(-1, "disrodelblClick")
$jighspdlbl = GUICtrlCreateLabel("Highest Speed", 750, 100, 129, 28, $SS_RIGHTJUST)
GUICtrlSetFont(-1, 18, 400, 0, "Digital-7")
GUICtrlSetOnEvent(-1, "jighspdlblClick")
$curspdout = GUICtrlCreateLabel("0 mph", 200, 100, 57, 28, $SS_RIGHTJUST)
GUICtrlSetFont(-1, 18, 400, 0, "Digital-7")
GUICtrlSetOnEvent(-1, "curspdoutClick")
$avgspdout = GUICtrlCreateLabel("0 mph", 524, 100, 57, 28, $SS_RIGHTJUST)
GUICtrlSetFont(-1, 18, 400, 0, "Digital-7")
GUICtrlSetOnEvent(-1, "avgspdoutClick")
$highspdout = GUICtrlCreateLabel("0 mph", 900, 100, 57, 28, $SS_RIGHTJUST)
GUICtrlSetFont(-1, 18, 400, 0, "Digital-7")
GUICtrlSetOnEvent(-1, "highspdout")
$curspdprog = GUICtrlCreateProgress(50, 150, 930, 29, BitOR($PBS_SMOOTH,$WS_BORDER))
GUICtrlSetColor(-1, 0x00FF00)
GUICtrlSetBkColor(-1, 0xFFFF00)
$disrodeout = GUICtrlCreateLabel("1.1 miles", 199, 225, 78, 28, $SS_RIGHTJUST)
GUICtrlSetFont(-1, 18, 400, 0, "Digital-7")
GUICtrlSetOnEvent(-1, "disrodeoutClick")
$longdislbl = GUICtrlCreateLabel("Longest Distance", 350, 225, 148, 28, $SS_RIGHTJUST)
GUICtrlSetFont(-1, 18, 400, 0, "Digital-7")
GUICtrlSetOnEvent(-1, "longdislblClick")
$longestout = GUICtrlCreateLabel("300 miles", 525, 225, 83, 28, $SS_RIGHTJUST)
GUICtrlSetFont(-1, 18, 400, 0, "Digital-7")
GUICtrlSetOnEvent(-1, "longestout")
$odomlbl = GUICtrlCreateLabel("Odometer", 750, 225, 89, 28, $SS_RIGHTJUST)
GUICtrlSetFont(-1, 18, 400, 0, "Digital-7")
GUICtrlSetOnEvent(-1, "odomlblClick")
$odomout = GUICtrlCreateLabel("1000.56 miles", 850, 225, 118, 28, $SS_RIGHTJUST)
GUICtrlSetFont(-1, 18, 400, 0, "Digital-7")
GUICtrlSetOnEvent(-1, "odomoutClick")
$curdisprog = GUICtrlCreateProgress(49, 275, 930, 29, BitOR($PBS_SMOOTH,$WS_BORDER))
GUICtrlSetColor(-1, 0x00FF00)
GUICtrlSetBkColor(-1, 0xFFFF00)
$curtimeprog = GUICtrlCreateProgress(50, 400, 930, 29, BitOR($PBS_SMOOTH,$WS_BORDER))
GUICtrlSetColor(-1, 0x00FF00)
GUICtrlSetBkColor(-1, 0xFFFF00)
$timeridelbl = GUICtrlCreateLabel("Time Elapsed", 47, 350, 121, 28, $SS_RIGHTJUST)
GUICtrlSetFont(-1, 18, 400, 0, "Digital-7")
GUICtrlSetOnEvent(-1, "timeridelblClick")
$timerideout = GUICtrlCreateLabel("3:25 minutes", 200, 350, 110, 28, $SS_RIGHTJUST)
GUICtrlSetFont(-1, 18, 400, 0, "Digital-7")
GUICtrlSetOnEvent(-1, "timerideoutClick")
$hourmeterlbl = GUICtrlCreateLabel("Hour Meter", 750, 350, 99, 28, $SS_RIGHTJUST)
GUICtrlSetFont(-1, 18, 400, 0, "Digital-7")
GUICtrlSetOnEvent(-1, "hourmeterlblClick")
$hourmeterout = GUICtrlCreateLabel("30.25 hours", 875, 350, 102, 28, $SS_RIGHTJUST)
GUICtrlSetFont(-1, 18, 400, 0, "Digital-7")
GUICtrlSetOnEvent(-1, "hourmeterout")
$newuserbtn = GUICtrlCreateButton("New User", 475, 500, 125, 25, 0)
GUICtrlSetOnEvent(-1, "newuserbtnClick")
$closebtn = GUICtrlCreateButton("Close", 775, 500, 125, 25, 0)
GUICtrlSetOnEvent(-1, "closebtnClick")
$startbtn = GUICtrlCreateButton("Start/Stop", 150, 500, 125, 25, 0)
GUICtrlSetOnEvent(-1, "startbtnClick")
$usercombo = GUICtrlCreateCombo("", 125, 25, 115, 25, BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL))
GUICtrlSetFont(-1, 18, 400, 0, "Digital-7")
GUICtrlSetOnEvent(-1, "usercomboChange")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

$dll = DllOpen("user32.dll")

dim $section [10]
dim $secarray [1000]
$sectiontemp = ""
$curdir = @WorkingDir & "\"
$user = ""
$usertemp = ""
$timerode = 0
$distancerode = 0
$timetoride = 0
$distancetoride = 0
$currentspeed = 0
$averagespeed = 0
$longest = 0
$startclicked = "no"
$highspeed = 0
$longest = 0
$odometer = 0
$odom = 0
$hour = 0
$hourtemp = 0
$seconds = 0
$spdtemp = 0
$istart = 0
$ihour = 0
$imin = 0
$isec = 0
$imsec = 0
$distemp = 0
$sectemp3 = 1
$sectemp2 = 1
$sectemp1 = 1
$secdiff = 0
$tiresize = 81.68140899333463
$distance = ($tiresize/12)
$mile = 5280
$j = 0
$notspinning = 0
$maxtocheck = 10
$distance = ($tiresize/12) * $maxtocheck
$avgspd1 = 0
$avgspd = 0

loadgui ()
updategui ()
While 1
       Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
    If GUICtrlRead($usercombo) <> $user And _GUICtrlComboBox_GetDroppedState($usercombo) = False Then
        $usertemp = GUICtrlRead($usercombo)
        $user = $usertemp
        loaduser ()
        updategui ()
    EndIf
    If _GUICtrlComboBox_GetDroppedState($usercombo) Then $user = ""
    sleep (100)
    if $user <> "" then 
        If _IsPressed("53", $dll) Then 
            movement ()
            $notspinning = 0
        EndIf
            $notspinning = $notspinning + 1
            if $notspinning > 10 then 
                $currentspeed = $currentspeed - 10
                $notspinning = 0
                if $currentspeed < 0 then $currentspeed = 0
            EndIf
        stopwatch ()
        updategui ()
    EndIf
WEnd    
;**************************************************************************************************************************************
func loadgui ()
    $section = IniReadSectionNames($curdir & "\Settings.ini")
    for $i = 1 to $section[0]
        $sectiontemp = $sectiontemp & $section[$i] & "|"
    Next
    guictrlsetdata ($usercombo, $sectiontemp)
EndFunc
;**************************************************************************************************************************************
func updategui ()
            guictrlsetdata ($highspdout, $highspeed)
            guictrlsetdata ($longestout, $longest)
            guictrlsetdata ($odomout, $odom)
            guictrlsetdata ($hourmeterout, $hour)
            guictrlsetdata ($timerideout,$timerode)
            guictrlsetdata ($disrodeout,$distancerode)
            guictrlsetdata ($curspdout,$currentspeed)
            guictrlsetdata ($avgspdout,$averagespeed)
            $spdprg  = Int(($currentspeed / $highspeed) * 100)
            guictrlsetdata ($curspdprog, $spdprg)
            if $timetoride > 0 then 
                $timeprg  = Int(($seconds / $timetoride) * 100)
                guictrlsetdata ($curtimeprog, $timeprg)
            EndIf
            if $distancetoride > 0 then 
                $disprg  = Int(($distancerode / $distancetoride) * 100)
                guictrlsetdata ($curdisprog, $disprg)
            EndIf
EndFunc
;************************************************************************************************************************************** 
func loaduser()
            $highspeed = iniread ($curdir & "\Settings.ini",$user,"highspeed","")
            $longest = iniread ($curdir & "\Settings.ini",$user,"longest","")
            $odometer = iniread ($curdir & "\Settings.ini",$user,"odometer","")
            $hour = iniread ($curdir & "\Settings.ini",$user,"hour","")
            $key = iniread ($curdir & "\Settings.ini",$user,"key","")
            $hourtemp = $hour
            $odom =  $odometer
EndFunc
;************************************************************************************************************************************** 
func stopwatch ()
    if $startclicked = "yes" then
        $iTime = Int(TimerDiff($iStart)/100)/10
        $iHour=Int($iTime/3600)
        $iMin = Int(($iTime-$iHour*3600)/60)
        $iSec = Int($iTime)-$iHour*3600-$iMin*60
        $iMsec = Int(($iTime-Int($iTime))*10)
        If $iHour < 10 Then $iHour='0'&$iHour
        If $iMin < 10 Then $iMin='0'&$iMin
        If $iSec < 10 Then $iSec='0'&$iSec
        $timerode = $ihour & ":" & $imin & ":" & $isec & "." & $imsec
        $seconds = $itime
        guictrlsetdata ($timerideout,$timerode)
    EndIf   
EndFunc
;**************************************************************************************************************************************
func movement ()
        if $startclicked = "yes" then 
            $distemp = $distemp + ($tiresize/12)
            $distancerode = int($distemp/$mile*100)/100
            if $distancerode > $longest then $longest = $distancerode
            $odom = $odometer + $distancerode
            $averagespeed = int($distancerode / ($seconds/3600))
            $hour = int(($hourtemp + ($seconds/3600))*1000)/1000
            for $j = $maxtocheck to 2 step -1
                $secarray [$j] = $secarray [$j-1]
                $secarray [$j-1] = $seconds
            Next
            $spdtemp = 0
            For $j = 1 to $maxtocheck
                $spdtemp = $spdtemp + $secarray [$j]
            next    
            $avgspd1 = $avgspd
            $avgspd = $spdtemp/$maxtocheck
            $secdiff = $avgspd - $avgspd1
            $currentspeed = int((($distance / $secdiff)* 0.632352941176470)/10)
            if ($currentspeed > $highspeed) and ($seconds > 10) then $highspeed = $currentspeed
        EndIf
endfunc
;**************************************************************************************************************************************
func updateini ()
    $odometer = $odom
    IniWrite ($curdir & "\Settings.ini",$user,"highspeed", $highspeed)
    IniWrite ($curdir & "\Settings.ini",$user,"longest", $longest)
    IniWrite ($curdir & "\Settings.ini",$user,"odometer", $odometer)
    IniWrite ($curdir & "\Settings.ini",$user,"hour", $hour)
    $hourtemp = $hour
EndFunc
;**************************************************************************************************************************************
Func closebtnClick()
    Exit
EndFunc
;**************************************************************************************************************************************
Func disinpChange()
    $distancetoride = guictrlread ($disinp)
    consolewrite ($distancetoride & @crlf)
EndFunc
;**************************************************************************************************************************************
Func Form1Close()
    exit
EndFunc
;**************************************************************************************************************************************
Func newuserbtnClick()
    $newuser = InputBox("New User", "Enter name of the new user", "", "", _
    -1, -1, 0, 0)
    if $newuser <> "" then 
        $user = $newuser
        iniwritesection ($curdir & "\Settings.ini",$newuser,"")
        IniWrite ($curdir & "\Settings.ini",$user,"highspeed", "0")
        IniWrite ($curdir & "\Settings.ini",$user,"longest", "0")
        IniWrite ($curdir & "\Settings.ini",$user,"odometer","0")
        IniWrite ($curdir & "\Settings.ini",$user,"hour", $hour)
    EndIf
EndFunc
;**************************************************************************************************************************************
Func startbtnClick()
    if $startclicked = "no" then
        $startclicked = "yes"
        $iStart = TimerInit()
    else
        $startclicked = "no"
        $distancerode = 0
        $distemp = 0
        updateini ()
    EndIf
EndFunc
;**************************************************************************************************************************************
Func timeinpChange()
    $timetoride = guictrlread ($timeinp) * 60
    consolewrite ($timetoride & @crlf)
EndFunc
;**************************************************************************************************************************************

Share this post


Link to post
Share on other sites

If there is something in your script that is making a sound, I cannot identify it either. We can leave that issue to another developer that maybe has experience with this.

As a last attempt, could you for me disable all windows sounds in control panel? It goes something like this:

Posted Image

Share this post


Link to post
Share on other sites

I disabled the sounds as you asked, and the sound is now gone. Thanx for help.

So there is nothing in autoit that automatically plays a sound with a keystroke, that can be disabled?

Share this post


Link to post
Share on other sites

So there is nothing in autoit that automatically plays a sound with a keystroke, that can be disabled?

That's right. It is Windows functionality. A lot of other programs will show the same behavior.

Share this post


Link to post
Share on other sites

I have hit exactly the same problem. It seems that even though you are using _isPressed to detect the keystroke, Windows interprets the keypress as a keying error before your program gets to react to it and plays the default error sound which is annoying when I am also playing a sound when the keys are pressed. This doesn't happen with HoTKeySet but I don't want an application-wide keypress function call, just a detection within a small subroutine at a specific time so this doesn't help. I did hope that there might be an Opt setting that would suppress system sounds but no joy.

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