NexusFi: Find Your Edge


Home Menu

 





Sending a keyboard Command from a NinjaTrader Script


Discussion in NinjaTrader

Updated
    1. trending_up 2,458 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?
Irans Dual Probability: Guns Quiet at 99.95% While Forma …
Prediction Markets & Event Contracts
Weekend Update: First Qatari LNG Transit Attempted -- IR …
Traders Hideout
CFTC Rewrites the Rulebook -- Kalshi Cracks $1B Non-Spor …
Prediction Markets & Event Contracts
Memorandum Watch: How the 60-Day MOU Framework Makes May …
Prediction Markets & Event Contracts
Trump Lands in Beijing on CPI Day: Iran Peace Expires To …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Sober Journey With S&P
25 thanks
2026 Jlab journal
10 thanks
Lady Vols Primer: Trading Volatility Journal
8 thanks
Algo automated / semi-automated trading anyone?
6 thanks
Trying to learn Volume and price action correlation
5 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
 
Experience: Advanced
Platform: NinjaTrader
Broker: Z
Trading: NiftyFuture
Posts: 1,562 since Feb 2010
Thanks Given: 1,513
Thanks Received: 1,701



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