Jump to content

Zamanlı Işlem


kamuran731
 Share

Recommended Posts

burada bir kodlama var ama bilmem işine yararmı sanırım bir Timer.ini dosyası oluşturup verilerini oradan çekebilirsin alıntıdır yanlız

[codebox]
#include <Sound.au3>

;Will play a random mp3 in script directory.

;Load all times, format shown below
;Weekday,Hour,Min
;1|08|15|
$Ini = IniReadSection(@ScriptDir & "\Timer.ini", 'TriBe')

;Get list of all mp3s in folder.
$MP3 = _FileListToArray(@ScriptDir, '*.mp3')

;Create array that matches the number of alarms.
Global $MyArray[$Ini[0][0] + 1][3]
$MyArray[0][0] = $Ini[0][0]

;Convert ini string to array for internal use.
For $i = 1 To $Ini[0][0]
$Tmp = StringSplit($Ini[$i][1], '|')
For $j = 1 To 3
$MyArray[$i][$j - 1] = $Tmp[$j]
Next
Next


;Check every second.
AdlibRegister('_CheckAlarm', 750)

;Show me current time.
ConsoleWrite(@WDAY & ' ~ ' & @HOUR & ' ~ ' & @MIN & @CRLF)

While 1
Sleep(100)
WEnd

Func _CheckAlarm()
;Loop through all alarms
For $X = 1 To $MyArray[0][0]
;If it is time to wake up, play a song.
If $MyArray[$X][0] == @WDAY And $MyArray[$X][1] == @HOUR And $MyArray[$X][2] == @MIN Then _PlayAlarm($X)
Next
EndFunc ;==>_CheckAlarm

Func _PlayAlarm($X)
;Generate a random number.
$Tmp = Random(1, $MP3[0], 1)

;Open random MP3
$Sound = _SoundOpen(@ScriptDir & '\' & $MP3[$Tmp])
_SoundPlay($Sound)

;Wait till I press Ok on the message box, if I don't play another song.
While Not (MsgBox(0, 'Morning!', 'Have a good day!', _SoundLength($Sound, 2) / 1000) == 1)
_SoundStop($Sound)
$Tmp = Random(1, $MP3[0], 1)
$Sound = _SoundOpen(@ScriptDir & '\' & $MP3[$Tmp])
_SoundPlay($Sound)
WEnd

;Shut the fuck up.
_SoundStop($Sound)

;Wait till current minute is over.
While $MyArray[$X][2] == @MIN
Sleep(1000)
WEnd
EndFunc ;==>_PlayAlarm

Func _FileListToArray($sPath, $sFilter = "*", $iFlag = 0)
Local $hSearch, $sFile, $sFileList, $sDelim = "|"
$sPath = StringRegExpReplace($sPath, "[\\/]+\z", "") & "\" ; ensure single trailing backslash
If Not FileExists($sPath) Then Return SetError(1, 1, "")
If StringRegExp($sFilter, "[\\/:><\|]|(?s)\A\s*\z") Then Return SetError(2, 2, "")
If Not ($iFlag = 0 Or $iFlag = 1 Or $iFlag = 2) Then Return SetError(3, 3, "")
$hSearch = FileFindFirstFile($sPath & $sFilter)
If @error Then Return SetError(4, 4, "")
While 1
$sFile = FileFindNextFile($hSearch)
If @error Then ExitLoop
If ($iFlag + @extended = 2) Then ContinueLoop
$sFileList &= $sDelim & $sFile
WEnd
FileClose($hSearch)
If Not $sFileList Then Return SetError(4, 4, "")
Return StringSplit(StringTrimLeft($sFileList, 1), "|")
EndFunc;==>_FileListToArray
[/codebox]

Edited by MeHMeTBeN
Link to comment
Share on other sites

@MostWanted
Hocam çalıştı çok güzel olmuş ellerine sağlık.
yanlız belli bir tarihte çalmasını sağlamak için ne yapmalıyız
mesela 27/02/2012 pzt saat 18:00 da çalmasını istiyorum.

Ayrıca date picker ekleyip ordan seçtiğimiz tarihi Timer.ini ye yazdırtabilirmiyiz.?

Edited by kamuran731
Link to comment
Share on other sites

Aslında dediklerinin tamamı projenin içinde cevaplı.Mesela herhangi bir gün dedin değil mi?Ben projede örnek olarak ne yaptım ini ye verileri girdim ve şu anki durumla karşılaştırdım.O zaman senin yapman gereken iniye tarih diye bi değer girmen ve bunu okutup ordaki if de şu anki durumla eşitlemen.Diğer dediğini sormaman bile gerek.Zaten bu obje onun için yapılmış.Tek gereken verileri okuman ve bunları iniye yazdırman.Kolay gelsin.

Edited by MostWanted
Link to comment
Share on other sites

hocam
Func _CheckAlarm() fonsiyonuna aşağıdaki Tarih satırını ekledim
$Tarih=IniRead($inidir, $Ini[$i],"Tarih", "00.12.2012")

if kısmını ise aşağıdaki gibi yaptım
If $gun = bugun() And $saat = @HOUR&":" &@MIN And $Tarih = @MDAY&"." @MON& "." &@YEAR Then
_PlayAlarm($mesaj)
Sleep(60000)
EndIf

iniye yazdığım tarih ve saatte çalışıyor ama [color="#FF0000"][b] if hatası veriyor[/b][/color]

Edited by kamuran731
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...