UCCNC argument for title

Here is where you can request new features or special features.

UCCNC argument for title

Postby Fabien » Sun Feb 09, 2020 10:15 am

Hello,
Is that possible to add a command argument to set UCCNC windows title (useful with multiple instances of UCCNC)
Fabien
 
Posts: 33
Joined: Fri Jun 21, 2019 8:04 am

Re: UCCNC argument for title

Postby dezsoe » Mon Feb 10, 2020 10:32 am

Hello Fabien,

I use this macro as a macroloop with autostart to show the version, profile name, controller type and the opened file name in the title:

title.png
title.png (3.61 KiB) Viewed 14264 times

Code: Select all
// ================================================================================================
// System Info v1.1
// ================================================================================================

string header = "UCCNC - ";
string version = AS3.Getfield(902);
string profile = AS3.Getfield(900);
string device = AS3.Getfield(907);
string filename = exec.Getgcodefilename(); // AS3.Getfield(895);

profile = profile.Replace(":", ": ");

if (filename == "-") filename = "";

header += version + " - " + profile + " - " + device + " - File: " + filename;

if (++counter == 20)
{
  counter = 0;
  if (exec.mainform.Text != header)
    exec.mainform.Text = header;
}

// ================================================================================================

#Events

// ================================================================================================

int counter = 0;

// ================================================================================================
dezsoe
 
Posts: 2049
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary

Re: UCCNC argument for title

Postby Robertspark » Mon Feb 10, 2020 10:57 am

nice macro :D
Robertspark
 
Posts: 1892
Joined: Sat Sep 03, 2016 4:27 pm

Re: UCCNC argument for title

Postby Fabien » Tue Jul 28, 2020 8:43 am

Hello dezsoe,
Sorry for my response soo late, the notification was probably lost in spams…
Do you know if i can get the actual UC100 serial number ? And more generally, do you have any document about AS3 items ?

A simple argument on command line should be also nice if dev team could add it please ;-)

Thank you.
Fabien
 
Posts: 33
Joined: Fri Jun 21, 2019 8:04 am

Re: UCCNC argument for title

Postby dezsoe » Wed Jul 29, 2020 5:28 pm

Hello Fabien,

As I wrote: that sample is a macroloop. You have to save it as e.g. M1234.txt into your Profiles\Macro_yourprofilename folder and in UCCNC you have to set it as a macroloop.

