Hello, I was wondering if you would be able to assist me in how to write information to an html webpage using a line in windows powershell. I am able to do this by writing in notepad, but i am trying to automate a login process to a webpage and would like to select the textbox by its html id tag. Thank you!
↧
New Post: Write to a textbox by html id
↧
New Post: Write to a textbox by html id
Windows automation can't, in general, see the html tags. You need to get into web automation directly for that (my suggestion would be selenium there's an interesting "port" to PowerShell here on CodePlex (I haven't tried it yet, but it looks : https://sepsx.codeplex.com/
↧
↧
New Post: Unable to resize Microsoft Management Console (MMC) window
Hi,
I am using following command to maximize an MMC window.
"Select-Window -ProcessName mmc | Set-WindowActive | Set-WindowPosition -maximize"
The window becomes active but does not maximize.
Below are the details of the window.
ProcessName : mmc
ProcessId : 4240
IsActive : False
Handle : 5374370
Title : Console1 - [Console Root]
Class : MMCMainFrame
It would be great if anyone has solution to this issue
I am using following command to maximize an MMC window.
"Select-Window -ProcessName mmc | Set-WindowActive | Set-WindowPosition -maximize"
The window becomes active but does not maximize.
Below are the details of the window.
ProcessName : mmc
ProcessId : 4240
IsActive : False
Handle : 5374370
Title : Console1 - [Console Root]
Class : MMCMainFrame
It would be great if anyone has solution to this issue
↧
New Post: Unable to resize Microsoft Management Console (MMC) window
Your console window has to be elevated to control elevated windows.
That is, MMC always runs elevated ("as administrator"), and although you can find it and set it active, you can't position it or send keys to it etc unless you're also elevated.
That is, MMC always runs elevated ("as administrator"), and although you can find it and set it active, you can't position it or send keys to it etc unless you're also elevated.
↧
New Post: Unable to resize Microsoft Management Console (MMC) window
Thanks Jaykul, that solved the issue.
↧
↧
New Post: No updates in three years?
Jaykul wrote:
What's the difference and relationship between WASP and UI Automation?
Of course it's not "dead" -- I still answer questions here in the forum all the time, and as you can see, there are no outstanding feature requestsHi, I can't quite understand your meaning:
Why are you dredging up ancient threads and discouraging people from using it?
For what it's worth, all active development has been done on the "UI Automation" module on PoshCode.org, and therefore hasn't shown up as checkins here. You are, of course, free to check out the alternative UI Automation module from xinliu here on codeplex -- especially you, togakangaroo :-P
What's the difference and relationship between WASP and UI Automation?
↧
New Post: No updates in three years?
The System.Windows.UIAutomation namespace in .Net enables automation similar to what WASP does.
I wrote a Script Module based on System.Windows.UIAutomation (aka SWA, aka UIAutomation) and posted it to PoshCode, and that's where the current development has been. It's past time I posted it here, of course, because it's just about ready for real use and probably needs beta testers more than anything else.
The cool thing about using SWA is that I don't have to provide a binary module, because the stuff that's necessary is built into the .Net Framework. The frustrating thing about it is that it is designed for systems and developers that think differently than PowerShell normally does, and every time I've tried to make it fit the PowerShell model better I've come up short ;-)
I wrote a Script Module based on System.Windows.UIAutomation (aka SWA, aka UIAutomation) and posted it to PoshCode, and that's where the current development has been. It's past time I posted it here, of course, because it's just about ready for real use and probably needs beta testers more than anything else.
The cool thing about using SWA is that I don't have to provide a binary module, because the stuff that's necessary is built into the .Net Framework. The frustrating thing about it is that it is designed for systems and developers that think differently than PowerShell normally does, and every time I've tried to make it fit the PowerShell model better I've come up short ;-)
↧
New Post: No updates in three years?
Thank you for your detail.
↧
New Post: Need help to make WASP module "ultra-portable"
I'm not sue how other people use WASP; but, I'm trying to find out how to run my my WASP-dependent scripts on any Win7/win8 PC; even if it doesnt have WASP module already installed.
An Internet based packaging installer wouldn't really work since some PCs may not have Internet access.
I have considered to use "System.Windows.UIAutomation" from within PowerShell; so there's no dependency for WASP at all; but, unfortunately it t looks like accessing .NET functionality via Powershell isn't very intuitive. I haven't been able to find sample Powershell scripts which clearly demonstrate how to the basic common automation tasks below via .NET. I wasn't able to figure out how to do it by looking at the WASP module code unfortunately.
Any useful help would be greatly appreciated!
An Internet based packaging installer wouldn't really work since some PCs may not have Internet access.
I have considered to use "System.Windows.UIAutomation" from within PowerShell; so there's no dependency for WASP at all; but, unfortunately it t looks like accessing .NET functionality via Powershell isn't very intuitive. I haven't been able to find sample Powershell scripts which clearly demonstrate how to the basic common automation tasks below via .NET. I wasn't able to figure out how to do it by looking at the WASP module code unfortunately.
- Minimize Window (title or process)
- Maximize Window (title or process)
- Resize Window (title or process)
- Hide Window (title or process)
- Activate Window (title or process)
-
Sendkey special characters such Windows-logo-Key+CTRL+ALT+F8
Any useful help would be greatly appreciated!
↧
↧
New Post: Need help to make WASP module "ultra-portable"
If you want something really minimal, you need to use the pure-script WASP 2 module.
The module is still in beta, and the PoshCode installer is still in beta (and may not work on PS2 at all), but you can try this command:
If you get timeouts (command not found) trying to execute off the WebDAV share, you can try the steps in kb2445570 or you can download the Install.ps1 scripts and the http://poshcode.org/Modules/WASP-2.0.0.6.psmx (which is a windows Package file -- you can actually just rename it to zip and then unzip and find the "WASP" module folder and install it manually instead of using the Install.ps1)
Anyway, I haven't uploaded the source to WASP 2 here because I'm still not happy with the command surface, it includes stuff like the horribly un-powershelly:
Invoke-Window.SetWindowVisualState -State Minimized
But you can probably work with it anyway, and presumably you'll be able to figure out how to min/max/resize/focus just by looking at the commands that are exported from the module.
You cannot send "Win" with the Send-Keys or Send-UIKeys, they're based on System.Windows.Forms.SendKeys, but the rest of it is documented there. Having said that, I'd argue there isn't anything you should need to automate with the Win key that you can't automate some other way ;-)
I've been meaning to migrate the Send-UIKeys to use InputSimulator but haven't gotten around to it. That one can definitely send the logo key, etc.
The module is still in beta, and the PoshCode installer is still in beta (and may not work on PS2 at all), but you can try this command:
\\PoshCode.org\Modules\Install \\PoshCode.org\Modules\WASP.psd1
Anyway, I haven't uploaded the source to WASP 2 here because I'm still not happy with the command surface, it includes stuff like the horribly un-powershelly:
Invoke-Window.SetWindowVisualState -State Minimized
But you can probably work with it anyway, and presumably you'll be able to figure out how to min/max/resize/focus just by looking at the commands that are exported from the module.
You cannot send "Win" with the Send-Keys or Send-UIKeys, they're based on System.Windows.Forms.SendKeys, but the rest of it is documented there. Having said that, I'd argue there isn't anything you should need to automate with the Win key that you can't automate some other way ;-)
I've been meaning to migrate the Send-UIKeys to use InputSimulator but haven't gotten around to it. That one can definitely send the logo key, etc.
↧
New Post: Write to a textbox by html id
If you use Internet Explorer Automation interface, it is possible, but I never tried with any other Browser's API. Here is Powershell method:
$ie = New-Object -ComObject "InternetExplorer.Application"
$ie.Visible=1
$ie.Navigate("C:\MyPage.htm")
$txtArea=$ie.Document.getElementById("MyTextBox") #assuming that your TextBox Id is 'MyTextBox'
$txtArea.InnerText="Hello world"
$txtArea.Value="My Value"
Hope this helps↧
New Post: WASP send-click challenges
I am having challenges with WASP send-click. The demo script below shows the challenges. Firefox will accept the click on the File menu, but not the click on the main web page display. IE & Chrome ignore the clicks. Notepad ignores the click on the File menu, but does correctly click on the main edit area, select all text and copy it to the window clipboard. Any and all suggestions would be appreciated.
# Initialization
Import-Module c:\wasp\wasp.dll
Add-Type -Assembly System.Windows.Forms
clear-host
$str = "the quick brown fox`njumped over the lazy dog`n"
# Set up apps to test.
$app_list = $MyInvocation.UnboundArguments
if (!$app_list) {
$app_list = "firefox", "iexplore", "chrome", "notepad"
}
# Main loop
foreach ($app in $app_list) {
# Set coordinates to click on for the app.
switch ($app) {
chrome {
$x1 = 20 # Apps button location
$y1 = 80
$x2 = 100 # main web page display
$y2 = 150
}
iexplore {
$x1 = 20 # File menu location
$y1 = 80
$x2 = 100
$y2 = 200
}
firefox {
$x1 = 20 # File menu location
$y1 = 35
$x2 = 100 # main web page display
$y2 = 150
}
notepad {
$x1 = 20 # File menu
$y1 = 35
$x2 = 40 # 3rd line of main editing window
$y2 = 100
# send-keys -window $h -keys "$str $str $str $str"
}
default {
"ERROR: unknown app=$app"
continue
}
}
"app=$app x1=$x1 y1=$y1 x2=$x2 y2=$y2"
# Start the application, get the window object, save object parms.
start-process -filepath "$app"
start-sleep -s 5
if ($app -eq "iexplore") {
$w = select-window -title *explorer*
} else {
$w = select-window -title *$app*
}
$w = $w | select-object -first 1
$h = $w.handle
$p = $w.processid
$t = $w.title
"app=$app h=$h p=$p t=$t"
# If no window handle found, complain and move on.
if (!$h) {
"ERROR: app=$app got null handle"
continue
}
# Get window position and mouse offsets.
$pos=Get-WindowPosition $h
$l = $pos.Location
$x_off = $l.X
$y_off = $l.Y
"pos=$pos offset x=$x_off y=$y_off"
# Move mouse, then click on first location.
[System.Windows.Forms.Cursor]::Position = New-Object System.Drawing.Point(($x_off + $x1), ($y_off +$y1))
start-sleep -s 1
send-click -left $x1 -top $y1 -window $h -button left
# Wait, then close first menu
start-sleep -s 3
send-keys -window $h -keys "{Esc}"
# Add text for notepad window
if ($app -eq "notepad") {
send-keys -window $h -keys "${str}${str}${str}${str}${str}${str}${str}${str}"
}
# Move mouse, then click on second location.
start-sleep -s 1
[System.Windows.Forms.Cursor]::Position = New-Object System.Drawing.Point(($x_off + $x2), ($y_off +$y2))
send-click -window $h -left $x2 -top $y2 -button left
# Try to select all text & copy it.
start-sleep -s 1
send-keys -window $h -keys "^a"
start-sleep -s 1
send-keys -window $h -keys "^c"
# Get rid of app & window.
"stopping $app"
start-sleep -s 1
stop-process -id $p -force
start-sleep -s 5 # wait for stop to take effect
}
↧
New Post: WASP send-click challenges
Short version (let me know if you need more, but I'm on my way out of the office):
You should try not to automate base on mouse clicks unless you can't avoid it -- mouse clicks automation is the most fragile: it breaks when resolution changes, or font-sizes change, and whenever things are moved on a UI even by just a few pixels. Use keystrokes (Alt+* hotkeys) for menus and buttons whenever possible. This is something that the new module is much better about, since it gives you Invoke-* cmdlets for stuff like buttons and menus...
Additionally, you shouldn't really drive browser automation with generic automation tools -- you need something that gets into the page and lets you automate based on the rendered DOM. My choice for browser automation is Selenium. I've done some work with Selenium in PowerShell using the WebDriver apis (I wrote a blog post and posted something to PoshCode, I think) and there's a project here on CodePlex (SePx? SePs? something like that) which claims to be a full port for PowerShell (I haven't tried that).
You should try not to automate base on mouse clicks unless you can't avoid it -- mouse clicks automation is the most fragile: it breaks when resolution changes, or font-sizes change, and whenever things are moved on a UI even by just a few pixels. Use keystrokes (Alt+* hotkeys) for menus and buttons whenever possible. This is something that the new module is much better about, since it gives you Invoke-* cmdlets for stuff like buttons and menus...
Additionally, you shouldn't really drive browser automation with generic automation tools -- you need something that gets into the page and lets you automate based on the rendered DOM. My choice for browser automation is Selenium. I've done some work with Selenium in PowerShell using the WebDriver apis (I wrote a blog post and posted something to PoshCode, I think) and there's a project here on CodePlex (SePx? SePs? something like that) which claims to be a full port for PowerShell (I haven't tried that).
↧
↧
New Post: WASP send-click challenges
Thanks for the info on upcoming WASP2. I fully agree that using X,Y mouse coordinates is a very fragile automation approach, but sometimes its the only way. I had that experience several years back using the Network Automation tool set. I am trying to understand what I can and cant do with WASP. I will make use of hot keys as much as possible, and will check out the other tools you mentioned. Thanks again!
↧
New Post: Wasp support in Powershell 3
I noticed a earlier question about WASP Support in Powershell 3. I get the same error but since the question is dated I thought I would ask if the answer given to it is the same. Here is my error
Import-Module : Could not load file or assembly 'file:///C:\Users\SAM\Documents\WindowsPowerShell\Modules\WASP\WASP.dll' or one of its
dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)
Import-Module : Could not load file or assembly 'file:///C:\Users\SAM\Documents\WindowsPowerShell\Modules\WASP\WASP.dll' or one of its
dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)
↧
New Post: Wasp support in Powershell 3
It's probably "blocked" because of how you downloaded it (with a browser) -- use Unblock-File (or if that's not a command (I can't remember what version that got added in), you'll have to right-click the file and view properties and unblock it there).
↧
New Post: Wasp support in Powershell 3
That was it! Thanks.
↧
↧
New Post: Focus
I am sorry to have to ask something else but I am kind of stuck. I have been playing with WASP and found that when I build my script in the ISE that it works just how I want when i run it. However when I try to launch the same script from say "powershell c:\myscript.ps1 the command window comes up but stays in the foreground and is not yielding focus to the windows launched by the script. Suggestions?
↧
New Post: Focus
Nevermind it was fluke, its working right now.
↧
New Post: Taskbar
Ok, I have been working on this and I am looking for ideas. I have a series of programs that I have launched and minimized and want to script the closing of these with WASP because when they are launched there are key presses to start and when they are closed there are key presses to ensure that they close. However since WASP can only effect windows that are either open or up and in the background I am looking for a way to just send a command or something to the minimized window to get it back where I can manipulate it.
I tried
Select-Window explorer | Set-WindowActive | Send-Keys '%{TAB}'
With mixed results, some times it brings up some of the windows, others it does nothing.
Since there is no windows key or space bar key press shortcuts for WASP it makes it a little bit more difficult.
I saw reading through the discussions that there was a way to access the system tray, is there a similar way to access the taskbar?
I tried
Select-Window explorer | Set-WindowActive | Send-Keys '%{TAB}'
With mixed results, some times it brings up some of the windows, others it does nothing.
Since there is no windows key or space bar key press shortcuts for WASP it makes it a little bit more difficult.
I saw reading through the discussions that there was a way to access the system tray, is there a similar way to access the taskbar?
↧