Reflections for ReGIS graphics screen scraping in C# .NET API - c#

I'm trying to create a windows forms application that can scrub screen information from a Reflections window. The problem is that it's an older version of reflections from back when WRQ still owned the app. Since Attachmate have taken it over, I can't find any documentation on the .net API related to this older version.
What I have so far is this:
private void button1_Click(object sender, EventArgs e)
{
openApp();
}
private void openApp()
{
// Create a new instance of Reflection.
Reflection4.Session reflection = new Reflection4.Session();
reflection.Visible = true;
}
So this is fine for opening a new Reflections window, but I want it to run the screen scrape on a window that is already open.

Below is a way to get the first active Reflection4.Session using Marshal.GetActiveObject(). I found the progid for Reflection4 using the ProgID Key website on MSDN. With that I found that the following code works:
Reflection4.Session session = (Marshal.GetActiveObject("Reflection4.Session.8") as Reflection4.Session);

Related

Can't connect a midi output device to .net MAUI using DryWetMidi

I am using the library DryWetMIDI for .net 7 and I am trying to connect a MIDI output device to MAUI. When I connect a input device it seems to work fine but the only output from the outputdevice I could get was the following error: Internal error (OUT_SENDSHORTRESULT_INVALIDHANDLE). When I tried everything in a simple console application it works perfectly.
Also because of my lack in experience in Maui I don’t really know if I should change something in the project dependencies or in the builder. Or maybe declare the MIDI in the App or the Appshell...
So I tried to create a input device and a output device and connect them to eachother (This is what the DryWetMIDI suggested). Next I try to get the events from the input and the outup device, the input device works but the output device doesnt.
I use the following code where the ouput device doesnt work in Maui:
private InputDevice inputDevice;
private OutputDevice outputDevice;
private DevicesConnector devicesConnector;
void ConnectMidi()
{
//create input device
inputDevice = InputDevice.GetByName("Keystation Mini 32");
inputDevice.EventReceived += OnEventReceived;
//create ouput device;
outputDevice = OutputDevice.GetByName("Microsoft GS Wavetable Synth");
outputDevice.EventSent += OnEventSent;
//connect them
devicesConnector = inputDevice.Connect(outputDevice);
inputDevice.StartEventsListening();
}
public void OnEventReceived(object sender, MidiEventReceivedEventArgs e)
{
var midiDevice = (MidiDevice)sender;
Debug.WriteLine("This gets called when a key is pressed") ;
}
public void OnEventSent(object sender, MidiEventReceivedEventArgs e)
{
var midiDevice = (MidiDevice)sender;
Debug.WriteLine("This gets never called");
}
If there is anohter solution using a diffrent library or something else I would love to hear it!
Hopefully this makes my problem clear and thanks in advance.
(This is also my first post so feedback would also be nice)
I'm the author of the DryWetMIDI. I've analyzed the problem:
The bug is not with the library, it's a MAUI related one.
The error comes from midiOutOpen system Windows function which fails for Microsoft GS Wavetable Synth in a MAUI project but works for any other project types.
I've reported the bug in MAUI repo: https://github.com/dotnet/maui/issues/12368. So what we have is to wait for response from Microsoft.
Update:
The bug has been moved to WinUI repo: https://github.com/microsoft/microsoft-ui-xaml/issues/8055. Also you can mark your project as Unpackaged and the issue should go away.

DevExpress Map Control not Loading - Windows Service

