ConEmu - How to create 3 Vertical & 1 Horizontal split? - conemu

How to create the below splits in ConEmu?
I tried the below commands and it did not help.
cmd -cur_console:n
powershell -cur_console:s1TVn
bash -l -i -cur_console:s1THn
cmd -cur_console:s2THn

Easy. Just use new console dialog.
Start one cmd pane
Start new PowerShell pane to the right
Activate first pane and start new cmd panes to the bottom (twice).
Done. You may go to the Tasks page and add "Active tabs" to new task.

Related

Windows 10 - Automatically exit batch script

This is my script:
SQLPLUS -S -M "HTML ON TABLE 'BORDER="2"'" username/pass#env #test.sql>test.html
After execution command prompt window stays open. How do I auto-close?
After your line of code add another line, like this:
exit
or
tskill cmd.exe
I hope I can help you.

Creating a cmd line shortcut

I am completely new to Windows, as i am an OSX user.
I am having to run a task in the cmd line every day, is there any way i can create a shortcut on my desktop which automates this?
Task example, open cmd, then execute:
atomInstaller npm -view -Xmx8g -Xms3g
Thanks
You could just make a shortcut to cmd.exe and add command line switches:
https://superuser.com/questions/358565/adding-command-line-switches-to-windows-shortcuts
Or you can put commands into a batch file using notepad ( or a better text editor ):
#echo off
atomInstaller npm -view -Xmx8g -Xms3g
save it as npm.bat then double-click it..
You can use shortcutjs.bat:
call shortcutjs.bat -linkfile "%userprofile%\desktop\atominstaller.lnk" -target "C:\atomInstaller.bat" -adminpermissions yes -iconlocation "C:\Windows\System32\compstui.dll,3" -hotkey "Ctrl+Shift+M"
Here's the usage:
shortcutjs.bat -linkfile link -target target [-linkarguments linkarguments] [-description description] [-iconlocation iconlocation] [-hotkey hotkey] [-windowstyle 1|3|7] [-workingdirectory workingdirectory] [-adminpermissions yes|no]
You can add additional parameter with -linkarguments or start location with -workingdirectory

How to hold ConEmu window from exiting?

Gurus
I am using using ConEmu command line to run a shell script in ConEmu. However ConEmu always exits after the script completes. Is there any way to make ConEmu work like "mintty -h always" which keeps the Window open?
ConEMU CLI:
ConEMU.exe /cmd C:\mybin\sh.exe my_script.sh
I wish it holds window like:
mintty.exe -h always -e C:\mybin\bash.exe my_script.sh
Thanks
You may use following syntax
ConEmu.exe /cmd C:\mybin\sh.exe my_script.sh -cur_console:c

ConEmu commands in task

I'm trying to get a Task in ConEmu to open several consoles, and for each run a batch-like script when opened. For example:
Open a Git Bash, name the console "X", set the current directory to "Y".
Open another Git Bash and run a set of commands, for example "cd A/B/C", "vagrant up"
Open a regular command window, run the command "cd D/E/F", "grunt watch"
I want the second and third consoles to appear alongside each other, but underneath the first console. So far I am stuck getting commands to run; I have a task that runs the following:
"%ProgramFiles(x86)%\Git\bin\sh.exe" --login -i "-cur_console:n:t:Git Bash" "-cur_console:d:C:\Users\Ole Vik\dev"
"%ProgramFiles(x86)%\Git\bin\sh.exe" --login -i "-cur_console:s1TVn:t:Vagrant"
cmd "-cur_console:s2THn:t:Third"
Reading the ConEmu wiki led me to the new_console and cur_console switches, but I'm having trouble figuring out if I can somehow enter commands in the Task setup, or maybe if I can have it run a .bat script on each console.
No colon is needed between switches (n & t for example).
cmd has /k switch to run commands.
I don't know the way to tell bash "run this command and stay in prompt". May be you need to run commands with &. I'm not sure about second line, you need to check it yourself.
"%ProgramFiles(x86)%\Git\bin\sh.exe" --login -i "-cur_console:nt:Git Bash" "-cur_console:d:C:\Users\Ole Vik\dev"
cmd -cur_console:s1TVnt:Vagrant /c vagrant up & "%ProgramFiles(x86)%\Git\bin\sh.exe" --login -i"
cmd -cur_console:s2THnt:Third /k cd /d "D\E\F" & grunt watch

Programmatically send key strokes to a window program in Groovy or bat script

Backstory: I need to programmatically find the differences between two files. I want to use WinMerge to generate a report (Tools -> Generate Report) that I can parse to get the differences between two files. I need this done using either a Groovy script or a bat script.
I was hoping that WinMerge would offer command line options to generate the report and then I could just use a Groovy Process object to execute WinMergeU.exe with the arguments. No such luck according to the command options I've found for WinMerge.
Next, I was hoping to be able to start WinMerge and send keystrokes to step through the menus to generate the report(Alt+T, R, Diff.html, [Enter]). I don't see a way to do that from a Groovy Process and I haven't found a way to do this in a bat script. I'm looking for something similar to WshShell.Sendkeys in VB. Is this a wild-goose chase?
UPDATE/Answer with PowerShell in a bat file:
I was intrigued by Knuckle-Dragger's comment about using a PowerShell script in a bat file.
$folder = "C:\DevTools\WinMerge\WinMergeU.exe"
ii $folder
Start-Sleep -m 1000
[void][System.Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic')
[Microsoft.VisualBasic.Interaction]::AppActivate("WinMerge")
Start-Sleep -m 100
[void][System.Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms')
Start-Sleep -m 100
[System.Windows.Forms.SendKeys]::SendWait("%F")
[System.Windows.Forms.SendKeys]::SendWait("o")
[System.Windows.Forms.SendKeys]::SendWait("{ENTER}")
[System.Windows.Forms.SendKeys]::SendWait("%T")
[System.Windows.Forms.SendKeys]::SendWait("r")
Start-Sleep -m 1000
[Microsoft.VisualBasic.Interaction]::AppActivate("Save As")
Start-Sleep -m 1000
[System.Windows.Forms.SendKeys]::SendWait("Diff.txt")
[System.Windows.Forms.SendKeys]::SendWait("{ENTER}")
To encapsulate this in a command window, save it to a file PowerShellScript.ps1:
start /b /wait powershell.exe -nologo -WindowStyle Hidden -sta *PowerShellScript.ps1*
Here is a powershell example to activate winmerge and send some keys.
EDIT: Reduced copy pasta with some .NET variables. $SK = Sendkeys $AA = AppActivate $LRA = Reflect .NET.
$startapp = "C:\DevTools\WinMerge\WinMergeU.exe"
ii $startapp
$SK = "[System.Windows.Forms.SendKeys]::SendWait"
$AA = "[Microsoft.VisualBasic.Interaction]::AppActivate"
$LRA = "[void][System.Reflection.Assembly]::LoadWithPartialName"
Start-Sleep 1
$LRA+'("Microsoft.VisualBasic")'
$AA+'("WinMerge")'
Start-Sleep -m 100
$LRA+'("System.Windows.Forms")'
Start-Sleep -m 100
$SK+'("%F")'
$SK+'("o")'
$SK+'("{ENTER}")'
$SK+'("%T")'
$SK+'("r")'
Start-Sleep 1
$AA+'("Save As")'
Start-Sleep 1
$SK+'("Diff.txt")'
$SK+'("{ENTER}")'
To encapsulate this in a command window, save it to a file PowerShellScript.ps1: Note, changed the command syntax a bit, should work if you use the & {.\dot\source\path}
start /b /wait powershell.exe -nologo -WindowStyle Hidden -sta -Command "& {.\PowerShellScript.ps1}"
This is something that I threw together without testing, and I don't have WinMerge so testing isn't really an option.
RunMe.bat
start "" "C:\Path\WinMerge.exe" "file1" "file2"
GenerateDiffFile.vbs
GenerateDiffFile.vbs
Set s = CreateObject("WScript.Shell")
wscript.sleep(1000) ' Sleep for 1 second to allow time for WinMerge to finish loading and merge the files
s.SendKeys("%tr")
wscript.sleep(250) ' Give time for dialog box to appear
s.SendKeys("Diff.html{Enter}")
This is completely untested, but I think it is very close to what you need... You can see that the batch-file runs WinMerge, passing the two files to merge on the command line. Then it launches the VBS script, which pauses long enough to allow the launched WinMerge to be able to accept keyboard input. I used this page from Microsoft to know what keys to send.
I've been sending keys to programs for years. It works very reliably, as long as the program you want to send keys to keeps focus.
All I do is this:
echo y | "Batchfile needing the keystroke"

Resources