NexusFi: Find Your Edge


Home Menu

 





Sending a keyboard Command from a NinjaTrader Script


Discussion in NinjaTrader

Updated
    1. trending_up 2,609 views
    2. thumb_up 1 thanks given
    3. group 2 followers
    1. forum 2 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
ECI Ed
Seminole, FL
 
Posts: 17 since Oct 2011
Thanks Given: 9
Thanks Received: 3

Would it be possible to send a keyboard command such as <PrintScreen> to the computer from within NinkaTrader script? Specifically, I'd like to save a copy of my charts at a trigger point using the Hot key in SnagIt. If so, can you please explain how and maybe provide some sample code?

There is another post on Big Mike's forum that suggests using:

SendKeys.Send("{PrintScreen}");

but when I tried this I got an error message on compile of:

The name 'SendKeys' does not exist in the current context.

Thanks


Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Fed Hike Odds at 57% After Warsh: England Surges 12.9%, …
Prediction Markets & Event Contracts
Datafeed for Atas
Platforms and Indicators
Daytrading to swingtrading
Traders Hideout
Netherlands & Germany Surge as World Cup Field Narro …
Prediction Markets & Event Contracts
Czechia Live at 52.5% as England Rides 4-2 Wave to Co-Fa …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Want your NinjaTrader indicator created, free?
5 thanks
Afternoon-close session
1 thanks
Franks Trading Journey
1 thanks
Denied 20K payouts: Alpha Futures
1 thanks
FootPrintV2 Chart for NT8
1 thanks
  #2 (permalink)
 
grankus's Avatar
 grankus 
Barcelona
 
Experience: Beginner
Platform: NinjaTrader 7
Trading: CL, TF
Posts: 8 since Aug 2012
Thanks Given: 5
Thanks Received: 0


Quoting 
...The name 'SendKeys' does not exist in the current context...

Did you finally find the solution?


Reply With Quote
  #3 (permalink)
 
devdas's Avatar
 devdas 
Al,India
 Vendor: www.edevaay.com 
 
Experience: Advanced
Platform: NinjaTrader
Broker: Z
Trading: NiftyFuture
Posts: 1,564 since Feb 2010
Thanks Given: 1,514
Thanks Received: 1,703



ECI Ed View Post
....... Specifically, I'd like to save a copy of my charts at a trigger point using the Hot key in SnagIt. If so, can you please explain how and maybe provide some sample code?

There is another post on Big Mike's forum that suggests using:

SendKeys.Send("{PrintScreen}");

but when I tried this I got an error message on compile of:

The name 'SendKeys' does not exist in the current context.

Thanks

SendKeys.Send will work with a listener , here it should be SnagIt.

You have to send keys to SnagIt from NT.

For that perhaps i only know some dirty methods of Dll import like this,

 
Code
using System.Threading;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using System.Collections.Generic;
using System.Text;
using System.Linq;

[DllImport("user32.dll",EntryPoint = "FindWindow")]
private static extern IntPtr FindWindow(string lp1,string lp2);

[DllImport("user32.dll", CharSet=CharSet.Auto, ExactSpelling = true)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool SetForegroundWindow(IntPtr hWnd);


private void trigger_function()
		{
			IntPtr handle = FindWindow(null, "SnagIt");      // handle for SnagIt
			 
				if(!handle.Equals(IntPtr.Zero))
				{
					if(SetForegroundWindow(handle))
					{
						
						SendKeys.SendWait("Key combo for print in SnagIt");
						
						SendKeys.Flush();
					}
					else Print("Failed In");
					
				}
				else Print("Failed Out"+handle.ToString());
				
		}
I have exampled above code snap from my own different key thrower script, you have to take care of key combos
that are accepted in SnagIt.

OTOH, just for saving your chart, there are other esay way you can use, just look some tools from @vvhg


Harvest The Moon
Nest The Market
Follow me on X Visit my NexusFi Trade Journal Reply With Quote
Thanked by:




Last Updated on November 4, 2014


© 2026 NexusFi®, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Downloads - Top
no new posts