How do I use AutoHotkey PostMessage to send WM_WININICHANGE to Program Manager? - windows-xp

I've written a script which updates an environment variable, but I need to tell Program Manager to update the computer's programs with this new information. I was given this as the API call that is made within another program to cause this:
::SendMessage(::FindWindow("Progman", NULL), WM_WININICHANGE, 0L, (LPARAM)"Environment");
I am attempting to translate this into an AutoHotKey PostMessage call, but I'm doing something wrong, as it isn't working. Here's where I've gotten so far:
PostMessage, 0x1A,, (LPARAM)"Environment", "Program Manager"
Here are the AHK resources I've been looking at to do this:
List of Windows Messages
Send Messages to a Window or Its Controls
PostMessage / SendMessage
And here are the resources that I used to figure out the original API call:
SendMessage function
WM_WININICHANGE message
Can anyone help me figure out what I'm doing wrong?

A somewhat direct translation would be:
SendMessage 0x1A,, "Environment",, ahk_class Progman
The wParam and lParam parameters are expressions, so literal strings must be quoted. Conversely, the Control and WinTitle parameters are not expressions, so any quote marks would be interpreted literally.
In AutoHotkey, (LPARAM) is just a variable enclosed in parentheses, not a type cast. It should be omitted.
Note that MSDN indicates WM_SETTINGCHANGE should be used instead of WM_WININICHANGE, but these are actually one and the same.
Finally, note that EnvUpdate broadcasts the WM_SETTINGCHANGE message to all windows.
EnvUpdate

Related

Is there a way to add a command to neovim that can be called as `:command`?

What I would like to archieve is to be able to use :< shell command and add the output to the shell command to the cursor's position in neovim.
It seems I could use :redir to archieve this functionality and wrap it in to a function.
Is there a way to associate a [neo]vim function to :command?
A command can't return value. Hence a command is not an expression. And in particular, commands never can be "nested" one into another, like function calls. Cf. Shell scripting, for example.
In principle, there are some tricks, like a builtin function that accepts command name, runs it, and returns output as string value. But this is rather "convenient redir", not "syntax breaker".
To add external tool output into cursor position use, for example,
put=system('blah blah')
This is legal, as (some of) commands may accept expressions, including function calls.
Make sure to escape "bars" and "double quotes" though, as (sometimes) they are special in VimScript.

VSCode ShowinputBox have a mandatory field? Either trap the escape and force data input or disable the ability to escape

How do I make an input field mandatory in VSCode ShowInputBox?
I do not want the user to be able to escape out. I know I can trap the response to be undefined which tells me that the user did in fact escape but I then want to reissue the ShowInputbox. That becomes really messy. It would be cleaner to remain in the ShowInputBox and not proceed till data is present. "validateInput" is not an option as it doesn't get called when escape is pressed.
Is there any means of either suppressing the Escape key or trapping it such that the user has to enter some data into the field.
Seems a simple request but I cannot find any means of accomplishing this.

Make & show the same information as a command prompt

In my previous questions here on stack we determined my command should run like this.
(& C:\Gyb\Gyb.exe --email $DestinationGYB --action restore --local-folder $GYBFolder --label-restored $GYBLabel --service-account)
The problem with this is if I run that same command in a command prompt I would see a bunch of status information.
When I run the command as above all I see in VSCode is it ran that line and its waiting. How can I make it show me like the command prompt without opening a new window?
here is GYB
https://github.com/jay0lee/got-your-back
Remove the parentheses () around your command if you want to see the output at the same time. Otherwise, this behavior is expected and is not unique to the VSCode terminal.
The group-expression operator () is used to control the order of which code is executed in PowerShell. Expressions are evaluated like order of operations (re: PEMDAS) in Mathematics, the inner-most parentheses get evaluated first. You can also use the group-expression operator to invoke a property or method from the returned expression in the group.
The problem is, group-expressions don't output to the parent level directly, that only happens when the group-expression is done executing. So when you have something that can run for several minutes or even hours like gyb.exe, you don't see that output until the command exits and execution continues.
Contrast this to running outside of the group-expression; as STDOUT is written to the success stream the success stream is immediately written to console as it comes. There is no additional mechanism you are proxying your output through.
Note: You will experience nearly the same behavior with the sub-expression operator $() as well, although do not conflate sub-expressions and group-expressions as they serve different purposes. Here is a link to the official explanation of theGrouping Operator ( ), the Subexpression Operator `$( ) is explained immediately below it.

Scan system PATH for executable file

Python 3 has the very useful shutil.which (https://docs.python.org/3/library/shutil.html#shutil.which) function. Is there an equivalent for Scala?
For context, I want to run a shell command in scala to get a notification to the user. For example, in the case of ubuntu, something like Seq("notify-send", title, msg) ! (using sys.process from the standard library). But I want to check beforehand if command is in the system path, so I can give an informative error message.
I'd like to avoid resorting to parsing (i.e. splitting on :) and iterating over the folders manually. Another alternative would be Seq("which", "command") !, but that doesn't work on windows (right?).

how to perl for bi-directional communication with dsmadmc.exe?

I have simple web-form with a little js script that sends form values to a text box. This combined value becomes a database query.
This will be sendt to dsmadmc (TSM administrative command line).
How can I use perl to keep the dsmadmc process open for consecutive input/output without the dsmadmc process closing between each input command sent?
And how can I capture the output - this is to be sent back to the same web page, in a separate div.
Any thought, anyone?
Probably IPC::Open2 could help. It allows to read/write to/from both input and output of an external process.
Beware of deadlocks though (i.e. situations where both your code and the app wait for their counterpart). You might want to use IO::Select to handle that.
P.S. I don't know how these modules behave on windows (.exe?..), but from a quick google search it looks like they are compatible.