I am using the DevExpress XtraMap MapControl within a windows service with the intention of generating the maps, saving them as images and adding them to reports. I have this setup working well when using it through a WinForms project, but when I copy the same code to a Windows Service it fails to save the image. Code in the WinForms project:
MapControl map;
public void Form1_Load_1(object sender, EventArgs e)
{
// Create a map control.
map = new MapControl();
// Create an image tiles layer and add it to the map.
ImageTilesLayer tilesLayer = new ImageTilesLayer();
tilesLayer.DataLoaded += Map_DataLoaded;
map.Layers.Add(tilesLayer);
BingMapDataProvider prov = new BingMapDataProvider();
prov.BingKey = "MY_BING_KEY";
tilesLayer.DataProvider = prov;
map.ZoomLevel = 2;
map.CenterPoint = new GeoPoint(38, -100);
map.ResumeRender();
this.Controls.Add(map);
}
private void Map_DataLoaded(object sender, EventArgs e)
{
var loc = #"C:\0Temp\Map\" + DateTime.Now.Ticks.ToString() + ".png";
map.ExportToImage(loc, System.Drawing.Imaging.ImageFormat.Png);
}
This code when run in a Windows service fails to save the image. The only difference being, in the Windows Service, the following line is removed:
this.Controls.Add(map);
When removing that line from the winforms project, it also fails to load/save. I can only assume that there is an event being triggered/monitored that adding this control to a form triggers that I am not aware of?
I believe, the Map Control is not intended to be used without showing it (or at least without creating it's handle). So when accessing to Bing Maps from Windows-service, I suggest you to use the Bing Imagery API directly.
p.s. Microsoft Bing Maps Terms of Use do not allow to
3.2 (b) Copy, store, archive, or create a database of the Content ...

Trying to get Geolocation on a map element in windows phone 8 using emulator

I couldnt find an answer to this question anywhere so I thought id ask here. Basically Iam following along with channel 9's tutorial on windows 8 phone for absolute beginners. Trying to follow along with the 'Around me' app tutorials. I create a Map element in the xaml. I create a geolocator object and attempt to set the view on my map to my current geocordinates. This doesnt work, the map view seems to show the location of microsofts headquarters in Redmond Washington each time I run the app. not Ireland, where it should be pointing? Below is my code which is all contained in the mainpage.xaml.cs
public MainPage()
{
InitializeComponent();
Loaded += MainPage_Loaded;
}
public async void MainPage_Loaded(object sender, RoutedEventArgs e)
{
Geolocator geolocator = new Geolocator();
geolocator.DesiredAccuracyInMeters = 50;
Geoposition position = await geolocator.GetGeopositionAsync(TimeSpan.FromMinutes(1), TimeSpan.FromSeconds(30));
var GeoCoorCenter = new GeoCoordinate(position.Coordinate.Latitude,position.Coordinate.Longitude);
AroundMeMap.SetView(GeoCoorCenter,17);
}
my code is the same as that used in the tutorial and it seems to work in that app. I also have the ID_CAP_LOCATION and ID_CAP_MAP set in the app manifest. Iam really not sure what the issue is here. Iam assuming its got something to do with the fact that Iam running the application in the emulator. If anyone can help me that would be great.
I've managed to run your code like this (basing on this answer and MSDN howto):
I've started the emulator, opened AdditionalTools -> Location and clicked somewhere on the Map (as my Location)
run Maps App - I see that shows the Location I've set, Close the Maps App
after that your App should point the right Location
As it's written at MSDN - it seems to be a bug which running Maps App fixes.

How to pass data from windows application to web application?

I have a windows application and i want to open my web application from this windows application. My Windows application will generate a key and machine code after authorization and will save the key and machine code in to database among active users. Now i want to send this key to browser so that my web application can identify the user with his machine.
How can i do this?
i cannot use URL because the user will be able to copy the URL and use my web application from another machine. I must restrict it.
Is there any other way?
There are Two Ways to transfer winform data to web applications
If you want to transfer the data to IE then You can Use
1)MSHtml.dll
code
InternetExplorer TargetIE = null;
IHTMLDocument2 document = null;
//Check whether the IE is opened
foreach (InternetExplorer internetExplorer in new ShellWindows())
{
if (internetExplorer.Document is HTMLDocument)
{
TargetIE = internetExplorer;
break;
}
}
2) If you want to transfer data from winform to any web browser my personal advice to you please use selenium for this.
download the respective dll and driver for respective drivers from this site help
Code
using OpenQA.Selenium;
using OpenQA.Selenium.IE;
using OpenQA.Selenium.Support.UI;
using OpenQA.Selenium.Chrome;
namespace WindowsFormsChrome
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
// download the chrome driver
IWebDriver driver = new ChromeDriver(#"C:\Users\Downloads\chromedriver");
driver.Navigate().GoToUrl("http://www.yahoo.com");
IWebElement myField = driver.FindElement(By.Id("txtUserName"));
myField.SendKeys("UserName");
IWebElement myField = driver.FindElement(By.Id("txtPassword"));
myField.SendKeys("Password");
IWebElement myField = driver.FindElement(By.Id("btnLogin"));
myField.click()
}
}
}
this second part work for all browser yoou just replace chromeDriver class as per you want.
you can POST data using c#
http://msdn.microsoft.com/en-us/library/debx8sh9(v=vs.110).aspx
see also this post in stackoverflow
How to post data to a website
You can write an ashx handler and pass your data (or some reference to your data) from your windows application. Here is an example how this can be done :
how to call ASHX handler and getting the result back

Open Office Communicator Session from C#

I am working on a WPF application and I wish to open sip:Username#company.com links. I am able to open mailto links using the following code:
private void btnSendEmail_Click(object sender, RoutedEventArgs e)
{
try
{
string mailURL = String.Format("mailto:{0}", UserDetails.EmailAddress);
Process.Start(mailURL);
Close();
}
catch
{
// Handle exception
}
}
Although, I am unable to open sip: links in a similar way. What I am trying to achieve is to open a new chat session with a user, like I am able to do when I follow sip: links from Outlook.
Any ideas?
Edit: I ended up using the CommunicatorAPI. Messenger.InstantMessage() seems to work for me. More info here: http://msdn.microsoft.com/en-us/library/bb787232.aspx
Using Process.Start works fine on my system (with Microsoft Lync 2010, a newer version of Communicator):
void Main()
{
Process.Start("sip:username#company.com");
}
Running the above code results in a new chat window opening. The only exception is when I enter my own user name, in which it starts composing a new Outlook e-mail message to myself. What happens when you use this (maybe also try omitting the following call to Close).
You probably need to associate a program with the "sip" uri scheme. Try this: how do I create my own URL protocol? (e.g. so://...)
if you have Lync or Office Communicator installed, they should respond appropriately to the sip: uri scheme. Also, tel:, callto: etc. For reference, the full list is here.
Is this not working for you from a WPF app? Does it work for you from a basic html page?
I ended up using the CommunicatorAPI. Messenger.InstantMessage() seems to work for me. More info here: http://msdn.microsoft.com/en-us/library/bb787232.aspx
The following code probably didn't work for you because you were trying to IM yourself.
Process.Start("sip:username#company.com");

Categories

Resources