How to open and save/close file using powershell -


i'm looking create hotkey on f10 will, when pressed, open text file named notes. simple part, is:

c:\users\matt\notes.txt 

but want press of same hotkey save file , exit.

i interested in script, can run powershell through hotkeys.

firing off editor script simple as:

$proc = start-process -filepath c:\bin\notepad++.exe -arg c:\users\matt\notes.txt -passthru 

the trickier part figuring out how save & close file. if editor happens have com object model, use doubt editor word. :-)

another general approach use winforms sendkeys functionality. better approach use windows ui automation framework drive ui of arbitrary apps. there's powershell module wraps api make easy use powershell. called uiautomation. here example of how used:

start-process calc -passthru | get-uiawindow |      get-uiabutton -name [1-3] | invoke-uiabuttonclick; 

you substitute $proc start-process calc -passthru bit above.


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

python - How to remove the Xframe Options header in django? -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -