How to have SlickEdit control another window? - winapi

I want to have SlickEdit control another window.
I have an idea of how this could be done using some window’s apis but I am not sure how to implement this in SlickEdit. I am assuming Slick-C (SlickEdit's macro language) would be used. I have done some limited coding in Slick-C but I am not sure if window apis can be run.
Here is what I want done using windows API.
BringWindowToTop (This will bring the other window to the top)
SetForegroundWindow
Simulate pressing the F7 in the other window by using SendKey.
SendKey is a method in WScript.Shell .
It sounds pretty straight forward, all I need to know is how to do it in SlickEdit.
Update:
I pretty much used the concept jussij outlined but in a language I am familar with called PL/B. I already had most of these APIs working for another process, so it was pretty easy to create this new program and had SlickEdit shell out to run the program.
Here is what was needed inside of SlickEdit:
_command BenShellSAV1P198() name_info(','VSARG2_MACRO|VSARG2_MARK|VSARG2_REQUIRES_MDI_EDITORCTL|VSARG2_READ_ONLY)
{
save_all();
shell("T:\\Sunbelt\\CODE\\plbwin.exe -h -i PlbBenTDSm.INI SAV1P198.PLC","N");
}
Then I bound that macro to a hot key and it all works just fine.

SendKey is a method in WScript.Shell.
I am pretty sure everthing you describe can be done at the WScript level.
So you could write a script that does all the work and once you have it working, just add it as a tool to SlickEdit by running the script using the cscript.exe executable.

Related

AutoHotkey - persistent keystroke expansion? - HotStrings

I am having trouble understanding how this product works. In the old days of Windows 3.1 and 95 I used these things called "hotkeys" where, no matter where I was in Windows, I could hit a certain key combination and it would happen. I assumed that was what this program did. Is it really just a scripting language?
I followed the "quick start" tutorial in the help file and it talks about creating a script and how to set strings for keystroke patterns to expand into. However, I created this simple script and put it in an AHK file on my Desktop:
::gsell::
Great Seller! A++++++++++++++++++++++++++++++++
Return
When I run the script from my desktop it appears to complete pretty much instantly, and of course it does nothing because I am on my desktop. I assumed there was some way to actually use these hotkeys in other applications, but it is not obvious to me and I've made a fair effort. Is this just an automation scripting language, or is there some simple way to set up some simple hotkeys and have them persist across applications?
Hotkeys and Hotstrings are available globally by default. Your issue with the expansion is likely because you have special characters that need to be escaped. Try the following:
::gsell::Great Seller{!} A{+}
; Simple Hotkey - Ctrl+F1
^F1::Msgbox, You pressed a hotkey
I decided to try an example from the help file and it did work. Apparently the place where I thought it was telling me the script was closed, was actually saying the script was still running, and it counts the number of seconds when you refresh. For some reason the text expansion is still not working, but this question is pretty much solved.

Assign VBS Script to a Keyboard Shortcut

I have a very basic VBS script that I plan on using frequently on my Windows 7 machine. Is there any way I can bind it to a keyboard shortcut so I don't have to navigate to it through Explorer obnoxiously.
I realize this question does not directly pertain to programming, or even scripting for that matter, but I could not find a straight answer online or through my own experimentation. I'm sure that there is a simple solution somewhere...
Thank you for taking the time to read, and hopefully respond to my inquiry.
Evin Ugur.
Windows does have built-in support for shell shortcut keys, where a keypress is used to invoke an *.lnk file that launches your VBScript (using either cscript or wscript).
Create a shortcut file, have it invoke your VBScript file directly or run cscript or wscript with the appropriate arguments, then save it and open its Properties sheet and set a keystroke in the "Shortcut key" field (I suggest something like Ctrl+Alt+K).
Like so:
Then, whenever you press Ctrl+Alt+K, regardless of the active application, your script will be invoked.
A more heavy-duty alternative is AutoHotKey: http://www.autohotkey.com/
Just as an FYI.
I tried this and I was not able to register the hotkey when I had the Icon in a costume folder. Even if I added the hotkey, it failed to work.
Once I moved the icon to the "C:\ProgramData\Microsoft\Windows\Start Menu\Programs", the hotkey started to work.

Magnify.exe command line args

Does anyone know if there is any command line args that i could pass to the windows magnifier (magnify.exe) so it would open using the Lens view.
Or maybe some other way, I tried opening and sending a keyboard input using the shortcut to change the view, but often it blinks before changing the view! =/
I just had the need to do the same thing, and wound up here trying to find a solution. It's ridiculous to think that they wouldn't have a command line switch to set the views, so I started just trying some. And behold! I scored:
Magnify.exe /lens (defaults to lens view)
Magnify.exe /fullscreen (defaults to fullscreen view)
Magnify.exe /docked (defaults to docked view)
Good luck!
Magnify.exe /? on the command line does not expose any sort of help for the executable. And a search online does not seem to provide evidence of any command line arguments. Leads me to conclude that magnify.exe does not take command line arguments.
I recommend reading this article on sending keystrokes to another application. His demo app worked for me to send keyboard shortcuts to magnify.exe. His source code is available as well so you can integrate into your application.
you could try something with autoit, its a scripting language similar to basic that is really well suited for automating tasks
Along those lines this autoit script might be helpful - it lists some msdn doco and if you know
autoit a script.
Maginifier UDF
I am using a work-around.
I created a Windows-8-style batch file that has a command "magnify /on".
I'm not sure if the "/on" part is necessary.
The program that I am trying to magnify,
(which is an old DOS program that runs in a DOS-Box),
launches with the magnify window conveniently available for me to change the magnification setting.
I tried to include a command after closing, "magnify /off", but it does not work;
therefore the magnifier window box has to be clicked to change the magnification back to normal.
This is a great case for the UNIX "strings" utility, of which there is a Sysinternals version here
It takes some digging and testing, but I found these options:
wait (doesn't magnify until you hit a key)
noutilman
hardwarebuttonlaunch
fullscreen
lens
docked
hilight
globalhotkey

General Question about a GUI to execute a batch file

I'm new to programming and have taken some classes in it so I'm not sure if this is possible. I want to use a COTS software called 010 Hex Editor and write a script for the program to automate a couple tasks. These tasks can be run from a batch file according to their documentation.
Then I want to instruct the user to eject the device and reinsert it to clear the cache. (This I want done just with a simple pop-up window.
Then I also want to format the device which I assume can be done in a batch file as it can be done through dos on Windows.
My question is, with these 3 steps, can I build a simple GUI that has a button that says, "Start" or something like that, then the pop up window comes up to eject and reinsert, and then another button to format, and another button to exit. I'm not really familiar with what language this could be done in, and how to do this as the C++/Java classes I've taken have been more about syntax and OOP. Thanks!
You can use the windows messenger service to put up an alert - but on newer windows (vista/7) it's a pain to set all the permissions to allow this.
There are lots of free utilities that will popup a dialog from the command line, with a given message and wait for a response.
They are generally called messagebox or msgbox - sorry can't recommend any in particular

How to get the main window handle of a process using JScript?

Is there any method in JScript to get the handle of the main window of a process by providing the process name? The Process.MainWindowHandle property works only in JScript .NET. Is anything similar available in classic JScript?
I am not sure if this works, just try to loop window.parent until its undefined.
something like -
var mainWindow = window;
while( mainWindow.parent ) {
mainWindow = mainWindow.parent;
}
you also have something like window.top which always returns you the topmost window. But not sure if this is supported by all browsers.
JScript and Windows Script Host don't have this functionality, and neither does WMI.
If PowerShell is an option for you, then you can use the Process.MainWindowHandle property you mentioned:
(Get-Process notepad).MainWindowHandle
Otherwise, you'll need to find or write an utility (COM object, command-line tool etc) that would provide this functionality, and call this tool from your script.
Edit: So you need to close the window — that's a UI automation task.
Windows Script Host provides very limited UI automation functionality. If you know the window title, you could try using the AppActivate to and SendKeys methods to activate that window and send the Alt+F4 shortcut to it. You can find an example this answer. (The code is in VBScript, but it should give you the idea.) However, this approach isn't reliable.
If you really really don't want to kill the process, the easiest solution is to use some third-party UI automation tool. For example, you could try the free AutoIt tool — I think it should be able to accomplish what you need.
Edit 2: Have you tried recording the closing of the window? You should get a script like this:
Sys.Process("notepad").Window("Notepad", "Untitled - Notepad").Close();
Isn't this what you need?
For a native win32 application, there is no such thing as a "main window". A process can have no windows at all, or several top level "main" windows.
Well once i had to write a add-in for Outlook. My boss wants a splash-screen to appear when Outlook loads. But Outlook window goes over the splash. After a lot of search i found FindWindow http://msdn.microsoft.com/query/dev10.query?appId=Dev10IDEF1&l=EN-US&k=k%28FINDWINDOW%29%3bk%28TargetFrameworkMoniker-%22.NETFRAMEWORK%2cVERSION%3dV4.0%22%29%3bk%28DevLang-CSHARP%29&rd=true this is help for it . This function finds window based on window caption and window class name. I p-invoked it and used it from C#. If you can use this function through JScript I think it could do the job for you. (I used Spy++ for finding lpClassName parameter)

Resources