AutoHotkey Community

It is currently May 27th, 2012, 12:04 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: October 6th, 2009, 10:16 am 
Offline

Joined: May 18th, 2009, 7:52 am
Posts: 11
Location: Amsterdam Holand
Hi,
I have build a sampler for a quiz for my school for kids.

With this we can play a music song with medaplayer and when i have select a jingle and pres the button, he mute the music for x seconds, after the jingle has playing, the music is back. Its works fine.

But there a problem with calculating some file, sometimes a jinlge is 2 sec and 600 mmsec, but the script stopt by 2 sec's. I think he can't calculate mmsec.
Now is it posiable to take a extra sec for every jingle, so when i select a jingle, he calculate it for 2 seconds, but he mute the player for 3 seconds.

Can someone help me with this? It would be great, thanks allot.

X Natascha

ps maybe can some look at the script too if i make it correct anyway, maby there are some things i can be make better? suggestions.

Code:
SetFormat,float,0.0


MP3INI=%A_scriptdir%\MP3INI.txt
ifnotexist,%MP3INI%
   {
   IniWrite,nothing2    , %MP3INI%  ,MP3short         , KEY1
   IniWrite,2000x       , %MP3INI%  ,MP3shortlenght   , KEY_1
   }


Gui,2:Add, Button, x10 y10  w90  h90  gJingle1,Tune 1
Gui,2:Add, Picture, x10  y110  w18  h18  gMH1,%A_ScriptDir%\inc\open.ico
IniRead,MP3L1,  %MP3INI%  ,MP3shortlenght       , KEY_1
Gui,2:Add, Text  , x30   y110  ,Select


Gui,2:Show, x300 y3 h260 w130, Test
MP3L2:=(MP3L1/1000)


return



;-------------- plays jingle1 for x seconds ----------
Jingle1:

PostMessage, 0x111, 18816, 150, , Windows Media Player
PostMessage, 0x111, 18816, 150, , Windows Media Player
PostMessage, 0x111, 18816, 150, , Windows Media Player
PostMessage, 0x111, 18816, 150, , Windows Media Player
PostMessage, 0x111, 18816, 150, , Windows Media Player
PostMessage, 0x111, 18816, 150, , Windows Media Player
PostMessage, 0x111, 18816, 150, , Windows Media Player
PostMessage, 0x111, 18816, 150, , Windows Media Player
PostMessage, 0x111, 18816, 150, , Windows Media Player
PostMessage, 0x111, 18816, 150, , Windows Media Player
PostMessage, 0x111, 18816, 150, , Windows Media Player




GuiControl,2:Text,playx,Jingle1
   IniRead,MP3jingle1    , %MP3INI%  ,MP3short      , KEY1

soundplay,%MP3jingle1%

SetTimer, a_continue, %MP3L1% ; run a_continue once, in 4 seconds.
return
a_continue:

soundplay,notexisted.mp3
   IfWinExist, %moz%
   {
   ;WinActivate, %moz%
   ;WinWaitActive, %moz%,,5
   ControlSend,,{space}, %moz%
   }

PostMessage, 0x111, 18815, 50, , Windows Media Player
PostMessage, 0x111, 18815, 50, , Windows Media Player
PostMessage, 0x111, 18815, 50, , Windows Media Player
PostMessage, 0x111, 18815, 50, , Windows Media Player
PostMessage, 0x111, 18815, 50, , Windows Media Player
PostMessage, 0x111, 18815, 50, , Windows Media Player
PostMessage, 0x111, 18815, 50, , Windows Media Player
PostMessage, 0x111, 18815, 50, , Windows Media Player
PostMessage, 0x111, 18815, 50, , Windows Media Player
PostMessage, 0x111, 18815, 50, , Windows Media Player


return

MH1:
; --- write MP3 file path short jingle ------------
FileSelectFile, selectedmp3short ,1, %AA%, Select your MP3/WAV file short jingle,*.mp3;*.wav
if selectedmp3short=
   return
   IniWrite,%selectedmp3short%    , %MP3INI%  ,MP3short      , KEY1
gosub,A2
IniRead,MP3L1,  %MP3INI%  ,MP3shortlenght       , KEY_1
MP3L2:=(MP3L1/1000)
GuiControl,2:Text,Time1,%MP3L2%
return



;---------------------------------------------------------------------------
A2:

;---------------------- TIME LENGHT DURATION MP3----------------------------
;TAG........... http://www.softpedia.com/progDownload/Tag-Download-21935.html
;----------------------------------------------------------------------------

IniRead,MP3VAR2,  %MP3INI%  ,MP3short     , KEY1
Musicfile="%MP3VAR2%"
F1=test55.txt
ifexist,%F1%
 Filedelete,%F1%
DetectHiddenWindows On
mycmd=c:\tag.exe --test --tofilen %F1% %Musicfile%
run,%comspec% /K %myCmd%,,hide,PID1
WinWait %ComSpec% ahk_pid %PID1%
WinActivate ahk_pid %PID1%
process,close,%PID1%


loop,read,%F1%
  {
  LR=%A_loopreadline%
  ifinstring,LR,Details:
  stringsplit,C,LR,`,
  stringsplit,D,C3,`:
  stringmid,d1a,d1,11,2
  }

D1b:=ABS(D1a)
D2b:=ABS(D2)
MINMilliSEC:=((D1b*60)*1000)
SECMilliSEC:=(D2b*1000)
Total:=(MINMilliSEC+SECMilliSEC)
;msgbox,Minutes-ms=%MINmilliSEC%`nSeconds-ms=%SECMilliSEC%`nTotal=%total%
;run,%F1%
IniWrite,%Total%   , %MP3INI%  ,MP3shortlenght      , KEY_1
;exitapp
return
;------------------------------------------------------------------------------





Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 6th, 2009, 11:36 pm 
Offline

Joined: August 22nd, 2009, 11:23 pm
Posts: 294
Try the command "A_Tickount"

Code:
_TickCount The number of milliseconds since the computer was rebooted. By storing A_TickCount in a variable, elapsed time can later be measured by subtracting that variable from the latest A_TickCount value. For example:

StartTime := A_TickCount
Sleep, 1000
ElapsedTime := A_TickCount - StartTime
MsgBox,  %ElapsedTime% milliseconds have elapsed.If you need more precision than A_TickCount's 10ms, use QueryPerformanceCounter().
 


The QueryPerformanceCounter gives more accuracy.
Code:
; Example: Demonstrates QueryPerformanceCounter(), which gives more precision than A_TickCount's 10ms.

DllCall("QueryPerformanceCounter", "Int64 *", CounterBefore)
Sleep 1000
DllCall("QueryPerformanceCounter", "Int64 *", CounterAfter)
MsgBox % "Elapsed QPC time is " . CounterAfter - CounterBefore


Have Fun, :lol:

_________________
Image
"Man's quest for knowledge is an expanding series whose limit is infinity"


Report this post
Top
 Profile  
Reply with quote  
 Post subject: difficult
PostPosted: October 7th, 2009, 9:09 am 
Offline

Joined: May 18th, 2009, 7:52 am
Posts: 11
Location: Amsterdam Holand
Oke oeps
Thats too difficult for me, can you explane it for me how to configure that with my situation/script?


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: BrandonHotkey, Leef_me, Pulover, XstatyK, Yahoo [Bot] and 13 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group