Text to speech in Delphi - windows

I am improving a small alarm/reminder application that I build years ago, and I would like to do an hourly beep, but instead of beeping it would be much nicer it would tell time.
Is there any simple way to do this in DELPHI D2007 or later?

Check Brian Long tutorial's
Speech Synthesis & Speech Recognition Using SAPI 5.1
I wrote a text to speech software using this tutorial.
It reads the clipboard content when I press CTRL + F10

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComObj;
[...]
procedure TForm1.Button1Click(Sender: TObject);
var
Voice: Variant;
begin
Voice := CreateOLEObject('SAPI.SpVoice');
Voice.speak('Hello World');
end;

I did a video awhile back on making your applications talk in Delphi. I personally haven't ever found a use for text to speech in one of my applications, but it's a fun thing to know how to do ;-)

In my code I use MS Agent and TAgntSrvr component:
http://delphi.icm.edu.pl/ftp/d30free/agntsrvr.htm
Also you can check this link or just Google around: "text speech delphi"

You can use eSpeak with Delphi to support more languages and Mac (and hopefully Linux in the future). Delphi example is here.

Related

Is there a way to create a new IME layout?

I have a hard time finding information on how I would go about developing a keyboard layout that uses IME without it just being information on how I can simply add a new keyboard layout that uses the microsoft IME or how I can use the Microsoft IME in my applications.
What I want to do is making the whole thing from scratch. It's not supposed to be for an existing language (so it's not like any of the existing IMEs would be an alternative) but, obviously, having information on how I'd go about developing an IME for Japanese, Chinese or Korean is also a nice thing.
Google has their own IME that is cross platform so I assume that it is possible to do it but I just can't find any information on it.
Thanks
The OS is Windows 8.1, by the way.
I'm a bit late, but I don't like open questions (to which I know the answer) ;-)
Hope it still helps: Microsoft's Keyboard Layout Creator (MS KLC) is what you need. https://msdn.microsoft.com/de-de/goglobal/bb964665.aspx

How do I duplicate iTunes-style windows on Windows?

