I want to terminate a process but one window title should be excluded. So in a browser every window gets killed except the one I want to stay open.
taskkill /IM msedge.exe /F /FI "WINDOWTITLE eq windowtitle" = exclusion
The reason is if I use :
Run(#ComSpec & ' /c start msedge --inprivate --window-size=100,100 --window-position=955,535 --app="url',#SW_HIDE)
AutoIt opens an extra new tab window sometimes (and that's why I want to close each instance except the one I call here). Because the window title (new tab) is specified in local language, I want to have it so that it works for different countries
How can I can accomplish that with a batch file or in AutoIt or anything else?
Related
ASCII character code 0x07 is a beep character.
Opening CMD and clicking ALT + 007 yields :
And when I click ENTER - I hear a beep. This is fine.
I've searched how to add a beep in the end of a batch file, and I found that this is the solution : (I'm pasting it as an image becuase SO doesn't show the round bullet after editing) :
This does work and does make a sound. When examined with a HEX viewer (with beyond compare) on ECHO, the round bullet is:
But if I manually add ALT+7 to the document , I see this:
Which is a 95 as a hex - and it's not a Beep. In addition, I went to the working batch file and added a new line with my ALT+7 :
But looking via HEX viewer :
Question:
I'm a bit confused. Clicking Alt+65 does yields A everywhere.
So why does the beep different and doesn't work when saved in Windows GUI?
In the console, if I click ALT+007 I get ^G (it does beep), but when I click ALT+7 I get the circle, which is not a beep:
Here are both:
Another interesting observation via notepad++ :
I think it's related to encoding, etc, but I don't understand the inconsistency.
I have a workaround to suggest. Put this in your script:
forfiles /p "%~dp0" /m "%~nx0" /c "cmd /c echo 0x07"
For every file in your script's directory matching your script's filename (e.g. 1 time), it will echo ASCII character 7, and will make noise. From the forfiles /? documentation:
To include special characters in the command line, use the hexadecimal code for the character in 0xHH format (ex. 0x09 for tab). Internal CMD.exe commands should be preceded with "cmd /c".
forfiles is a handy utility to abuse whenever you need a non-printable or extended character.
As for my speculation for why Alt+007 doesn't behave as expected, I believe the console works on a different codepage from windowed applications (console = 437, windowed = 1252 for en-US, IIRC). I've struggled with this issue as well for reasons, ultimately resorting to hard coding the symbols used for console characters 1 through 31 in that JavaScript project.
This is not really an answer, but it would be too large for a comment.
The "manually adding ALT+7 to the document" part produced strange results which it should not have produced. The result should have been a single 0x07 character. It may be that your editor did something funny when you pressed ALT+7.
The problem with this kind of troubleshooting is that the tools you are working with have complex behavior that distorts the experiment. The tools also have strange modes and strange states. For example, what is the encoding of your console subsystem?
I tried this: copy con x.bat typed echo followed by Alt+7 and then Ctrl+Z and got a beeping batch file. The character looked like a bullet.
Then I tried with Alt+007 and I also got a beeping batch file, but the character was ^G now.
At the C:\> prompt, I typed echo followed by Alt+7, a bullet was also produced, but there was no beep. But an Alt+007, looking like a ^G did produce a beep. Go figure.
I would say ignore the inconsistencies that occur when you are trying to input a control character, because there is a lot of software involved in doing so which is beyond your control and apparently works in mysterious ways. (I know, not an answer.)
To beep in a cmd file :
Solution 1
C:\>rundll32 user32.dll,MessageBeep -1
Solution 2
C:\>echo ^G>beep.txt
C:\>type beep.txt
NB :
^G is obtained by pressing Ctrl+G and you can see the character by editing beep.txt
I have got 2 batch files, say A.bat and B.bat, which I need to keep open at the same time on my desktop.
When I open the batch file window, I see C:\Windows32\cmd.exe written on top of each window.
This really confuses me as to which window corresponds to which batch file.
Thus, is there a way I can display A on the window corresponding to A.bat and same for B?
I didn't get any cues on the web which brought me here.
Any assistance will be greatly appreciated.
Thanks
Make the first line of each .bat file read:
#Title %~nx0
Using a DOS batch file I'd like to display a popup window in XP and Windows 7 where I display a message and give the user the choice to press one of two buttons - one would stop the DOS batch file, while the other button would allow it to continue.
Any hint on what dos batch command/pgm I may use?
The following WSH/VBscript snippet prompts the user to click yes/no, after which you can base logic on the response:
'enter this text into ask.vbs
dim input
input = MsgBox ("Do you want to continue?", 4)
'wscript.echo input
If input = 7 Then
'answer was no
End If
If input = 6 Then
'answer was yes
End If
Then in your batch file, call wscript ask.vbs.
However, I recommend staying in pure console for this task if you can, as choice and set can handle this nicely as Anders suggests. pause works very well too, and that's usually what I use for a binary choice like yours because it's the simplest approach.
To display an actual window you would have to call something external, a .exe or a Windows Scripting Host script.
If you want to stay in pure batch, echo the choices and use SET /P to wait for input from the user. (To support DOS and Win9x you would have to use choice and not set on those systems)
Is it possible to change window title of an arbitrary window that does not belong to my application (identified by application PID or window descriptor) in KDE? If so, how can it be done?
For anyone also searching for this, the above has helped me find the way to do this from the command line...
You will need to have wmctrl installed....
From the command line this can be achieved like this:
First (optionally) list all windows:
wmctrl -l
Then, assuming you have a window called "foo this is a window bar", issuing
wmctrl -r "this is a window" -N "Full new title"
will set the title of this window to Full new title
Yes, it can be done.
Iterate over the X11 Windows and check for one with the _NET_WM_PID property set to PID, yielding the XID of the window;
then change the WM_NAME property of that window.
But note that if this _NET_WM_PID property is not set by the program on its windows, you will not be able to find the window by the PID. And note that a program may set _NET_WM_PID on all of its windows, so the result of the first step may not be a single window.
I often use the current date and time to name new folders, and I have made a program that does this (i.e. it takes one argument and then creates a new folder based on the current date and time and the argument).
I was wondering how I can make it so that I get a "New DateTime Folder" displayed in my context menu in windows explorer (just below "New Folder") and that it automatically adds the date and time in-front and allows the user to enter the name. It's actually a lot like the standard "New Folder" except instead of the default name being "New Folder" it should be "DateTime" and the text shouldn't by default be marked.
Any ideas? Thanks.
After playing around a bit I figured out a way to add a basic version of this just by editing the registry. It does not prompt for a name (It just uses a basic DD.MM.YYYY HH;MM;SS format) and does not enter explorer rename mode:
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Classes\.NewDirectoryBasedOnDate]
#="NewDirectoryBasedOnDate"
[HKEY_CURRENT_USER\Software\Classes\.NewDirectoryBasedOnDate\ShellNew]
"Command"="\"CMD\" /D /E:ON /c for /F \"tokens=1-9 delims=.,\\:/\" %%A IN (\"%%date%%.%%time%%\") DO for /F \"tokens=*\" %%a IN (\"%1\") do md \"%%~dpa\\%%A.%%B.%%C %%D;%%E;%%F\""
"nullfile"=hex:
[HKEY_CURRENT_USER\Software\Classes\NewDirectoryBasedOnDate]
"FriendlyTypeName"="Directory Based On Date"
[HKEY_CURRENT_USER\Software\Classes\NewDirectoryBasedOnDate\DefaultIcon]
#="shell32.dll,3"
[HKEY_CURRENT_USER\Software\Classes\NewDirectoryBasedOnDate\Shell\open]
"LegacyDisable"=hex:
[HKEY_CURRENT_USER\Software\Classes\NewDirectoryBasedOnDate\Shell\open\command]
#="."
I only tested this on WinXP and it is a bit of a hack (I had to add the fake Shell\open\command key for the new menu entry to show up)
By changing the command to wscript.exe //nologo "C:\path\to\NewDateDir.wsf" "%1" and saving the following code in NewDateDir.wsf you end up with this:
<?xml version="1.0" ?><job><script language="VBScript"><![CDATA[
if WScript.Arguments.Count < 1 then
MsgBox("Bad parameter!")
WScript.Quit(1)
end if
Set FSO=CreateObject("Scripting.FileSystemObject")
Function StrFilter(s,ch,rep)
StrFilter=Join(Split(s,ch,-1),rep)
End Function
basedir=FSO.GetParentFolderName(WScript.Arguments(0))
defname=Date&" "&Time
defname=StrFilter(defname,"/",".")
defname=StrFilter(defname,":",";")
name=InputBox("New folder in "&basedir,"New folder",defname)
if not IsEmpty(name) and Len(name) > 0 then
FSO.CreateFolder(FSO.BuildPath(basedir,name))
end if
]]></script></job>
Even if you decide to write a shell extension I think activating explorers rename mode is going to be hard, especially if you want partial selection. You also have to remember that other programs might implement shell context menus so you can't use all kinds of undocumented explorer stuff.
You have to implement a shell extension, in particular a context menu. Here is a pretty good walk-through on how to do it. There is also some lower-level documentation on MSDN here (for context menus in particular) and here (for shell extensions in general). For your particular case I think you would register you shell extension under the "Directory\Background" key.