I need to open URL in Microsoft Edge (on Windows 10). When I invoke
start shell:AppsFolder\Microsoft.MicrosoftEdge_8wekyb3d8bbwe!MicrosoftEdge http://www.google.com
then Microsoft Edge is started correctly but it doesn't open the given URL (www.google.com, in this case). It opens Bing search where the given URL is used as a search term instead.
The following method should work via Command Prompt (cmd):
start microsoft-edge:http://www.cnn.com
Windows 10: Create a shortcut with this destination:
%windir%\system32\cmd.exe /c "start microsoft-edge:https://twitter.com"
and a shortcut:
C:\Windows\System32\cmd.exe /c start shell:AppsFolder\Microsoft.MicrosoftEdge_8wekyb3d8bbwe!MicrosoftEdge http://localhost:6516
I too was wondering why you can't just start microsoftedge.exe, like you do "old-style" applications in windows 10. Searching the web, I found the answer -- it has to do with how Microsoft implemented "Universal Apps".
Below is a brief summary taken from that answer, but I recommend reading the entire entry, because it gives a great explanation of how these "Universal Apps" are being dealt with. Microsoft Edge is not the only app like this we'll be dealing with.
Here's the link: http://www.itworld.com/article/2943955/windows/how-to-script-microsofts-edge-browser.html
Here's the summary from that page:
"Microsoft Edge is a "Modern" Universal app. This means it can't be opened from the command line in the traditional Windows manner: Â Executable name followed by command switches/parameter values. But where there's a will, there's a way. In this case, the "way" is known as protocol activation."
Kudos to the author of the article, Stephen Glasskeys.
All the other solutions work for Microsoft Edge (legacy) and on Windows 10 only.
As of 2020, it will be discontinued and replaced by Microsoft Edge (Chromium based).
The solution that works with the new Edge on Windows 7, 8 and 10 is :
start msedge URL
Source :
https://en.wikipedia.org/wiki/Microsoft_Edge#Anaheim_(2019%E2%80%93present)
https://learn.microsoft.com/en-us/deployedge/microsoft-edge-sysupdate-windows-updates
While the accepted answer is correct, it has the unwanted artifact of flashing a console window when running from a non-console application.
The solution I found works best, which is only mentioned here in a comments to the question, is the following command line:
explorer.exe "microsoft-edge:<URL>"
Keep in mind that if contains the % sign you will need to type %% as Windows uses the symbol for variable expansion.
Hope someone finds this helpful.
Personally, I use this function which I created and put in my profile script ...\Documents\WindowsPowerShell\….profile, feel free to use it. As I am from the UK, I prefer to go to .co.uk where possible, if you are from another area, you can add your own country code.
# Function taking parameter add (address) and opens in edge.
Function edge {
param($add)
if (-not ($add -contains "https://www." -or $add -contains "http://www.")) {
if ($add[0] -eq "w" -and $add[1] -eq "w" -and $add[2] -eq "w") {
$add = "https://" + $add
} else {
$add = "https://www." + $add
}
}
# If no domain, tries to add .co.uk, if fails uses .com
if (-not ($add -match ".co" -or $add -match ".uk" -or $add -match ".com")) {
try {
$test = $add + ".co.uk"
$HTTP_Request = [System.Net.WebRequest]::Create($test)
$HTTP_Response = $HTTP_Request.GetResponse()
$add = $add + ".co.uk"
} catch{
$add = $add + ".com"
}
}
Write-Host "Taking you to $add"
start microsoft-edge:$add
}
Then you just have to call: edge google in powershell to go to https://www.google.co.uk
I would like to recommend:
Microsoft Edge Run Wrapper
https://github.com/mihula/RunEdge
You run it this way:
RunEdge.exe [URL]
where URL may or may not contains protocol (http://), when not provided, wrapper adds http://
if URL not provided at all, it just opens edge
Examples:
RunEdge.exe http://google.com
RunEdge.exe www.stackoverflow.com
It is not exactly new way how to do it, but it is wrapped as exe file, which could be useful in some situations. For me it is way how to start Edge from IBM Notes Basic client.
Looks like things have changed and the previous solution doesn't work anymore.
However, here is the working command to launch CNN.com on Microsoft Edge:
microsoft-edge:http://www.cnn.com
I want to complement other answers here in regards to opening a blank tab in Microsoft Edge from command-line.
I want to add an observation from my end. Windows doesn't detect the command microsoft-edge if I remove the trailing colon. I thought colon would be required only when I've to provide the target URL to open e.g. when I've to open a blank tab. But that's not the case. Color (:) is required all the time.
How to open a blank tab in Microsoft Edge?
From Run prompt (press Window logo + R):
microsoft-edge:about:blank
microsoft-edge:
msedge
From Command(cmd.exe) prompt:
start microsoft-edge:about:blank
start microsoft-edge:
start msedge
You can also initiate a search using Edge from run prompt. Let's say I've to search Barack Obama then fire below command on run prompt-
microsoft-edge:Barack Obama
It starts Microsoft's Bing search website in Edge with Barack Obama as search term.
It will do more or less the same thing in good old dos script fashion
set add=%1
if %add%$ ==$ set add="about:blank" && goto launch
rem http://
set test=%add:~0, 7%
if %test% == http:// goto launch
rem ftp://
set test=%add:~0, 6%
if %test% == ftp:// goto launch
rem https://
set test=%add:~0, 8%
if %test% == https:// goto launch
rem add http
set add=http://%add%
:launch
start microsoft-edge:%add%
microsoft-edge:http://google.com (open google as desired)
microsoft-edge: (just open)
Related
I've recently installed arbtt which seems to be an intersting, rule based, automatic time tracker. http://arbtt.nomeata.de/#what
I've got it working for the most part, but after 30 minutes or so of gathering stats, I end up with the following error.
Processing data [=>......................................................................................................................................................................................] 1%
arbtt-stats: Prelude.(!!): index too large
Does anyone have any suggestions on ways I can troubleshoot this issue, or better yet, solve it? I have 0 experience with the coding language used to create the rules (Haskell I believe). All I've done to this point is follow the documentation as closely as possible.
This error ultimately renders the tool useless since it doesn't gather data any longer than 30 minutes. To fix it, I have to delete the log and start from scratch. I'm primarily interested in the notion of having a customizable, rule based time tracker but I'm by no means tied to using arbtt.
Based on the comments below, I'm including some more information below.
When I try to run arbtt-recover I get a long list of errors that look like this. All of them seem to be related to an Unsupported TimeLogEntry.
Trying at position 1726098.
Failed to read value at position 1726098:
Unsupported TimeLogEntry version tag 0
As for the configuration file, here is what I have so far.
$idle > 30 ==> tag inactive,
-- A rule that matches on a list of strings
current window $program == ["Chrome", "Firefox"] ==> tag Web,
current window $program == ["skype"] ==> tag Skype,
current window $program == ["jetbrains-phpstorm"] ==> tag PhpStorm,
( current window $title =~ m!Inbox! ||
current window $title =~ m!Outlook! ) ==> tag Emails,
( current window $title =~ m!AdWords! ||
current window $title =~ m!Analytics! ) ==> tag Adwords,
It goes on further, but I'm fairly confident I've followed this same syntax for all other lines. The rest of the lines are following the same format but are project/client specific for me. If required, I'm happy to include the rest of the file.
As discussed in the comments: This is a case of a corrupt ~/.arbtt/capture.log. You can usually fix this by
running arbtt-recover
and then moving ~/.arbtt/capture.log.recovered to ~/.arbtt/capture.log.
The second manual step is required to avoid accidentially deleting too much data. You can test that the recovered file is better by making arbtt-stats using the recovered file by passing --logfile=~/.arbtt/capture.log.recovered to it.
Data corruption happens for example when there is an unclean shutdown, or other undetermined reasons. But the log file format is such that even after a corruption (e.g. a partial write of one sample), further samples will be written correctly and should be picked up by arbtt-recover, so you did not lose more than a few samples.
I'm stuck on a roadblock with the simplest of things. In Drupal 6, I'm trying to take a user-entered path to an image and output that image to the page. Here's a bit of code:
$slogan_image = theme('image', $slogan_image_path);
dpm("\$slogan_image_path = '$slogan_image_path'");
dpm("\$slogan_image = '$slogan_image'");
The devel output reads:
$slogan_image_path = '/sites/default/files/images/Family.jpg'
$slogan_image = ''
There is an image at '/sites/default/files/images/Family.jpg'; if I browse to www.mysite.com/sites/default/files/images/Family.jpg, the image will be displayed.
What am I doing wrong? Thanks.
The problem was that my path began with a slash. Drupal paths don't have that initial slash. Drupal being open source, I could look refer to the Drupal 6 api docs and see the code for theme_image included this line:
$url = (url($path) == $path) ? $path : (base_path() . $path);
showed me that Drupal would prepend my path with the base_path(). Executing that code myself, in an Execute PHP page, allowed me to see that theme_image would wind up using //sites/default/files/images/Family.jpg as the $url, clearly an illegal value.
I thought I'd append this short explanation to my trivial problem to help rank beginners see how I debugged it.
I've got my computer(Windows 7) hooked up to the TV, and i very often change output device for sound between Digital Audio (S/PDIF)(High definition audio device) and my headset (2- Corsair CA-HS1 USB Headset)
I wanna be able to execute a batch/script file who changes this for me so i don't have to "right click volume > playback devices > "Mark output device" and click "set default".
I know it's a luxury problem, but hey, maybe I can learn something from someone?
All help appreciated!
This is how I set 'Line 1' as the playback device:
start /min "" G:\......\nircmd.exe setdefaultsounddevice "Line 1"
NirCmd is a small command-line utility which you can download that allows you to do some useful tasks without displaying any user interface.
I had the exact same requirement as yourself, and AFTER stumbling across your posting I found the following:
https://web.archive.org/web/20131231034118/http://downloadsquad.switched.com/2010/06/16/windows-7-tip-how-to-change-the-default-audio-device-with-a-hot/
Unfortunately it's not a native Windows function; it requires the download of a small open-source scripting tool called AutoHotKey, but it works nicely and only requires a small amount of memory (1 ~ 2.5Mb)
The script provided in the original article doesn't work for me. It's searching for Enabled/Disabled devices and changing that value, as opposed to changing the default device.
I've edited it to switch between 2 default devices now.
It works by opening your Sound control panel (mmsys.cpl), then scrolling down the list of playback devices to the second item in the list (that's the {Down 2} part).
This is because my Speakers are the second item in my list.
It then checks to see if the device is default or not. If not, it sets it as the default and closes the window. If it's already the default, it scrolls down another 2 times and sets that as the default.
So, you'll need to ammend the {Down 2} lines to fit your own list of devices.
#+a::
Run, mmsys.cpl
WinWait,Sound
ControlSend,SysListView321,{Down 2}
ControlGet, selectedDevice, List, Focused, SysListView321
Loop, Parse, selectedDevice, %A_Tab%
if a_index <> 3
continue
else
{
if A_LoopField <> Default Device
{
ControlClick,&Set Default
ControlClick,OK
WinWaitClose
SoundPlay, *-1
return
}
else
{
ControlSend,SysListView321,{Down 2}
ControlClick,&Set Default
ControlClick,OK
WinWaitClose
SoundPlay, *-1
return
}
}
To follow up on Dale Newton's post, NirCmd is a great way to do this. On top of that if you pair it with AutoHotKey you can create an executable that will change your devices without opening pesky CMD windows every time you run it. For example, I have two sources that I switch between all the time, one is my headphones and they other is my monitor. For my monitor I created an ahk script that does this:
#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir% ;I have nircmd in the same folder as these scripts
Run, nircmd setdefaultsounddevice "Acer X34-8" 1
Run, nircmd setdefaultsounddevice "Acer X34-8" 2
And another for my headphones with the last two lines changed to:
Run, nircmd setdefaultsounddevice "Headset Earphone" 1
Run, nircmd setdefaultsounddevice "Headset Earphone" 2
Afterwards you can compile each ahk script into an exe and bind each exe to a keyboard macro so you can execute them with a couple key presses. Personally I am using a Corsair K95 so I use their software to bind these to my 'G' keys.
Also to note, if you are in your sound preferences you can rename any of the devices to avoid naming conflicts.
I had a HDMI device that keeps changing it's name, so none of the existing solutions worked for me.
I eventually ended up with this powershell and use of the NirCmd app.
#File: TV.ps1
$name = "SMART*"
# list active audio playback devices. (Note for cature devices change Render to Capture)
$device = Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\MMDevices\Audio\Render\*\" | where {$_."DeviceState" -eq 1} | foreach-object -Process {(Get-ItemPropertyValue -Path ($_.PSPath + "\Properties\") -Name "{a45c254e-df1c-4efd-8020-67d146a850e0},2")} | Where-Object {$_ -like $name}
C:\bin\NIRCMDC setdefaultsounddevice $device 1
C:\bin\NIRCMDC setdefaultsounddevice $device 2
As far as I understand there is no way to do this programmatically. This is a deliberate design, since Microsoft does not want applications to override audio setting set by user.
You will find same answer here but if you solutions that manipulate windows you can have a look here.
The following script is written in Windows 7 and uses sendkeys. It is based on other snippets I found but adds to them to ensure selection is consistent and stray windows are not left displayed.
You may want to adjust SleepTime for your system if it still plays up.
Call the script using a shortcut with the index of the item you wish to select in the Playback Devices window as first parameter.
You can create a new 'toolbar' on your 'taskbar' to select each device with a single click:
Taskbar toolbar picture
'===============================================================================
'This script uses sendkeys to select the Sound Output device
'First parameter should be the desired device number in 'Playback Devices' list
'===============================================================================
Option Explicit
Const SleepTime = 200
Dim WindSh
'===============================================================================
'MAIN ROTUINE
'===============================================================================
'Check the command line input
if ( Wscript.Arguments.Count <> 1) then
MsgBox "You must provide a single integer argument representing the device number", vbinformation + vbokonly, Wscript.ScriptName
Wscript.Quit 1
elseif ( false = IsNumeric( Wscript.Arguments.Item(0) ) ) then
MsgBox "The argument provided was not an integer number: " & Wscript.Arguments.Item(0), vbinformation + vbokonly, Wscript.ScriptName
Wscript.Quit 2
End If
set WindSh = CreateObject("Wscript.Shell")
WindSh.run("control.exe mmsys.cpl")
do while (WindSh.AppActivate("Sound") = false)
WScript.Sleep SleepTime
loop
WindSh.sendkeys("{DOWN " & Clng( Wscript.Arguments.Item(0) ) & "}")
WScript.Sleep SleepTime
WindSh.sendkeys("{TAB 2}")
WScript.Sleep SleepTime
WindSh.sendkeys("{ENTER}")
WScript.Sleep SleepTime
WindSh.sendkeys("%{F4}")
WScript.Sleep SleepTime
if (WindSh.AppActivate("Sound") = true) then
WindSh.sendkeys("%{F4}")
end if
Might not be related to switching the audio device around via script, but I also have my computer hooked up to my TV via HDMI.
When I want to watch video files on the TV I use Media Player Classic Home Cinema - this lets me specify the audio device for MPH:HC in the options without switching over my default sound device on the entire computer.
If your usage is similar to mine maybe MPC:HC will solve your problem for you.
Note that if you use nircmd setdefaultsounddevice speakers in an enterprise or educational environment login script, the sound will still come out from the speakers when headphones are plugged in.
This feels like it should be pretty easy but I can't find documentation on how to do this:
I just want Sikuli to type Ctrl+C to copy text to the clipboard.
type(KEY_CTRL+'c') doesn't work and neither does type(KEY_CTRL,'c').
Any suggestions?
Try using type("c",KEY_CTRL) instead.
I wrote a simple script which types a line in notepad, double clicks it to mark it and then ctrl+x ctrl+v it into the document again. Works great.
openApp("notepad.exe")
find("textfield.png" )
type("Some text")
doubleClick("theText.png")
type("x", KEY_CTRL)
click("theTextField.png" )
type("v",KEY_CTRL)
The following works in 0.9 and newer versions of sikuli
type('x', KeyModifier.CTRL)
Key objects are defined for pretty much all the modifier keys and num pad keys. Anyways, it should look something like this
keyDown(Key.CTRL)
type('c')
keyUp(Key.CTRL)
The usage of type() and the possible key names are documented here:
http://doc.sikuli.org/region.html#Region.type
http://doc.sikuli.org/keys.html#key-constants
As others have mentioned, use the following:
type('c', Key.CTRL) # Copy command
One point worth mentioning - do not use upper-case characters, i.e.:
type('C', Key.CTRL) # Does not copy, avoid this
I haven't looked into the Sikuli source code, but my best guess is that it implicitly sends this as Shift+C, which results in a different command entirely.
type('x', Key.CTRL) also works.
Also, make sure that NUM_LOCK is off. If NUM_LOCK is on, it can make anything with KeyModifier.CTRL or KeyModifier.SHIFT misbehave.
You can try next code:
keyDown(Key.CTRL)
type("c")
keyUp(Key.CTRL)
I had a requirement to automate a flash content. The following code worked for me.
These were the following steps I ahd to perform as a part of the automation:
Enter Username and Password
Click on Login Button
Click on the button which will navigate to the application
The challenge I faced was to focus on the Username and password which had no placeholders . Hence the focusing was difficult. So I used the CTRL keys to do this .
Pattern appLogo = new Pattern("C:\\images\\appLogo.png");
StringSelection userNameText = new StringSelection("username");
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(userNameText, null);//Copy the text into the memory
Screen s = new Screen();
s.find(appLogo);
s.click(appLogo);
s.type(Key.TAB);//I had to enter tab twice to focus on user name textbox
s.type(Key.TAB);
s.type("V",KeyModifier.CTRL);
StringSelection password = new StringSelection("password");
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(password, null);
s.type(Key.TAB);//I had to enter tab twice to focus on user name textbox
s.type("V",KeyModifier.CTRL);
Pattern loginButton = new Pattern("C:\\images\\Login.png");
s.find(loginButton);
s.doubleClick(loginButton);
The scenario is like i need to press say key E in my keyboard after finishing the test how to add this in the script in Sikuli IDE.
I tried everything possible, but still failed. I thought I got it at the point which I'll post
as my final attempt, but still isn't good [enough].
A script is being passed three arguments. Domain name, username and password.
But the probles is that I need domain separated in "domain" + ".com" format. Two variables.
I tried to split it using name.extension cheat, but it doesn't work quite well.
Check the simple code:
#echo off
echo.
set domain=%~n1
set ext=%~x1
echo %DOMAIN%
echo %EXT%
echo.
When you try it, you get:
D:\Scripts\test>test.bat domain.com
domain
.com
D:\Scripts\test>test.bat domain.co.uk
domain.co
.uk
First obviously does work, but only because I'm able to cheat my way through.
String operations in DOS Shell are a pain in the ass. I might be able to convince
a script writer to pass me 4 arguments instead of 3... but in case that fails... HELP!
Windows ships with the Windows Scripting Host which lets you run javascript.
Change the batch file to:
#echo off
cscript //Nologo test.js %*
Create test.js:
if (WScript.Arguments.Length > 0) {
var arg = WScript.Arguments.Item(0);
var index = arg.indexOf('.');
if (index != -1) {
var domain = arg.substring(0, index);
var ext = arg.substring(index);
WScript.Echo(domain);
WScript.Echo(ext);
} else WScript.Echo("Error: Argument has no dots: " + arg);
} else WScript.Echo("Error: No argument given");
And you can use it:
C:\Documents and Settings\Waqas\Desktop>test.bat domain.com
domain
.com
C:\Documents and Settings\Waqas\Desktop>test.bat domain.co.uk
domain
.co.uk
And that does what I think you wanted.
If you want to automatize something (as stated in another answer), my solution would be to use appropriate tools. Install a Perl runtime or something else you're comfortable with. Or use the Windows power shell
Also, unless you supply your script with a list of valid top level domains, there is NO WAY, in no language, that your script can decide whether test.co.uk should be splitted as text and co.uk or test.co and uk. The only feasible possibility would be to make sure that you get only second-level-domains without sub-domain parts. Simply split at the first dot in that case.
BTW: I'm curious to why you would want to automate website creation in a Windows shell script. You aren't doing anything nasty, are you?