Activate extension programmatically with a command execution - vscode-extensions

I'd like to activate extension A from extension B with a help of a command that extension A defines. This command is also an activation event for extension A, i.e. "trigger.command"
Therefore if from extension B I call VScode.commands.executeCommand("trigger.command") will that activate extension A?
If not, is there anything else I can try doing?

If the command actually runs, I don't see how this cannot activate the extension. It must to run the code. See VS Code API.

Related

Global from User defined GUI

So I think my problem is my understanding of Global Variables and subroutines. Plus the Lists at the start
Heres my code:
https://gist.github.com/anonymous/ff1b16aa4093a2929896
If I place it into maya highlight it and press the Play icon. It works and the GUI opens and I can run the whole process from the GUI okay. But if I save it and try and import it as module it doesnt work properly and the reset button disppears and I get this:
# NameError: global name 'Reset' is not defined #
EDIT: I'd put Reset in the variable but for the procedure for some reason.
Check out the optionVar command.
In general, the entire user interface of Maya is open source. If you want to know how something works, you can simply find the script that implements it. Also try not to avoid learning MEL.

Call an Objective-c class from AppleScript in OSX 10.7

Is it possible to call an Objective-c class from AppleScript in OSX 10.7?
I have seen some suggestions for Snow Leopard or earlier, but none seem to work.
AppleScript-Obj-C seems to be a way of constructing a GUI which uses AppleScript, but I want to call a class I have written from a script.
The following (which does not work) is what I would like to do:-
on getJpegComment(photoFile)
set aJpeg to call method "initWithPath" of class "JpegCom" with parameter photoFile (does not work)
return call method "comment" of aJpeg
end getJpegComment
tell application "iPhoto"
tell album "Sale"
set thePhotos to get every photo
end tell
repeat with aPhoto in thePhotos
tell application "iPhoto"
set aPhotoFile to image path of aPhoto
set aComment to my getJpegComment(aPhotoFile)
set comment of aPhoto to aComment
end tell
end repeat
end tell
I started down this path because of links which seemed to indicate this was possible.
I could write an Objective-c program, which called AppleScript, but this seems overkill for seemed to be a simple task.
PS I have thousands of photos, which I had entered JPEG COMments of Windows, unfortunately iPhoto does not understand these.
When I want to do a simple task like you, and I need something from objective-c, I find the easiest solution is to turn the objective-c part into a command line tool in Xcode. Then I call the tool from applesript using "do shell script". I have many examples of these tools on my website of 1) the code for the unix tool, and 2) how to use the tool from applescript. So basically you make a tool which accepts one parameter (eg. the path to the image) and it returns the comment. Look here for my tool examples. Any of the items under the "Code Sharing" menu will help you with this approach.
No, you can't call Objective-C from a regular, freestanding AppleScript run from AppleScript Editor or a script menu. You would need to build your script into an AppleScriptObjC application created with Xcode or execute it in a special environment such as ASObjC Runner.
For cases where I just want to call a couple Objective-C methods, I would probably use do shell script to invoke Python and use the PyObjC bridge. That way your script remains compatible with regular AppleScript, and you don't need any auxiliary executable files. For example:
do shell script "python -c 'from Foundation import NSDate; print NSDate.date()'"
You can make an AppleScriptObjC script using AppleScript Editor. Go to File > New from Template > Cocoa-AppleScript Applet.
This will run like a standard script, without any GUI, but you can also access Cocoa functionality like you can when using AppleScriptObjC in Xcode. You should also be able to use Objective-C classes like you would do in Xcode.

VB.NET call desktop application from 2 shortcuts - supply different parameters

I have a desktop application which reads files from a specified folder, then deposits the files to a folder in a third party document management system based on criteria that the user provides.
My question is:
is it possible to somehow provide different parameters to the code, depending on which shortcut of the application the user clicked on to start it up?
You can add command line parameters to a shortcut icon. Here's how you can do it in Windows:
On the Start Menu, navigate to Notepad.
Right click on Notepad and choose Send To > Desktop (Create Shortcut)
Right click on the newly-created desktop icon and choose Properties
Add your command line parameters to the Target text box.
For example, if you want notepad to open up the hosts file, this would be the content of Target property:
%SystemRoot%\system32\notepad.exe "C:\WINDOWS\system32\drivers\etc\hosts"
You can put pretty much anything into the Target property of a shortcut that you would put into a command line.
Yes.
The easiest way would be to have the shortcut pass those parameters in via the command line.
You could also use conditional compilation variables, and have 2 different .exes. You should be able to find samples of both approaches (command line and conditional compilation variable) in help.

system.diagnostic.process.start problem

Im trying to create an application launcher using vb.net. I'm trying to launch desktop shortcuts that are hidden because I want my desktop to be free of mess. Those shortcuts are created through nircmd :http://www.nirsoft.net/utils/nircmd.html
I used this code:
System.Diagnostics.Process.Start("E:\Documents and Settings\Rew\Desktop\SpeakClipboard.exe")
And it returned the error that the path specified cannot be found.
I tried launching an application in program files using this method and it worked well.
Is there a problem with shortcuts? I cannot specify the path for the file where the shortcut is linked because its a shortcut in the desktop and doesn't point to anything except the nircmd.exe that is on : F:\NIRCMD
But I also tried using this path for system.diagnostic.process.start:
F:\NIRCMD\nircmd.exe cdrom open g:
But still no luck.
If I understand correctly SpeakClipboard.exe is actually a shortcut? If so it probably has a hidden .lnk extension. So you should specify SpeakClipboard.exe.lnk or SpeakClipboard.lnk if it doesn't actually have .exe in the name.
There is a property on the ProcessStartInfo object that allows you to specify an argument.
eg your command would be "F:\NIRCMD\nircmd.exe" and the arguments would be "cdrom open g:"
Does that work?

run WPS from inside a cocoa application

I'm trying to learn to develop in cocoa and objective C.
I would like to run a run WPS from inside a cocoa application.
This command works from a terminal: wps test.sas
The command creates a test.log and a test.lst.
How do I execute this command
from the C program
Is there a way
to read the test.lst file into a
text window in application builder?
It would be fantatic if you could help me :-)
Regards,
T
(1) To run the command, use NSTask.
(2) To read the file, use NSString's + stringWithContentsOfFile:encoding:error: method
(3) To put the contents of the file into an NSTextView in your user interface, use NSTextView's setString: method.
If little to none of the above makes sense, you need to start here.