But I made an other one (don't use both together, the first macro will overwrite the title!):

Code: Select all
string[] args = Environment.GetCommandLineArgs();

if (args.Length > 0)
  for (int i = 0; i < args.Length; i++)
    if ((args[i].Trim().ToUpper() == "/TITLE") && (i < args.Length - 1))
      exec.mainform.Text = args[i + 1];

Copy these lines into your M99998.txt macro and if you set a command line switch "/title" then the next parameter will be the title of the program. If you need more than one word, then you have to "put it into quotes", see the example below:

commandline.png
commandline.png (1.26 KiB) Viewed 6823 times


title.png
title.png (989 Bytes) Viewed 6823 times
dezsoe
 
Posts: 2049
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary

Re: UCCNC argument for title

Postby Fabien » Tue Sep 08, 2020 1:18 pm

Hello dezsoe,
Thank you for your help. Do you know if i can read the dongle serial in the code ?
Based on your proposal, here is my version.
You can set Window title and position (full, half or quater of screen)

Code: Select all
string[] args = Environment.GetCommandLineArgs();

// test all commands (add it in a bat file then run it)
// C:\UCCNC\UCCNC.exe /TITLE "title 1" /SLEEP_FOR_TESTS 2000 /TITLE "title 2" /WINDOW_MAXIMIZED /POPUP_FOR_TESTS "Window should be maximized" /WINDOW_ON_TOP /POPUP_FOR_TESTS "Window should be on top" /WINDOW_ON_BOTTOM /POPUP_FOR_TESTS "Window should be on bottom" /WINDOW_ON_LEFT /POPUP_FOR_TESTS "Window should be on left" /WINDOW_ON_RIGHT /POPUP_FOR_TESTS "Window should be on right" /WINDOW_ON_TOP_LEFT /POPUP_FOR_TESTS "Window should be on top left" /WINDOW_ON_TOP_RIGHT /POPUP_FOR_TESTS "Window should be on top right" /WINDOW_ON_BOTTOM_LEFT /POPUP_FOR_TESTS "Window should be on bottom left" /WINDOW_ON_BOTTOM_RIGHT /POPUP_FOR_TESTS "Window should be on bottom right"

//MessageBox.Show("Test " + args.Length);
if (args.Length > 0)
{
   for (int i = 0; i < args.Length; i++)
   {
      string command = args[i].Trim().ToUpper();
      if ((command == "/TITLE") && (i < args.Length - 1))
      {
         //MessageBox.Show("TITLE = " + args[i + 1]);
         exec.mainform.Text = args[i + 1];
         i++;
      }
      else if (command == "/WINDOW_MAXIMIZED")
      {
         exec.mainform.WindowState = FormWindowState.Maximized;
      }
      else if (command == "/WINDOW_ON_TOP")
      {
         Rectangle rect = Screen.PrimaryScreen.WorkingArea;
         exec.mainform.WindowState = System.Windows.Forms.FormWindowState.Normal;
         rect.Height = rect.Height / 2;
         exec.mainform.Bounds = rect;
         exec.mainform.Location = new Point(0, 0);
      }
      else if (command == "/WINDOW_ON_BOTTOM")
      {
         Rectangle rect = Screen.PrimaryScreen.WorkingArea;
         exec.mainform.WindowState = System.Windows.Forms.FormWindowState.Normal;
         rect.Height = rect.Height / 2;
         exec.mainform.Bounds = rect;
         exec.mainform.Location = new Point(0, rect.Height);
      }   
      else if (command == "/WINDOW_ON_LEFT")
      {
         Rectangle rect = Screen.PrimaryScreen.WorkingArea;
         exec.mainform.WindowState = System.Windows.Forms.FormWindowState.Normal;
         rect.Width = rect.Width / 2;
         exec.mainform.Bounds = rect;
         exec.mainform.Location = new Point(0, 0);
      }   
      else if (command == "/WINDOW_ON_RIGHT")
      {
         Rectangle rect = Screen.PrimaryScreen.WorkingArea;
         exec.mainform.WindowState = System.Windows.Forms.FormWindowState.Normal;
         rect.Width = rect.Width / 2;
         exec.mainform.Bounds = rect;
         exec.mainform.Location = new Point(rect.Width, 0);
      }   
      else if (command == "/WINDOW_ON_TOP_LEFT")
      {
         Rectangle rect = Screen.PrimaryScreen.WorkingArea;
         exec.mainform.WindowState = System.Windows.Forms.FormWindowState.Normal;
         rect.Height = rect.Height / 2;
         rect.Width = rect.Width / 2;
         exec.mainform.Bounds = rect;
         exec.mainform.Location = new Point(0, 0);
      }
      else if (command == "/WINDOW_ON_TOP_RIGHT")
      {
         Rectangle rect = Screen.PrimaryScreen.WorkingArea;
         exec.mainform.WindowState = System.Windows.Forms.FormWindowState.Normal;
         rect.Height = rect.Height / 2;
         rect.Width = rect.Width / 2;
         exec.mainform.Bounds = rect;
         exec.mainform.Location = new Point(rect.Width, 0);
      }
      else if (command == "/WINDOW_ON_BOTTOM_LEFT")
      {
         Rectangle rect = Screen.PrimaryScreen.WorkingArea;
         exec.mainform.WindowState = System.Windows.Forms.FormWindowState.Normal;
         rect.Height = rect.Height / 2;
         rect.Width = rect.Width / 2;
         exec.mainform.Bounds = rect;
         exec.mainform.Location = new Point(0, rect.Height);
      }
      else if (command == "/WINDOW_ON_BOTTOM_RIGHT")
      {
         Rectangle rect = Screen.PrimaryScreen.WorkingArea;
         exec.mainform.WindowState = System.Windows.Forms.FormWindowState.Normal;
         rect.Height = rect.Height / 2;
         rect.Width = rect.Width / 2;
         exec.mainform.Bounds = rect;
         exec.mainform.Location = new Point(rect.Width, rect.Height);
      }
      else if ((command == "/SLEEP_FOR_TESTS") && (i < args.Length - 1))
      {
         System.Threading.Thread.Sleep(Int32.Parse(args[i + 1]));
         i++;
      }
      else if ((command == "/POPUP_FOR_TESTS") && (i < args.Length - 1))
      {
         MessageBox.Show(args[i + 1]);
         i++;
      }
   }
}

Fabien
 
Posts: 33
Joined: Fri Jun 21, 2019 8:04 am


Return to Feature Request

Who is online

Users browsing this forum: No registered users and 1 guest