Can anyone provide some insight on how to "duplicate" an iTunes style window in Windows? Specifically I am looking for the following features:
1) rounded window
2) top and bottom toolbars
3) rounded text fields
I'm currently attempting a bit of cross-platform development with Real Studio and while I've discovered the mechanism by which to perform the rounded windows in OS X (declare method call to HIWindowSetContentBorderThickness or SetContentBorderThickness), I cannot find in the MSDN how to do similar things in Windows. Obviously Apple accomplished it in actually writing iTunes for Windows. Perhaps they wrote custom controls from the ground up.
SIDENOTE: I found this article from a few years back that briefly discusses it (http://discuss.joelonsoftware.com/default.asp?joel.3.454369.12), but this is pretty much all I could find.
Even if I can't duplicate it exactly, some direction on which Windows libraries might contain the functionality I need to do it "manually" would be nice. Any further assistance would be greatly appreciated.
There's no API for doing Apple-style rounded corners, but there are lower-level APIs for creating windows (both frame windows and controls) of any shape you want.
I don't use RealStudio, but I believe it allows you to access both .NET and native Win32 APIs, so:
If you're using .NET Windows.Forms, read Shaped Windows Forms and Controls in Visual Studio .NET. It's written for VB7, but should be easy to translate to your favorite language.
If you're using the raw Win32 API, there are at least two ways to do this. The simplest, but most limited, is to call the SetWindowRgn API, which sets the shape of your window to anything you can create as an HRGN. But that probably won't cut it for you. You don't want jagged edges; you want smooth curves, with alpha-blended borders, and maybe shadows. (At least that's what Apple does.) The Layered Windows API is the way to do this. It allows arbitrary shapes (even changing on the fly, if you use UpdateLayeredWindow—although you don't need that feature to emulate iTunes), alpha transparency, and complicated hit testing. Since the original article is very out of date, and doesn't cover all of the functionality, also see Layered Windows for the current documentation, which has links to the references.
there is a third party controls that do what you want. It works on Mac & Windows.
http://www.madebyfiga.com/fgsourcelist/
works well.
sb

Where do I find the icons / animations recommended in the Windows 7 UX guide?

The Windows 7 UX guide has nice illustrations and examples of icons, but I really can't find them in the SDK. Are they hiding somewhere, or are they not available ?
If you are talking about the common UI icons, then you are supposed to get them programmatically. For instance, you can use
var
errIcon: HICON;
begin
errIcon := LoadIcon(0, IDI_ERROR);
DrawIcon(Canvas.Handle, 10, 10, errIcon),
(Delphi code) to draw an error icon.
See LoadIcon, DrawIcon at MSDN. You might also wish to study STATIC controls.
To draw other visual elements, you need to use the visual themes API, e.g. the DrawThemeBackground function that accepts a class, part, and state and then draws it:
SHGetStockIconInfo has a decent list of system icons.

How to draw button in title bar like in Google Chrome?

I tried several components from 2000-2001, but none of them works for win7. How do I do it?
If you are looking for a way to make use of glass frame in Windows 7 using Delphi, you can follow this tutorial. There is also an update available dedicated to a 64 bit bug. You can also look at some examples by Chris Rolliston available on embarcadero developer network.
Or they probably just draw their own components like a video game would do and they emulated the windows 7 look and feel.
You could use rkSmartTabs:
Or IceTabSet:
Finally, check out the answers to these StackOverflow questions:
Google Chrome Tabs Style UI in Delphi
Resources for Windows Aero Glass and Compositing dwm
Take a look at my TChromeTabs component (http://code.google.com/p/delphi-chrome-tabs/downloads/list). As well as the Chrome Tabs implementation it includes a TForm descendant that will show you how to draw in an Aero title bar.
.NET Framework Windows Vista & 7 Features
This maybe

How to get text from the screen

There is some Win OS API call or so that would let one obtain text from the screen
not via obtaining a snapshot and then doing OCR on it, but via API
the idea is to get the text that is under the mouse that the user points to and clicks on.
This is how tools like Babylon (http://www.babylon.com) and 1-Click Answers (http://www.answers.com/main/download_answers_win.jsp) and many others work.
Can someone point me to the right direction to get this functionality?
There is no direct way to obtain text. An application could render text in a zillion different ways (Windows API being one of them), and after it's rendered - it's just a bunch of pixels.
A method you could try however is to find the window directly under the mouse and trying to get the text from them. This would work fine on most standard Windows controls (labels, textboxes, etc.) Wouldn't work on Internet browsers though.
I think the best you can do is make your application such that it supports as many different (common) controls as possible in the above described manner.
You can get the text of every window with the GetWindowText API. The mouse position can be found with the GetCursorPos API.
In Delphi you could use this function (kudos to Peter Below)
Function ChildWindowUnderCursor: HWND;
Var
hw, lasthw: HWND;
pt, clientpt: TPoint;
Begin
Result := 0;
GetCursorPos( pt );
// find top-level window under cursor
hw := WindowFromPoint( pt );
If hw = 0 Then Exit;
// look for child windows in the window recursively
// until we find no new windows
Repeat
lasthw := hw;
clientpt := Pt;
Windows.ScreenToClient( lasthw, clientpt );
// Use ChildwindowfromPoint if app needs to run on NT 3.51!
hw := ChildwindowFromPointEx( lasthw, clientpt, CWP_SKIPINVISIBLE );
Until hw = lasthw;
Result := hw;
End;
Regards,
Lieven
Windows has APIs for accessibility tools like screen-readers for the blind. (Newer versions are also used for other purposes, like UI automation and testing.) It works with many applications, even most browsers which render their own content without using the standard Windows controls. It won't work with all applications, but it can be used to figure out the text under the mouse in most cases.
The current API is called the Windows Automation API. Describing how to do this in general is beyond the scope of a Stack Overflow answer, so I've simply provided a link to the documentation.
The older API that was widely available when this question was first posted is called the Microsoft Active Accessibility API. As with the modern APIs, the scope here is too broad to detail here.
Note that documentation for both APIs is written both for both developers building accessibility tools (like screen readers) as well as for developers writing apps that want to be compatible with those accessibility tools.
The basic idea is that an accessibility tool gets COM interfaces provided by the target application's window(s), and it can use those interfaces to figure out the controls and their text and how they're related both logically and spatially. Applications that are composed of standard Windows controls are mostly automatically supported. Applications with custom UI implementations have to do work to provide these interfaces. Fortunately, the important ones, like the mainstream browsers, have done the work to support these interfaces.
i think its called the clipboard. i am going to bet these programs inject click and double click & keyboard events and then copy items there for inspection. Alternatively, they are gettin jiggy with the windows text controls, and grabbing content that way. i suspect due to security issues, these tools have problems running in vista also.

Resources