1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
|
#include<iostream>
#include<Windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <fstream>
#include <time.h>
using namespace std;
// FUNCTION REFERENCES
void Prompt (bool);
void LeftClick (double, double, RECT);
RECT WindowActivate (HWND);
int main()
{
//Define Window Variables
HWND thorconsole;
RECT thorRECT;
cout<< "Welcome to the ATSA Interface" << endl << endl;
// CHOOSE CAMERA SYSTEM
char CCDsys; //Defines CCDsys variable
//OPEN PROGRAMS
cout << "Initializing ThorCam Software..." << endl; //Text appears on console
WinExec("\"C:\\Program Files\\Thorlabs\\Scientific_Imaging\\ThorCam\\ThorCam.exe\"", SW_SHOWNORMAL); //Opens and runs ThorCam Software
thorconsole = FindWindow(NULL, "ThorCam");
thorRECT = WindowActivate(thorconsole);
LeftClick(15, 30, thorRECT); //selects camera in ThorCam
return 0;
}
void Prompt (bool show) // hides the console so it won't get in the way of the other programs
{
HWND prompt = GetConsoleWindow();
if(show)
{
ShowWindow(prompt, SW_SHOWNORMAL);
SetForegroundWindow (prompt);
}
else
ShowWindow(prompt, SW_HIDE);
}
void LeftClick (double x, double y, RECT rect) //provides a left click in a certain location in a specific window
{
SetCursorPos(rect.left + x, rect.top + y);
INPUT Input = {0};
//left down
Input.type = INPUT_MOUSE;
Input.mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
::SendInput(1, &Input, sizeof(INPUT));
//left up
::ZeroMemory(&Input, sizeof(INPUT));
Input.type = INPUT_MOUSE;
Input.mi.dwFlags = MOUSEEVENTF_LEFTUP;
::SendInput(1, &Input, sizeof(INPUT));
}
RECT WindowActivate(HWND console) // Activates the window
{
RECT rect;
SetForegroundWindow(console);
GetWindowRect(console, &rect);
Sleep(100); //delaying the program for a tenth of a second so that the window has time to come to the foreground before any other action takes place
return rect;
}
|