View previous topic :: View next topic |
Author |
Message |
aebolzan
Joined: 06 Jul 2007 Posts: 229 Location: La Plata, Argentina
|
Posted: Fri Nov 26, 2010 1:51 pm Post subject: Triggering another software |
|
|
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 |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7926 Location: Salford, UK
|
Posted: Sat Dec 04, 2010 11:12 am Post subject: |
|
|
The first question would be what kind of data input terminal do you have on your microscope? |
|
Back to top |
|
|
aebolzan
Joined: 06 Jul 2007 Posts: 229 Location: La Plata, Argentina
|
Posted: Tue Dec 07, 2010 5:07 pm Post subject: |
|
|
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 |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7926 Location: Salford, UK
|
Posted: Wed Dec 08, 2010 12:54 pm Post subject: |
|
|
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)). |
|
Back to top |
|
|
aebolzan
Joined: 06 Jul 2007 Posts: 229 Location: La Plata, Argentina
|
Posted: Wed Dec 08, 2010 9:19 pm Post subject: |
|
|
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 |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7926 Location: Salford, UK
|
Posted: Thu Dec 09, 2010 2:12 pm Post subject: |
|
|
The following program puts the letter 'a' into the edit window of an instance of Notepad that is running concurrently...
Code: | 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. |
|
Back to top |
|
|
aebolzan
Joined: 06 Jul 2007 Posts: 229 Location: La Plata, Argentina
|
Posted: Thu Dec 09, 2010 10:01 pm Post subject: |
|
|
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 |
|
Back to top |
|
|
|