Powershell: How to open a file from a separate window - file

I'm using PowerShell for about a week now. I am able to open a specific URL and fill in my username and password automatically. I can also navigate to a certain page where multiple files can be found to download.
I use the following command to select a certain file to download:
$ie.navigate2('http://www.example.com/resource.aspx?ResourceID=GetDocStoreFile&EntryID=1234')
What happens next is that a second window will open, named "file download". There are three buttons: open, save and close.
I don't want to press the "open" button manually, but would like the script to do that for me and then goes back to the original window to select another file. Any suggestions?

If you use a download URL, I don't think you can interact directly with IE using the COM object, because there's no document. Once the dialog box opens, all of the object's properties become null. You can use the method I posted here: How to perform keystroke inside powershell? AppActivate will work to activate a dialog box by title.
The % represents the the ALT key, so if the underlined letter of the button you want to click is O, you'd invoke SendKeys like this:
$wshell.SendKeys('%O')

Related

Change the default value of the "Startup directory for new process" in the "Create new console" dialog

How do we change the default value for the Startup directory for new process? Out of the box the default is my user directory C:\Users\bigfo.
My current workaround is to change the {Bash::bash} task so that it overrides whatever is in the Create new console dialog. I do that like this:
set "PATH=%ConEmuBaseDirShort%\wsl;%PATH%" & %ConEmuBaseDirShort%\conemu-cyg-64.exe --wsl -cur_console:pm:/mnt -new_console:d:C:\dev
What I would really like, though, is for the Create new console dialog to look like this:
conemu & cmder default startup locations:
there are actually two answers for this question depending on what you
really want to do. i will list both:
the global default startup path
for all tasks this is set at launch time from the cli or, more commonly, the
windows startup link from the start menu or taskbar. in either case,
you can edit this from the default, which is typically set to the install
folder.
if changing a start menu link, begin at the desktop, press oskey to bring
up the start menu. assuming cortana is active, you can simply search for
cmder by typing it out. if not, you will have to scroll down to find your
link to cmder or conemu.
right-click on the icon, select open file location from the context menu.
after windows explorer opens, the shortcut to the program will be
highlighted. right-click this shortcut and select properties from the context
menu.
note: it is possible that the application location rather than a
shortcut will be highlighted. if it is an application, right-click the
program and select pin to taskbar from the context menu. then skip down
to the part about setting the taskbar shortcut default folder.
it is also possible to select pin to start menu but this method requires
that you then navigate to
\programdata\microsoft\windows\start menu\programs\ and edit the
shortcut. otherwise, the process will be identical to the taskbar step.
the first page/general options in properties will have the path to the
program first, and the startup folder second. simply change the startup
location to your desired path (typically c:\users\<yourname>).
video of process:
The per-task method (override the global default):
NOTE: this is if you want a specific task or several specific tasks to open in
a place other than the global default.
If Cmder/ConEmu is not running, start it.
From within any terminal, press winkey+alt+p to open the settings.
In settings on the left side nested tree navigation locate to
Startup->Tasks.
Scroll down to find the task you wish to edit.
In the large edit box, place the input cursor at the end and press the
Startup dir... button to add the startup location CLI option to the
startup command for this task.
Navigate to the folder you wish to start the application in. If it's not
something you can navigate to, simply select any folder and edit it after
you're done in the launch command.
Video:

Finding empty label in Windows form

I am new to Windows Form application and trying to build a small application.
I had dragged and dropped a label on the main form.
Then I deleted its text property to empty string basically hiding the label.
Now I would like to move this label to some other location on the form but unable to do so because I cannot find it.
I checked the designer file and its there.
But I cannot find it in the form so that I can grab it and move to a different location.
Please help.
Thanks
Use Document Outline. Look at the following images.
That happens to me several times, and a few weeks ago I found a way to get the empty label like this:
On the tab "Properties" just click on the arrow to show all controls and click on the label you want, this will automatically select the label on your form..

how to close a tabbed window using testcomplete?

I am trying to access a tabbed window which is under Multiple Document interface window under which there are tabs which are generated dynamically.
I wanted to check whether the new tab is opened successfully or not, and after its been opened i need to close it too.I tried to get the number of tabs opened using the following piece of code:
mdiclient.ChildCount
Now need a way to close the opened Tab without using Click coordinates.
Try getting the tab object as a child of the mdiclient window and then call its Close method.
tried using The Close one .. but it always closed the 1st tab .. so i found a Workaround,
use :
mdiclient.Child(index).Dispose
Worked for me like a charm... got the count of the number of tabs opened using the
mdiclient.Controls.get_count

how to open a file and edit it in wpf

Hi
I have a textbox and a button named browser. When I click the browser button, my program uses the Microsoft.Win32.OpenFileDialog to display the file name I selected on the textbox. If I want to add one more button named open, when I click open button, the above file could be opened. No matter it's a *.cs file, *.txt or *.xml. Is this possible?
I try to use OpenFileDialog.OpenFile(), doesn't work. Thanks!
You can use System.Diagnostics.Process.Start it will use whatever is your default program to open the file, like this:
System.Diagnostics.Process.Start(filePath);

WinForms printing: how can I access the progress dialog?

When printing in Windows forms, or doing a print preview, a dialog is displayed with text like
Page [P] of [DOC]
where [P] is page number and [DOC] is the name of the document. The dialog also contains a button to allow the user to cancel the print job.
How can I change the text displayed? What I would prefer is text like
Page [P] of [Pages]
where [Pages] is the total number of pages, to give the user an indication how long it will take to print all pages. If possible I would also like to show a progress bar, because when a print job is started, I know exactly how many pages will be printed.
I did this:
Derive your own class from PrintDocument, handling all printing
Set the print controller to a new StandardPrintController (no dialog displayed then)
Display your own dialog, e.g. display and close in OnBeginPrint and OnEndPrint, update in OnPrintPage
If I remember correctly, there was no way to change the text, and since the default dialog is not localizable, we could not use it. It works fine with what I wrote above though.

Resources