Silverfrost Forums

Welcome to our forums

Triggering another software

26 Nov 2010 12:51 #7163

Maybe this question sounds a bit strange, but .....I have microscope with a software that is very basic: for taking a picture one has to press Enter every time. Now I want to take a large series of pictures every 10 minutes and I cannot stay the whole day in front of it just for pressing 'Enter' every 10 (or 30) min....So I wonder if with the facilities of FTN95 it would be possible to send an 'Enter' to the microscope program with a simple routine....I see there are subroutines such as CISSUE@, but I have no idea how to use them or, before starting any try with Fortran, if FTN95 could do what I need.... Any suggestion or program example will be very very appreciated.....

Agustin

4 Dec 2010 10:12 #7203

The first question would be what kind of data input terminal do you have on your microscope?

7 Dec 2010 4:07 #7211

I do not know if I fully understand what you mean. What I have is a capture program that controls the camera. I have to press Alt+C to open the 'Camera' menu and then click press 'A' to select the 'Auto Capture' item and take the picture.

Agustin

8 Dec 2010 11:54 #7212

OK so you want to write an application that emmulates a key stroke event in another application.

If the other application is a Windows application then in theory you can use FindWindow to find its Windows HWND and then use PostMessage to send a keystroke event. Both these functions are in the Windows API and are available from FTN95 but when using FindWindow you may find that the interface in win32api.ins is not suitable (usually one of the arguments is NULL and you will need to send this as a VAL rather than a REF or alternatively pass LOC(0)).

8 Dec 2010 8:19 #7213

Thanks for your answer: it is indeed what I need. Where could I find a short example about the use of these windows api with FTN95? (I know just Fortran language, ..sorry).

Agustin

9 Dec 2010 1:12 #7216

The following program puts the letter 'a' into the edit window of an instance of Notepad that is running concurrently...

WINAPP
STDCALL FINDWINDOW 'FindWindowA' (STRING,VAL):INTEGER*4
STDCALL POSTMESSAGE 'PostMessageA' (VAL,VAL,VAL,VAL):LOGICAL*4
STDCALL GETWINDOW 'GetWindow' (VAL,VAL):INTEGER*4
integer hwnd
logical ret
integer,parameter::WM_KEYDOWN=Z'0100'
integer,parameter::GW_CHILD=5
hwnd = FindWindow('Notepad',0)
hwnd = GetWindow(hwnd, GW_CHILD)
if(hwnd /= 0) ret = PostMessage(hwnd,WM_KEYDOWN, 65, 0)
end  

'Notepad' is the classname of the application. 65 is the virtual key for the letter 'a'. The edit window is the first child of the main window for Notepad. The Spy tool in Plato can provide some information but in the end I used the Microsoft Spy tool to get the details.

9 Dec 2010 9:01 #7217

Thanks Paul for your example. As an exercise I tried to run it on Wordpad (according to Spy, the classname of Wordpad is 'WordPadClass') and nothing happened. Maybe the classname is not the only parameter that one has to change in FindWindow?. On the other hand, let's say that instead of inserting 'a' in Notepad (your example) I want to print what is already written in Notepad, i.e., I have to send Alt+A to open the File Menu and then Ctrl+P to print the content of the window.

Agustin

Please login to reply.