
ronriel
Active Members-
Posts
45 -
Joined
-
Last visited
Everything posted by ronriel
-
BASS Function Library (Sound and Music Functions)
ronriel replied to BrettF's topic in AutoIt Example Scripts
This is very interesting! Thank you. -
Hi, I actually have been using a simple script like this basically to help me with the examples on the Autoit Helpfile. All you have to do is highlight the part of the script you'd like to run and hit the hotkey. Here it is: ;ronriel's helper HotKeySet ("^r", "Runscript") HotKeySet ("^e", "edit") HotKeySet ("^t", "Terminate") Local $temp = @TempDir&"\AutoitCode.Au3", $PID Func Runscript();run the script get() $PID = Run(@AutoItExe&" "&$temp) EndFunc Func edit();edit the script with your editor, that is, if you have an editor set as the default program to open .au3 scripts. get() ShellExecute($temp) EndFunc Func Terminate();terminate the script. ProcessClose($PID) EndFunc Func get();retreive the script from the clipboard Send("^c") FileClose(FileWrite(FileOpen($temp,2),ClipGet())) EndFunc While 1 Sleep (100000) WEnd Simple but helpful.
-
Please check my first post. I have updated the script. Kindly check here. It might give you some ideas. Good luck.
-
Hello, I would like to share this. You need to have MS Office 2003 or 2007 Document Imaging installed for this to work. Returns: [0][0] - number of recognized words in a containing image [1][1] - Returns the distance in pixels of the left edge of the specified rectangle from the left edge of the containing image. [1][2] - Returns the distance in pixels of the top edge of the specified rectangle from the top edge of the containing image. [1][3] - Returns the width of the specified rectangle. [1][4] - Returns the height of the specified rectangle. ; #FUNCTION# ==================================================================================================== ================ ; Name.......: OCR_GetWordsCoordinates ; Description: Performs optical character recognition (OCR) on a specified image file, and then reports the coordinates ; and size of the bounding rectangle surrounding each word in the recognized text. ; Author ....: ronriel ; ==================================================================================================== =========================== Func OCR_GetWordsCoordinates($Image) Local $error = ObjEvent("AutoIt.Error","Error"),$items[1][5] $miDoc = ObjCreate("MODI.Document") $miDoc.Create($Image) If @error Then Return SetError(1,0,-1) $miDoc.Ocr(9, True, True) If @error Then Return SetError(2,0,-1) EndIf $items[0][0] = $miDoc.Images(0).Layout.Numwords;number of recognized words in a containing image For $y = 1 to $items[0][0] ReDim $items[$y+1][5] $items[$y][0] = $miDoc.Images(0).Layout.Words($y-1).text;the recognized word For $miRect In $miDoc.Images(0).Layout.Words($y-1).Rects $items[$y][1] = $miRect.Left;Returns the distance in pixels of the left edge of the specified rectangle from the left edge of the containing image. $items[$y][2] = $miRect.Top ;Returns the distance in pixels of the top edge of the specified rectangle from the top edge of the containing image. $items[$y][3] = $miRect.Right - $miRect.Left;width of the specified rectangle $items[$y][4] = $miRect.Bottom - $miRect.Top ;height of the specified rectangle Next Next Return $items EndFunc Func Error() Endfunc ;EXAMPLE #include<array.au3> $a = FileOpenDialog("Choose an Image File",@DesktopDir&"\","Images (*.jpg;*.bmp;*.gif;*.png;*.tif)") If @error then Return $b = OCR_GetWordsCoordinates($a) _ArrayDisplay($b) I hope this is useful.
-
It requires MS Office 2003 or 2007 Document Imaging installed.
-
Hi, This can be quite useful. This little script lets you select any part of the screen, use OCR to read for texts,and then store them in the clipboard. You may also select image files directly and read texts in them. Just Press ALT+Q to start. UPDATE: *OCR script now tries to detect line breaks. OCR'd text will now be pasted with @CRLFS. *Removed the cursor from the captured image. ;r-OCR ;By: ronriel ;updated oct. 20, 2008 ;autoit-v3.2.12.1 ;Tested Windows XP SP2 with MS Office 2007 #Include <ScreenCapture.au3> #include <WindowsConstants.au3> #Include <Misc.au3> _Singleton("script",0) Opt("GUIOnEventMode",1) Opt("WinTitleMatchMode", 4) Opt("TrayOnEventMode",1) Opt("TrayMenuMode",1) HotKeySet("!q","ShowWin") Local $err = ObjEvent("AutoIt.Error","Error") $GUI = GUICreate("", 90, 40,-1,-1,0x80880000,$WS_EX_TOOLWINDOW) WinSetTrans($GUI,'',200) $B1 = GUICtrlCreateButton("Read Region", 0, 0, 90, 20) GUICtrlSetBkColor(-1,0xe6e6fa) GUICtrlSetOnEvent(-1,"Capture") $B2 = GUICtrlCreateButton("Read File", 0, 20, 90, 20) GUICtrlSetBkColor(-1,0xe6e6fa) GUICtrlSetOnEvent(-1,"Capture") $GUI2 = GUICreate("", 0 , 0 , 0, 0, BitOR($WS_POPUP,$WS_BORDER), BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW)) GUISetBkColor(0xe6e6fa,$GUI2) WinSetTrans($GUI2,'',60) GUISetState(@SW_HIDE) $GUI3 = GUICreate("", 0 , 0 , 0,0 , BitOR($WS_POPUP,$WS_BORDER), BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW)) GUISetBkColor(0xFF0000,$GUI3) GUISetState(@SW_HIDE) TrayCreateItem("Info") TrayItemSetOnEvent(-1,'Ex') $Exit = TrayCreateItem("Exit") TrayItemSetOnEvent(-1,'Ex') TraySetState() Func ShowWin() If BitAND(WinGetState($GUI),2) Then GUISetState(@SW_HIDE,$GUI) Else $Mpos = MouseGetPos() WinMove($GUI,'',$Mpos[0]-45,$Mpos[1]-10) GUISetState(@SW_SHOW,$GUI) EndIf EndFunc Func Capture() Local $Image = @TempDir&"\ScreenCapture.png", $v = 0 If @GUI_CtrlId = $B1 Then GUISetState(@SW_HIDE,$GUI) GUISetState(@SW_SHOW,$GUI3) Do Sleep(10) ToolTip("Read Region") $c = MouseGetPos() WinMove($GUI3,"",$c[0]-2.5,$c[1]-2.5,5,5) If _IsPressed(01) Then ToolTip('') $C1 = MouseGetPos() Do Sleep(10) $C2 = MouseGetPos() If $C2[0] <> $C1[0] And $C2[1] <> $C1[1] Then GUISetState(@SW_SHOW,$GUI2) EndIf If $C1[0] < $C2[0] Then $X = $C1[0] $W = $C2[0] - $C1[0] Else $X = $C2[0] $W = $C1[0] - $C2[0] EndIf If $C1[1] < $C2[1] Then $Y = $C1[1] $H = $C2[1] - $C1[1] Else $Y = $C2[1] $H = $C1[1] - $C2[1] EndIf WinMove($GUI2,"",$X,$Y,$W,$H) WinMove($GUI3,"",$c2[0]-2.5,$c2[1]-2.5,5,5) Until Not _IsPressed(01) $v = 1 EndIf Until $v = 1 GUISetState(@SW_HIDE,$GUI2) GUISetState(@SW_HIDE,$GUI3) _ScreenCapture_Capture($Image,$x,$y,$x+$W,$y+$h,False) ElseIf @GUI_CtrlId = $B2 Then GUISetState(@SW_HIDE,$GUI) $Image = FileOpenDialog("Choose an Image File",@DesktopDir&"\","Images (*.jpg;*.bmp;*.gif;*.png;*.tif)") if @error then Return EndIf $OCR = OCR($Image) If @error then Return ClipPut($OCR) TrayTip("Info","Text saved to Clipboard",2,1) EndFunc Func OCR($Image) Local $y = 0, $string $miDoc = ObjCreate("MODI.Document") $miDoc.Create($Image) If @error Then Return SetError(1) $miDoc.Ocr(9, True, True);language is English If @error Then TrayTip("Info","OCR could not read any character.",2,1) ClipPut("Error!") Return SetError(1) EndIf For $Word In $miDoc.Images(0).Layout.Words $delim = ' ' If $miDoc.Images(0).Layout.Words($y).Rects(0).Bottom < $miDoc.Images(0).Layout.Words($y+1).Rects(0).Top Then $delim = @CRLF $string &= $Word.text & $delim $y += 1 Next Return StringTrimRight($string,1) EndFunc Func Error() Endfunc Func Ex() If @TRAY_ID = $Exit Then Exit Else MsgBox(0,"Info", "Press ALT+Q to start."&@CRLF&@CRLF&"r-OCR"&@CRLF&"By: ronriel (ronriel@yahoo.com)") EndIf EndFunc While 1 Sleep(100000) WEnd Good Luck!
-
Yeah, you did some search but did not read what you've found. Anyway, here's an example: #include <GUIConstants.au3> #include <Sound.au3> $sound = "NONE" SoundSetWaveVolume(100) #Region ### START Koda GUI section ### Form=c:\documents and settings\windows\desktop\mplayer\gui.kxf $AForm1 = GUICreate("Ashley's MediaPlayer", 633, 447, 193, 115) GUISetBkColor(0xA6CAF0) $AGroup1 = GUICtrlCreateGroup("", 136, 384, 369, 57) $play = GUICtrlCreateButton("Play", 144, 400, 57, 33, $BS_DEFPUSHBUTTON) $stop = GUICtrlCreateButton("Stop", 360, 400, 57, 33, $BS_DEFPUSHBUTTON) $open = GUICtrlCreateButton("open", 424, 400, 59, 33, $BS_DEFPUSHBUTTON) $Pause = GUICtrlCreateButton("Pause", 208, 400, 59, 33, $BS_DEFPUSHBUTTON) $made = GUICtrlCreateLabel("Made by Ashley", 272, 400, 79, 17) $loop = GUICtrlCreateCheckbox("loop", 288, 416, 49, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $AProgress1 = GUICtrlCreateProgress(16, 361, 590, 15, $PBS_SMOOTH) GUICtrlSetData(-1, 0) GUICtrlSetColor(-1, 0xFF0000) $Nowplaying = GUICtrlCreateLabel("Now playing:", 24, 384, 65, 17) $edit = GUICtrlCreateInput($sound, 8, 408, 113, 21, BitOR($ES_AUTOHSCROLL,$ES_READONLY)) $Duration = GUICtrlCreateLabel("", 536, 384, 47, 17, BitOR($SS_CENTERIMAGE,$WS_BORDER,$WS_CLIPSIBLINGS)) $ALabel1 = GUICtrlCreateLabel("This is a pre release...", 160, 64, 318, 41) GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif") $ALabel2 = GUICtrlCreateLabel("Some Functions do not work...", 110, 159, 439, 41) GUICtrlSetFont(-1, 24, 400, 0, "MS Sans Serif") GUISetState(@SW_SHOW) Local $s, $SL #EndRegion ### END Koda GUI section ### AdlibEnable("Progress") While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $stop GUICtrlSetData($Duration, "Stopping") Sleep(1000) _SoundStop($s) GUICtrlSetData($Duration, "Stopped") Case $msg = $open GUICtrlSetData($Duration, "Open") $sound=FileOpenDialog("Open Music File","C:\Documents and Settings\Windows\My Documents\My Music","Music Files(*.mp3;*.wav;*.wma;*.cda)",3) $s = _SoundOpen($sound) $SL = _SoundLength($s, 2) GUICtrlSetData($Duration, "") GUICtrlSetData($edit, $sound) Case $msg = $play If GUICtrlRead($Duration) = "Stopped" Or GUICtrlRead($Duration) = "" Then GUICtrlSetData($Duration, "Playing") ElseIf GUICtrlRead($Duration) = "Paused" Then GUICtrlSetData($Duration, "Playing") EndIf _SoundPlay($s) ;pause Case $msg = $Pause If GUICtrlRead($Duration) = "Playing" Then GUICtrlSetData($Duration, "Paused") _SoundPause($s) EndIf endselect WEnd Func progress() GUICtrlSetData($AProgress1,_SoundPos($s, 2)/ $SL * 100);move the progress bar as the song progresses EndFunc Pause and progress bar should work.
-
Why? Perhaps those files are not associated with correct MCI drivers anymore. Or maybe you have in some way uninstalled necessary audio codecs. Try installing one maybe it will correct your problem.
-
Nice cyanidemonkey. I'm flattered someone made use of something I have started. Maybe i can help you with that.I see you used my code for loading files(from 1st version). Yes, it is very slow specially when loading thousands :"> . I had a major rewrite of my code(r4r). I changed much of the loading functions for speed.( Load directories,files and Playlist - got so addicted with regular expressions and stuff, I have more than 5 methods of loading playlists. ) I have a new playlist format designed for speed. More than 3000 files can now be loaded in less than 3secs from my playlist including data from tags! But still, loading from directories, and .pls, .m3u playlist takes a while but at least 2 faster than the previous. I'll be posting a new version when my new skin is complete. I just wish i can find more free time.
-
You're welcome! ...because comments like that are uncalled-for. After all, we all started out as noobs. How else?
-
Here's a quick example: #include <GUIConstants.au3> #include <Sound.au3> #include <Date.au3> Const $FileLocation ="D:\mp3\10.000 days5 the pot.mp3" Dim $var, $hour, $min, $sec $Form1 = GUICreate("Test", 324, 113, 324, 440, -1, BitOR($WS_EX_APPWINDOW, $WS_EX_WINDOWEDGE)) $PosSlider = GUICtrlCreateSlider(16, 55, 300, 20) GUISetState(@SW_SHOW) _SoundOpen($FileLocation, "FileHandle") $TotalMilliSeconds = _SoundLength("FileHandle", 2) _SoundPlay("FileHandle") While 1 Sleep(10) $ci = GUIGetCursorInfo($Form1) If $ci[2] = 1 And $ci[4] = $PosSlider Then;user presses on the slider _TicksToTime(GUICtrlRead($PosSlider) / 100 * $TotalMilliSeconds, $hour, $min, $sec) ToolTip($hour & ":" & $min & ":" & $sec) $var = 1 ContinueLoop EndIf If $var = 1 And $ci[2] = 0 Then;only seek after user releases the slider _SoundSeek("FileHandle", $hour, $min, $sec) _SoundPlay("FileHandle") ToolTip('') $var = 0 EndIf $Pos = _SoundPos("FileHandle", 2) GUICtrlSetData($PosSlider, $Pos / $TotalMilliSeconds * 100); move the slider as the song progresses If $Pos = $TotalMilliSeconds Then _SoundClose("FileHandle") If GUIGetMsg() = $GUI_EVENT_CLOSE Then _SoundClose("FileHandle") Exit EndIf WEnd I hope that helps! note: you don't need "Sound_Addendum.au3" anymore. You can also use AdlibEnable in place of the While - Wend loop. That way, the script uses less memory and CPU.
-
Like this one? It's going with the next version. This is how I did it. Well not exactly, but kinda like this: #include <GuiConstants.au3> $posL = 50 $posT = 70 $gui = GUICreate("Test",200,100) $bar = GUICtrlCreatePic(@ScriptDir&"\bar.gif",$posL,$posT,0,0) $ball = GUICtrlCreatePic(@ScriptDir&"\ball.gif",$posL,$posT,0,0) GUISetState() $oShell = ObjCreate("shell.application") $oDir = $oShell.NameSpace (@ScriptDir) $oFile = $oDir.Parsename ("bar.gif") $sW = StringReplace($oDir.GetDetailsOf ($oFile, 27), " pixels", "") Do $msg = GUIGetMsg() $CI = GUIGetCursorInfo($gui) If $CI[2] = 1 And $CI[4] = $bar Then ToolTip(Round(($CI[0]-$posL)/$sW*100)); "bar.gif" width = 90 GUICtrlSetPos($ball,$CI[0],$posT) EndIf Until $msg = $GUI_EVENT_CLOSE ball: bar:
-
Thank you... Haven't noticed the post until now. It's been long since I last visited the forum. Anyway here's an update. See my first post.
-
RazerM, This is cool! Thanks you for this. This exactly what i want. Why don't you make a UDF with something like this. It might be useful for someone. It is for me.
-
I like it.
-
Yes, the search function is poor specially if you load lots of songs, say a thousand I'm making a new way wherein when you search for a song, say "paul", it will display a new separate window displaying all song titles containing "paul". Then you choose which "paul" you want.
-
Errrm, I am not using _Sound UDF to open videos and I never said so. And it's not in my initial plan to add video playback functionality to this player because it's not designed for it. However, If I can get video playback to use a window that i created then maybe i will add support for it. Anyway thank you for the tip.
-
Thank you RazerM. A lot of addition is in the works right now. Just one question: How do you create a window such that it will replace the default display window created during the "open" operation in video playback? Thank you for the _Sound UDFs.
-
Thanks! Maybe I should change the title as this is really not my fist script but rather my first contribution (or 1st posted script?). My first script was that "hello world" MsgBox 2 months ago. I can still remember my excitement when i first saw it work.
-
Thanks for testing. I think that with mci you can play just any format that windows supports. Unfortunately, I don't have that many sample files. I have only tried .wmv and .asf. and it works fine. I'm now trying to create a window in place of the default display window so that it will be skinned as well. Thank you for all the help smashly.
-
Thanks for the tip. I'll try to add support to whatever file windows multimedia can play. Yay!, next update is going to be a fairly big one. I'm nearly finished with the script but right now I'm busy with Photoshop. I didn't expect it could be this fun.
-
Thanks again smashly.. It's nice to know I'm not the only one enjoying this little script. This function "WM_DROPFILES_FUNC" is very nice. Where can I get more info about those dll calls? I ought to learn about those calls too. I can be a clever coder but my knowledge in these fields is very limited; limited to what's on the Autoit Help in fact. Keep it coming, I'm actually learning autoit faster this way.
-
Cool. Thanks smashly. you're very helpful. That is definitely going with my next version.
-
No, it's not programmed in the code and I think it's not part of Sound.au3. But how long are those silences? If they're only a small fraction of a second long then it's understandable. It's just the script doing it's job. If you're noticing very long silences, then it's not a "silence between tracks". It's the silence at the end or at the beginning of your audio file. I use Audacity to trim those silences off my mp3's. cheers!
-
Thanks, I couldn't have noticed that soon. What utility do you use to check for syntax errors? I wonder why those minors errors are not reported on my machine. Thanks for the tip smashly. That will be useful on my other scripts. But on this one, it will just shoot CPU usage to about 30 percent and render my scrolling text unreadable. Anyway, i don't change my volume that often. I just leave it at 100%. Maybe there's some other way I could integrate that on my script.. But right now i'm busy on other things.(i'm making a skinning logic for this player)