Button (Macro) - Call *.exe

Here is where you can drop off Examples of WORKING macros,plugins,Gcode programs , macro Wizards etc.
Please give a brief description of what it is and how it works.

Button (Macro) - Call *.exe

Postby Robertspark » Thu Aug 03, 2017 1:40 pm

Similar principle to the call (open) usermanual PDF.

.... this one just starts a program of your choosing from a UCCNC screenset button press, in this case Sheetcam (obviously won't work for you directly unless you have sheetcam ..... hence change it to the program of your choosing [vectric, autocad, stepper motor tuning software [leadshine protuner from the diagnostics screen] etc...

Code: Select all
System.Diagnostics.Process Sheetcam = new System.Diagnostics.Process();
Sheetcam.StartInfo.FileName = @"C:\Program Files (x86)\SheetCam TNG Development\SheetCam TNG Development.exe";
Sheetcam.Start();
Attachments
M20001.txt
(202 Bytes) Downloaded 1563 times
Robertspark
 
Posts: 1892
Joined: Sat Sep 03, 2016 4:27 pm

Re: Button (Macro) - Call *.exe

Postby dezsoe » Thu Aug 03, 2017 2:05 pm

The same technique to use your favorite text editor to edit g-code. Edit screen and change "Edit file" buttonnumber from 126 to 20126. In M20126.txt change the path to your favorite text editor.

Code: Select all
// 126 -> 20126 -> external code editor

string sFileName = exec.mainform.filenametoload;

if ((sFileName == "") || (sFileName == Application.StartupPath + "\\Contents\\Empty.txt"))
{
  AS3.Additemtolistbeginning("No file loaded!", 2);
  return;
}

System.Diagnostics.Process proc;
proc = System.Diagnostics.Process.Start(@"C:\Program Files (x86)\PSPad editor\PSPad.exe", sFileName);
proc.WaitForExit();

exec.mainform.loadfile();
Attachments
M20126.txt
(446 Bytes) Downloaded 1596 times
dezsoe
 
Posts: 2093
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary

Re: Button (Macro) - Call *.exe

Postby Robertspark » Wed Dec 25, 2019 11:04 pm

help.....

Trying to work out how to get focus / setfocus to a process that is already loaded....

I've got this far.... but I cant seem to get "SetForegroundWindow" to work for me

Code: Select all


System.Diagnostics.Process[] localByName = System.Diagnostics.Process.GetProcessesByName("SheetCam TNG Development");

if (localByName.Length > 0){
   
//System.Diagnostics.Process Sheetcam = new System.Diagnostics.Process();
//localByName.Start();

return;
}
else {
System.Diagnostics.Process Sheetcam = new System.Diagnostics.Process();
Sheetcam.StartInfo.FileName = @"C:\Program Files (x86)\SheetCam TNG Development\SheetCam TNG Development.exe";
Sheetcam.Start();
}


I've tried various things after the "if (localByName.Length > 0){" and just cannot seem to be able to give focus to an already loaded process, instead of loading another occurance


Any guidance would be greatly appreciated, thanks,
Robertspark
 
Posts: 1892
Joined: Sat Sep 03, 2016 4:27 pm

Re: Button (Macro) - Call *.exe

Postby Robertspark » Thu Dec 26, 2019 11:55 am

well, I got this far:

Code: Select all
System.Runtime.InteropServices.DllImportAttribute import = new System.Runtime.InteropServices.DllImportAttribute("USER32.DLL");


but I cannot get this to run error free.... (yet)

Code: Select all
public static extern bool SetForegroundWindow(IntPtr hWnd);




trying to use this way of doing it:
https://shatter-box.com/knowledgebase/b ... th-csharp/
Robertspark
 
Posts: 1892
Joined: Sat Sep 03, 2016 4:27 pm


Return to UCCNC TOOL BOX

Who is online

Users browsing this forum: No registered users and 5 guests