• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Fast and invisible cmd call

Community Beginner ,
Dec 27, 2017 Dec 27, 2017

Copy link to clipboard

Copied

I need to call cmd command to get HDD serial. I will do it often so I need fast and invisible (without popup console window) solution.

  1. app.system

This is perfect fast and invisible solution on MacOS. But user see popup console window on Windows

I will glad to know how to disable with popups windows. Do anybody know how?

  1. quiet VBs file creation and launching:

var command="ping google.com";

var vbsFile = File(Folder.temp + '/aps_call.vbs');

vbsFile.open('w');

//vbsFile.write("chcp 1251\r\n");

vbsFile.write("Dim objShell\r\n");

vbsFile.write('Set objShell = WScript.CreateObject( "WScript.Shell" )\r\n');

vbsFile.write('objShell.Run "' + command + ' > ""' + decodeURI(tempFile.fsName) + '""", 0, True\r\n');

vbsFile.write('Set objShell = Nothing\r\n');

vbsFile.close();

vbsFile.execute();

$.sleep (200);

This is invisible but very slow solution. I don't know why execute method takes 2-3 seconds on my pc. May be somebody knows how do it faster.. )

Thanks for your attention and answers!

TOPICS
Actions and scripting

Views

1.4K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Guide , Jan 03, 2018 Jan 03, 2018

The modified code....

#include "BasicExternalObject.h"

#include "SoSharedLibDefs.h"

#include <string>

#include <windows.h>

#include <stdio.h>

#include <iostream>

#if defined (_WINDOWS)

    #pragma warning(disable : 4996) // Turn off warning about deprecated strcpy on Win

#endif

/**

* \brief To allow string manipulation

*/

using namespace std;

/**

* \brief Utility function to handle strings and memory clean up

*

* \param s - The referenced string

*/

static char* getNewBuffer(string& s)

{

    // Dynamically allocate m

...

Votes

Translate

Translate
Adobe
Guide ,
Dec 27, 2017 Dec 27, 2017

Copy link to clipboard

Copied

Windows 64bit only!

You could use Pauls modified External Lib example.

Files are here..

wikisend.com/download/806904

Place both files in the preset/ scripts folder.

The jsx gives a few basix examples, the system command will return data without opening a dos window.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 27, 2017 Dec 27, 2017

Copy link to clipboard

Copied

Where can I find documentation for this? Is this library free?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Dec 27, 2017 Dec 27, 2017

Copy link to clipboard

Copied

Yes its free, the modified code can be found here.. Get Photoshop foreground color as RGB value

The original code (SDK) can be downloaded from Adobe... Bridge Developer Center

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 27, 2017 Dec 27, 2017

Copy link to clipboard

Copied

Thank you! But what about Winx86? I need support it too

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Dec 27, 2017 Dec 27, 2017

Copy link to clipboard

Copied

Just recompile it then

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Dec 27, 2017 Dec 27, 2017

Copy link to clipboard

Copied

Just compiled a 32bit version for you...

Wikisend: free file sharing service

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 27, 2017 Dec 27, 2017

Copy link to clipboard

Copied

OK. I will try to use it. Thank you again

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 02, 2018 Jan 02, 2018

Copy link to clipboard

Copied

Sorry but .systemCmd shows cmd window. And I didn't find 'systemCmd' in documentation. May be it has more parameters..

Also I tries to use x86 version on x64 Windows and I got error of 'input-output'. Is it mean that I have to check WIndows type and have 2 libraries?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Jan 03, 2018 Jan 03, 2018

Copy link to clipboard

Copied

The documentation is the code itself, you might be able to amend it to suit your needs, maybe you could use CreateProcess instead of popen?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 03, 2018 Jan 03, 2018

Copy link to clipboard

Copied

Yes it will be nice to use CreateProcess but sorry I'm still  don't see modified code of this library. For example code of systemCmd. Can you send me project that you complied or link of it?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Jan 03, 2018 Jan 03, 2018

Copy link to clipboard

Copied

The modified code....

#include "BasicExternalObject.h"

#include "SoSharedLibDefs.h"

#include <string>

#include <windows.h>

#include <stdio.h>

#include <iostream>

#if defined (_WINDOWS)

    #pragma warning(disable : 4996) // Turn off warning about deprecated strcpy on Win

#endif

/**

* \brief To allow string manipulation

*/

using namespace std;

/**

* \brief Utility function to handle strings and memory clean up

*

* \param s - The referenced string

*/

static char* getNewBuffer(string& s)

{

    // Dynamically allocate memory buffer to hold the string

    // to pass back to JavaScript

    char* buff = new char[1+s.length()];

   

    memset(buff, 0, s.length()+1);

    strcpy(buff, s.c_str());

    return buff;

}

extern "C" BASICEXTERNALOBJECT_API long systemCmd(TaggedData* argv, long argc, TaggedData* retval)

{

    // The returned value type

    retval->type = kTypeString;   

    // Accept 1 and only 1 argument

    if(argc != 1)

    {

        return kESErrBadArgumentList;

    }

    // The argument must be a string

    if(argv[0].type != kTypeString)

    {

        return kESErrBadArgumentList;

    }

char*  cmd = (argv[0].data.string);

    FILE* pipe = _popen(cmd, "r");

    if (!pipe) retval->data.string = "";

    char buffer[128];

    std::string result = "";

    while(!feof(pipe)) {

        if(fgets(buffer, 128, pipe) != NULL)

            result += buffer;

    }

    _pclose(pipe);

    retval->data.string = getNewBuffer(result);

    return kESErrOK;

}

extern "C" BASICEXTERNALOBJECT_API long getClipboard(TaggedData* argv, long argc, TaggedData* retval)

{

    // The returned value type

    retval->type = kTypeString;   

    HANDLE h;  

  if (!OpenClipboard(NULL)) return kESErrBadArgumentList; 

  h = GetClipboardData(CF_TEXT);

  CloseClipboard();

  if(h){

  string text;

    text = (char*)h;

    if(text.length() < 1) return kESErrBadArgumentList;

    retval->data.string = getNewBuffer(text);

  }else{

retval->data.string = "";

  }

    return kESErrOK;

}

extern "C" BASICEXTERNALOBJECT_API long clearClipboard(TaggedData* argv, long argc, TaggedData* retval)

{

    if (OpenClipboard(NULL)){

        EmptyClipboard();

        CloseClipboard();

    }

    return kESErrOK;

}

extern "C" BASICEXTERNALOBJECT_API long setClipboard(TaggedData* argv, long argc, TaggedData * retval)

{   

    // Accept 1 and only 1 argument

    if(argc != 1)

    {

        return kESErrBadArgumentList;

    }

    // The argument must be a string

    if(argv[0].type != kTypeString)

    {

        return kESErrBadArgumentList;

    }

string source = (argv[0].data.string);

int len = source.length() +1;

source = source.c_str();

if(OpenClipboard(NULL))

{

    HGLOBAL clipbuffer;

    char * buffer;

    EmptyClipboard();

    clipbuffer = GlobalAlloc(GMEM_DDESHARE, len);

    buffer = (char*)GlobalLock(clipbuffer);

    strcpy(buffer, LPCSTR(source.c_str()));

    GlobalUnlock(clipbuffer);

    SetClipboardData(CF_TEXT,clipbuffer);

    CloseClipboard();

}

    return kESErrOK;

}

/**

* \brief Free any string memory which has been returned as function result.

*

* \param *p Pointer to the string

*/

BASICEXTERNALOBJECT_API void ESFreeMem (void* p)

{

    delete(char*)(p);

}

/**

* \brief Returns the version number of the library

*

* ExtendScript publishes this number as the version property of the object

* created by new ExternalObject.

*/

BASICEXTERNALOBJECT_API long ESGetVersion()

{

    return 0x1;

}

/**

* \brief Initialize the library and return function signatures.

*

* These signatures have no effect on the arguments that can be passed to the functions.

* They are used by JavaScript to cast the arguments, and to populate the

* reflection interface.

*/

BASICEXTERNALOBJECT_API char* ESInitialize (const TaggedData ** argv, long argc)

{

    return "makeArray,getAverage,appendString_s,myScript_a,acceptBoolean_b";

}

/**

* \brief Terminate the library.

*

* Does any necessary clean up that is needed.

*/

BASICEXTERNALOBJECT_API void ESTerminate()

{

   

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 12, 2019 May 12, 2019

Copy link to clipboard

Copied

LATEST

Receive an image file name and return coordinate values of non-black and white colors

----------------------------------------

How to modify :

------------------

#include <iostream>

#include <fstream>

#include <windows.h>

#include <gdiplus.h>

#include <vector>

#pragma comment(lib, "gdiplus.lib")

using namespace Gdiplus;

extern "C" BASICEXTERNALOBJECT_API  long my_getXY(TaggedData* argv, long argc, TaggedData * retval) {

Gdiplus::GdiplusStartupInput gdiplusstartupinput;

ULONG_PTR gdiplustoken;

Gdiplus::GdiplusStartup(&gdiplustoken, &gdiplusstartupinput, NULL);

wstring infilename(L"1.png");  //            

Bitmap* bmp = new Bitmap(infilename.c_str());

UINT height = bmp->GetHeight();

UINT width = bmp->GetWidth();

Color color;

vector<int> arr_xy(0);

for (UINT y = 0; y < height; y++) {

for (UINT x = 0; x < width; x++)

{

bmp->GetPixel(x, y, &color);

if (((int)color.GetRed() != 255 && (int)color.GetGreen() != 255 && (int)color.GetBlue() != 255) && ((int)color.GetRed() != 0 && (int)color.GetGreen() != 0 && (int)color.GetBlue() != 0)) {

arr_xy.push_back(x); arr_xy.push_back(y);

}

}

}

long* array = new long[arr_xy.size()];

for (int i = 0; i < arr_xy.size(); i++)

array = arr_xy.at(i);

delete bmp;

Gdiplus::GdiplusShutdown(gdiplustoken);

     return array;   // 

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 20, 2018 Jan 20, 2018

Copy link to clipboard

Copied

I used vbs and that didn't make 2 - 3 seconds delay: Re: UI: Remember last path entered

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines