I have been asked to figure out a way to turn off a running application on a host computer when i certain flash application is running in the browser, a seemingly difficult task but i have thought of a few possible ways to achieve this and i would like to ask which approach would be the best.
The way i see it these are my possibilities
Have the flash application create a cookie which another program checks for and if detected, this program running on the computer will then turn off the other application.
Have a program running on the host computer listening on a specific port and when the proper string is sent fx. through the use of actionscript sockets, the program will turn off the application temporarily.
Create a program sniffing network traffic and if the swf in question is being downloaded, turn off the other application temporarily (This seems to me to be the least viable approach, not even sure it would be possible to do effectively)
The reason i need to do this, is because the flash application will need to access the webcamera of the host computer, which doubles as a motion detecting camera which means the camera will be locked while the motion detection software is running. So i need to turn off the motion detection software, grab a picture in flash, save the picture and start up the motion detection again.
Am i missing some super simple approach? how would you achieve this? Thanks in advance for your answers.
TBH I don't think you'll succeed in this, unless you create it as an Air app (granted, I didn't spend too much brain power on thinking up solutions). The flash player is very restricting on what you can and cannot do. ExternalInterface is the replacement of FSCommand, which is considered obsolete, BTW. It allows you to communicate from AS with the swf container. JS (and maybe VBScript?) only though.
However, if it turns out you need to create an Air app, you can use NativeProcess which allows you to run an application on the host. For instance, if you'd want to run a java .jar you could do this:
var javaExecutable : File = new File();
javaExecutable.nativePath = '/path/to/java/';
var processArguments : Vector.<String> = Vector.<String>([
'-jar',
'/path/to/jar/',
'foo'
]);
var process : NativeProcessStartupInfo = new NativeProcessStartupInfo();
process.executable = javaExecutable;
process.arguments = processArguments;
var shell : NativeProcess = new NativeProcess();
shell.addEventListener(NativeProcessExitEvent.EXIT, onExitEvent);
shell.addEventListener(ProgressEvent.STANDARD_OUTPUT_DATA, onStdOutputDataEvent);
shell.start(process);
Very important to note: (emphasis mine)
The NativeProcess class and its capabilities are only available to AIR applications installed with a native installer (extended desktop profile applications).
You can also use the fscommand() function to pass messages to Director
or to Visual Basic, Visual C++, and other programs that can host
ActiveX controls.
in FSCommand
Related
I have created a Flex Desktop Application with Adobe Air.
I need to protect the application from being captured. By changing the window display affinity of the application, the application can be protected from being captured.
How to use win API in flex?
Is there any other way to protect the window from being captured?
First you have to make sure that the main window does not have the WS_EX_LAYERED Windows style. That style makes SetWindowDisplayAffinity fails with code 8 (ERROR_NOT_ENOUGH_MEMORY), at least on my machine (Seven Pro 64 bits). In your -app.xml file, set the value to false for the node <transparent> under <initialWindow>.
Second, you have to choose how to inject a regular C DLL in the application process, as the API will fail with error 5 (ERROR_ACCESS_DENIED) if you try to change the affinity of a window not living in the caller process.
One possible injection method is using the SetWindowsHookEx API. Google will give you many hits about that one. Feel free to ask for some details. You obviously needs cooperation of another process, here (and some Win32 APIs practice).
Another possible way is coding an 'ACTIONSCRIPT® Extensions for ADOBE® AIR®' (PDF).
The later seems preferable:
No collaboration from an external process needed.
Adobe AIR does the DLL loading for you.
C/C++ code much more simple.
I used the first technique, as I am more fluent in raw Win32 APIs about DLL, than I am with AIR and Action Script...
I successfully tested that first technique with a very simple "Hello World" AIR Desktop application, and get a nice "All Black" image after Print Screen.
I'm relatively new to flash, air and AS3 so I'm sorry if this comes of as a beginners question. I have made an application in AIR to run on windows and communicate with my atmega8 chip through serial communication via serproxy.
Now I want to port that application to android to perform the same basic functions but communicate to the atmega8 via bluetooth. So I created a new Air for android file in Flash CS6 copied my code from my previous application excluding the communication through sockets part and created an apk which ran on an android phone:). It did everything except the communication as expected.
Now I have been trying to implement the as3breeze.com/bluetooth-ane and use it to communicate but I'm not too sure how to go about the whole thing. I have imported the ane through actionscript settings and have implemented the classes but when I try to test I get this error.
The content cannot be loaded because there was a problem loading an extension: Error: Extension namespace is invalid for C:\Users\AppData\Local\Temp\Tmp_ANE_File_Unzipped_Packages\AndroidBluetooth.ane
So after some searching I found posts talking about as3 sdk and flash builder. Do I really need all these things or can I make my bluetooth app work some how with just flash cs6? Also what exactly does my error mean and how can I solve it. Thanks in advance for any help. I have been searching so a solution to this for days and I either get an explanation that does not work or I lack the knowledge to understand.
The path that can't be accessed makes me believe you haven't extracted the ANE (basically you're trying to access a temporary directory). Try extracting the ANE file to somewhere, like My Documents or wherever your flash project is, and include (in the actionscript settings) that path instead.
Hope it helps.
I have an AIR application, which must somehow interact with C# application on desktop, ( it must generally receive data which C# application extracted from MSSQL database ).
Is it possible this interaction and how ?
lots of ways. the most simple is to connect a tcpip connection, and communicate the data via localhost. this way you'll later be able to move the app.
public function connectToServer(ip:String="127.0.0.1", port:Number=65045):void {
trace("connect")
theSocket=new Socket(ip, port);
theSocket.connect(ip,port);
theSocket.addEventListener(IOErrorEvent.IO_ERROR, ioerrorEvent)
theSocket.addEventListener(ProgressEvent.SOCKET_DATA,Getdata);
theSocket.timeout=10*60*60*1000 //10 minutes
}
i suppose you'll know the c# side.
also you can make a file what both apps will read/write, you can use extensions, so one app will be contained by the other, etc..
You could bake in some native code libraries into your AIR app to talk to the other app or even better, take the functionality of that C# app merge it as native code into your AIR app so you can talk to MySQL directly. Good Luck!
http://help.adobe.com/en_US/air/build/WS597e5dadb9cc1e0253f7d2fc1311b491071-8000.html
I need to create a custom communication between server and flash client. For example I want to write UDP protocol using error correction. It is much faster than TCP and does not suffer from routing problem. Unfortunately I absolutely cannot think of how to replace the existing way:
_stream = new NetStream(_connection);
_video.attachNetStream(_stream);
This encloses all communication and I do not have a control over it. I understand that I can use appendBytes, but not sure what exactly to pass to this function. I can do anything on the server side. My video is H.264 and audio is ACC.
Unless it's a AIR application, you can't. It's native API which already handling application layer (OSI model).
If you want make your own, using flash.net.DatagramSocket class (available in AIR 2+) for your application layer and NetStream.appendBytes for audio/video stream decoding & playback (feeded with FLV/F4V chunks)
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/DatagramSocket.html
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/NetStream.html#appendBytes%28%29
I was betting on UDP, but never got it working in Flash. I'll explain it:
In your browser, there is really no way to make usage of UDP!!! Flash applications there run in a sandbox, which only talk TCP!
Air is used for desktop applications, which after compilation run in a desktop wrapper, which itself has direct access to the socket and other possibilities.
That's it! You have to use TCP.
I have been given the task of creating an Autorun installer for a distributable CD, and thought I would challenge the task with Flash. In previous versions of flash it was possible to use fscommand and trickery to run other local exe files, but due to virus creators and what-not, this has been reworked and totally destroyed for others to use.
So as a Flash developer I have hit a bit of a brick wall with this, and am asking out for any alternative ideas anybody may have? I am quite open with learning new languages/programs, and would like any expert advice from people in the know.
Just as a heads up for what features are required:
GUI with simple graphics/buttons
Ability to launch external exe/pdf files
must be able to be compiled to an exe, which can be launched by any windows machine without installing third party software eg Java.
The only simple solution I have thought of is making an html page, but using a browser is something I want to avoid doing!
Please Help :)
Christian
You can continue using flash freely if you want. There is a bunch of projector tools like northcode swf studion, Zink, mProjector and others. You can also create your own tool using any system programing language that produces windows executable - the only thing you will need - is to create an ActiveX instance of Flash Player and set up minimalistic API to allow Flash call required system functions.