sending keys to a Java application's textbox from C# - c#

I am trying to make an automation application that basically send some keys to a textbox in a java application and, if possible, based on the text that is in the textbox. Also I would like to select a certain option for a combobox. Can someone direct me to the right path? some code, an example, anything...
thank you,
denis

hello i think you're looking something like this
"winApiHelper" is a class made by me that help me to implement Win Api's methods, take a look here http://msdn.microsoft.com/en-us/library/ms633539(v=vs.85).aspx
private void SendKeys()
//String sText , String sWindow
//alternate you can have a parameters
{
string stab = "{TAB}";
string skey = rtFilename.Text.Trim();
int iHandle = winApiHelper.FindWindow(null, cboWindows.Text.Trim());
winApiHelper.SetForegroundWindow(iHandle);
System.Windows.Forms.SendKeys.Send(skey.Trim() + stab.ToString().Trim());
}

First, java.awt.Robot allows you to emulate keyboard and mouse events. Unfortunately it works in absolute screen coordinates. Right now java does not have API that allows to access windows beyond current application.
But if you can find the absolute location of text box where you wish to write "hello, world" you can do it using Robot.
If you cannot get absolute coordinates you have to use other tools like JNI or JNA. Please see the following post for details: Windows: how to get a list of all visible windows?
Good luck1

Related

Cannot get insides of the element from other app

I want to find specific button with text(find it by text) and press it.
I'm trying to get insides from 'group'('группа' on screanshot) element of a teleramm desctop app, i know there is defenetly list of buttons there, but i cant find anything with UIA and inspect.exe. I tried both raw automtaion dll and nuget UIAComWrapper.
SendMessage(to get text) and EnumChildWindows didn't help me as well, as SendMessage enum does not return other handles inside of app.
AutomationElementCollection automation_element_collection = group_element.FindAll(TreeScope.Children, Condition.TrueCondition); //empty collection
AutomationElement automation_element_collection = group_element.FindFirst(TreeScope.Children, Condition.TrueCondition); //returns null
TreeWalker raw_view_walker = TreeWalker.RawViewWalker;
AutomationElement automation_element = raw_view_walker.GetFirstChild(group_element); //returns null
What am i doing wrong and may there be any other projects to help me with this?
screanshot from inspector.exe
Telegram Desktop app just doesn't support accessibility features like UIA for ages, look at the Github ticket. Formally, it works, but on a really basic level - there is no option to retrieve the message history textual content, group and contact names, etc.
So, until any of those implemented, there is just no way to programmatically traverse the UI elements. But if you really need it, you could look at OCR.

How can I run built-in Revit commands from C#

I am wanting to know if there is a methodology to feed calculated values to a built-in Revit command from inside a C# program, and then possibly (based on results, such as whether this makes an element too short or too long for a known "maximum span" of a particular beam) continue with my C# program and change the beam size). I am told you can invoke the Revit built-in command after execution of your c# external command, but you cannot then return to the c# program
As another example, I want to select an element to trim/extend to, and have the code figure out which "Joist" beams to extend to this element. My program would do extended filtering (such as "Reference Level", or "Workset", or "Comments", or "Mark" parameters (etc.)) and then run the built in function, providing the element to extend to and then each of my beams.
I've tried internet searches, as well as the Revit SDK samples, and nothing obviously used this (but there are a lot of csproj's to look through).
Can anyone verify that you cannot go back and forth between the C# program and the Revit built-in command?
You can programmatically invoke a built in Revit command with the UIApplication.PostCommand() method. Refer to documentation and building coder for more information. It will not execute until after the API context is over, however.
I don't think you'll be able to feed arguments into the command however, short of some kind of Win32 hack. Perhaps you will need to recreate the functionality of the built in command within the Revit API.
Unfortunately, I don't think we can do (command "_line" pnt1 pnt2) type of thing here.
Perhaps start with the SDK sample "MoveLinear". It shows how to modify end points of linear elements (which includes beams).
The main part of the sample's code is
Autodesk.Revit.DB.Line line;
//get start point via "get_EndPoint(0)"
Autodesk.Revit.DB.XYZ newStart = new XYZ(
lineLoc.Curve.GetEndPoint(0).X + 100,
lineLoc.Curve.GetEndPoint(0).Y,
lineLoc.Curve.GetEndPoint(0).Z);
//get end point via "get_EndPoint(1)"
Autodesk.Revit.DB.XYZ newEnd = new XYZ(
lineLoc.Curve.GetEndPoint(1).X,
lineLoc.Curve.GetEndPoint(1).Y + 100,
lineLoc.Curve.GetEndPoint(1).Z);
//get a new line and use it to move current element
//with property "Autodesk.Revit.DB.LocationCurve.Curve"
line = Line.CreateBound(newStart, newEnd);
lineLoc.Curve = line;
Which moves the X of the first point and the Y of the second point 100 feet.
you can try:
RevitCommandId commandId = RevitCommandId.LookupPostableCommandId(PostableCommand.PlaceAComponent);
commandData.Application.PostCommand(commandId);

How to set the start position for a video using AxShockwaveFlash (revised)

Revised question with added detail...
I'm trying to use AxShockwaveFlash to play a youtube video and start it at a specific location. This is within a C# winforms app. I have the basics. I can successfully start and stop the video. I cannot, however, figure out how to set the position and start at a specific time within the video. What property or method needs to be called to do this?
Here's what I have so far:
AxShockwaveFlashObjects.AxShockwaveFlash mFlashPlayer;
...
mFlashPlayer.Movie = #"http://www.youtube.com/v/9O9HfafzBPE?version=3&hl=ru_RU";
mFlashPlayer.Play();
I've tried setting various properties and calling various methods, but I'm just guessing. For example, I tried calling
mFlashPlayer.GotoFrame(200);
and it did nothing. Seems so simple, I'm starting to wonder if I'm encountering a bug. ?
I also tried using the standard form when using a web browser, which is to encode it directly in the url. For example, the following did not work either:
mFlashPlayer.Movie = #"http ...blah... #t=77s";
mFlashPlayer.Play();
Thanks in advance for any suggestions.
ANSWER
Apparently, I'm not authorized to post an answer, so I'm editing the question and adding it here...
Got it! The magic trick is to set the 'start' parameter in the url that you provide to the Movie property or the LoadMovie() method.
Embedded AS3 player:
http://www.youtube.com/v/VIDEO_ID?version=3&start=NUMBER_SECONDS
Chromeless AS3 player:
http://www.youtube.com/apiplayer?video_id=VIDEO_ID&version=3&start=NUMBER_SECONDS
Replace VIDEO_ID and NUMBER_SECONDS with the desired values.
Example:
mFlashPlayer.Movie = #"http://www.youtube.com/v/1ZKz2KW87Y4?version=3&start=100";
I found the required info here:
https://developers.google.com/youtube/player_parameters
That was one of the more frustrating hunts for info that I've been on in a while. Hope this post saves other folks the headaches.

save Website Content & access it

I'm starting with C# again after 3 years (have average experience with object orientated languages; here I'm mainly missing function names). I'm not too sure it's possible in c#, so if you can recommend another language I will try to look there.
My Question(s):
On program start (or button) I want to extract a part of a Website and save it (temporary of file don't matter). That way I wont need to buffer/load (loadtime) anything again and can access the content if I go offline afterward.
I want to extract some numbers out of the content and do simple math with them.
Would be great to know if its possible and how. I'm happy if you can tell me the main functions I should look into. Some basic code would be great too if its not too much to ask.
If you want to have access to the information even if your program closes/restarts then you will need to export the source code to a file as follows:
using (WebClient wb = new WebClient())
{
string source = wb.DownloadString("http://example.com");
File.WriteAllText("c:\\exampleFile.txt", source);
}
Otherwise you can remove the File.WriteAllText("c:\\exampleFile.txt", source); and simply parse the parts you want from the source and do your calculations.
Keep in mind this will download the source code of the url as 'it is' that means you will need to do some parsing of the text in order to get the information you want out of it.
May be you are looking for this:
var contents = new System.Net.WebClient().DownloadString(url);

how to show locations in a Google map

I have a database and every person has a location.
In this point, l need some sugesstions to show all the person's location in a single map.
To give an example,
X man = at y, X1 man = at z,X2 man = at q
y,z,q will be shown in a singe map?
start by reading this article:
Show Your Data on Google Map using C# and JavaScript
if you have more specific questions ask more details
i think it will helps you
The Google Maps API is accessed via JavaScript (any server controls are just abstracting this away from you). In the case you described, you would need to dynamically output the required JavaScript to tell the maps API what to display.
See http://dotnet.sys-con.com/node/171162

Categories