Jump to content

paint.net window brings to front view while called from command line => how to disable that feature?


Recommended Posts

Hello,

 

I use greenshot to make screenshots. I use it all the time. I configured greenshot to open the screenshot file in paint.net

so it will typically run a command line like 

"C:\Program Files\paint.net\paintdotnet.exe" "{0}" (where "{0}" is the filename of the image)

=> and then bang, paint.net comes in the frontview. which is something really annoying. 

 

I tried using a bat file that starts pdn minimzed:

START /MIN "" "C:\Program Files\paint.net\paintdotnet.exe" 

=> to no avail. pdn still goes in the forefront instead of being minimized 😔

 

So I tried with a VB script to start a silence shell and use the intWindowStyle

option of the Run command as documented there => https://docs.microsoft.com/en-us/previous-versions/d5fk67ky(v=vs.80)?redirectedfrom=MSDN

set s = createobject("WScript.Shell")
's.run """C:\Program Files\paint.net\paintdotnet.exe""", 2
's.run """C:\Program Files\paint.net\paintdotnet.exe""", 7       
s.Run chr(34) & "C:\Program Files\paint.net\paintdotnet.exe" & Chr(34), 2

I basically tried all possible values from 0 to 10 => in all cases the pdn just ignores the value and its main window just come in forefront. 😔

 

I also notice in MS documentation: 

Quote

intWindowStyle
Optional. Integer value indicating the appearance of the program's window. Note that not all programs make use of this information.

 

I also tried using the minimized option of a shortcut towards pdn => to no avail. pdn just ignores it entirely. (screenshot below) 😞

 

=> How can I start pdn without its main UI coming in the forefront?

 

thanks 

 

image.png.2520e0d96973ee41936237c8b7b45ccb.png

 

Link to comment
Share on other sites

It's not possible to do this right now but I could add a command-line parameter.

 

The way this works is that when you launch PDN for the 2nd+ time while it's still open, the new process detects the existing one, forwards the file names to it, and then brings it to the foreground. You just can't currently disable that second part.

 

I'll comment back on this post when I add this functionality, so just make sure you have e-mail notifications enabled.

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html

forumSig_bmwE60.jpg

Link to comment
Share on other sites

oh wow! thanks!

 

at least, i'm happy that it wasn't me not using the software correctly.

 

indeed a simple command line parameter would do the trick. that's exactly what I had in mind. I was willing to dive in the code to offer you a pull request. but then I found out that my favorite imaging software that i've been using and recommanding to friend for 10+ years is no longer open source! And when I read why => https://blog.getpaint.net/2007/12/04/freeware-authors-beware-of-“backspaceware”/

I was really outraged!

 

Again thanks a lot for your feedback. I'll wait for some comments here. 😊 (and yes I have notifications enabled)

 

 

 

 

 

Link to comment
Share on other sites

in fact. I jut figured...

"maaan you've been using the software for 10+ years, nearly everyday. never said thank you... never said anything in fact.

you post a question for something silly most ppl absolutely don't care about... and the guy offers a code fix...."

 

I felt a bit ashamed of myself to be honest. So I just sent a small donation. it's not much, but it should pay you a beer or two 😉

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

I just looked into this for the 4.3.12 release and it's a bit tricker than I thought -- it's easy enough for the new paintdotnet.exe to not activate/focus the existing instance (triggered by a command-line arg), but the existing process instance will refuse to open the image because it's not the currently active window. The reasons are lost to time, but I could easily break something important since this is a very important part of the code.

 

I'll take a look at this again for the 4.4 release, where I can work on things that are higher risk (4.3.x is strictly in "servicing mode").

The Paint.NET Blog: https://blog.getpaint.net/

Donations are always appreciated! https://www.getpaint.net/donate.html

forumSig_bmwE60.jpg

Link to comment
Share on other sites

A workaround.

I wrote a simple AutoIt script to do this. It's not perfect though. It will still show the window (and a console window for debugging purposes), but briefly. 

 

You can compile this script into an exe and call it like this or drag & drop images on the exe's icon.

script.exe "[PATH-TO-IMAGE]"

 

It'll open the image in Paint.NET and then immediately send keys (WIN+DOWN+DOWN) minimize its window.

 

https://www.autoitscript.com/site/

 

Script:

#pragma compile(Console, true)

Func _ConsoleWriteLine($Command)
      ConsoleWrite($Command)
      ConsoleWrite(@CRLF)
EndFunc

#include <File.au3>
local $source
local $sDrive = "", $sDir = "", $sFilename = "", $sExtension = ""
local $title
local $version = "4.3.11" ; update this according to your current Paint.NET version

If Ubound($CmdLine) > 1 Then
	$source = $CmdLine[1]
	_PathSplit($source, $sDrive, $sDir, $sFilename, $sExtension)
	$title = StringFormat("%s%s - paint.net %s", $sFilename, $sExtension, $version)
Else
	$source = ""
	; The window title for default canvas may be different for your locale
	$title = StringFormat("Untitled - paint.net %s", $sFilename, $sExtension, $version) 
EndIf
_ConsoleWriteLine("Opening " & $source & "...")
ShellExecute('paintdotnet:' & ' "' & $source & '"')
_ConsoleWriteLine("Waiting " & $title & " window to become active...")
WinWaitActive($title, "", 5)
AutoItSetOption("SendKeyDelay", 50)
_ConsoleWriteLine("Sending keys...")
Send("{LWINDOWN}{DOWN}{DOWN}{LWINUP}")
_ConsoleWriteLine("Done!")

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...