greenshot / greenshot

Greenshot for Windows - Report bugs & features go here: https://greenshot.atlassian.net or look for information on:
https://getgreenshot.org
GNU General Public License v3.0
4k stars 578 forks source link

Cannot take screenshot on latest Windows 10 when / after using Slack window sharing #320

Closed ceecko closed 2 years ago

ceecko commented 3 years ago

Describe the bug On latest Windows 10 I sometimes get to a situation where it's not possible to create a screenshot with Greenshot. When you try to capture a region, a small rectangle (about 100x50px) of the top left screen is randomly placed on the screen and that's the only area you can interact with to select the region.

After restarting Windows the issue is usually gone. Happens only sometimes but it's pretty annoying ;)

To Reproduce Example steps to reproduce the behavior:

  1. Capture region (either via context menu or using a key)

Expected behavior Standard way to capture a region is available

Screenshots This is how it looks when you try to capture a screenshot IMG_2646

Versions (please complete the following information):

Additional context Only happens occasionally

Chaython commented 3 years ago

The only way I have issue, taking screenshots, is if the opened window on top is protected. Never the issue you have described. Try deleting your greenshot settings, reinstalling greenshot, changing display settings maybe something to do with dpi/scaling.

ceecko commented 3 years ago

@Chaython I've tried all those things before opening a ticket to make sure I don't bother you guys ;) Greenshot in general works ok. Sometimes though I see this behavior and I need to reboot to fix it.

Since you've mentioned a protected window could cause this, I'm going to check if it's not the combination of Windows Terminal and GeForce Experience software messing up fullscreen/windowed mode since I see a notification coming up once in a while GeForce Experience has been activated although no game is running.

I tried to reproduce it but no luck so far. I'll send an update here once I can replicate the issue. If you have a "debug" build which I can use and send you logs, I'm happy to run it.

Chaython commented 3 years ago

https://getgreenshot.org/faq/where-can-i-find-greenshots-log-file/

https://getgreenshot.org/faq/how-can-i-make-greenshot-write-debug-information-to-its-log-file/


From: ceecko @.> Sent: June 30, 2021 4:17 AM To: greenshot/greenshot @.> Cc: Chaython @.>; Mention @.> Subject: Re: [greenshot/greenshot] Cannot take screenshot on latest Windows 10 (#320)

@Chaythonhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FChaython&data=04%7C01%7C%7Cbfb5bea10bcc49d7ef7b08d93bb048a2%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637606450581255692%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=q%2F6SHsbxXVESoJm8uBsGBRjAPGBBH21wn4bU515Xrws%3D&reserved=0 I've tried all those things before opening a ticket to make sure I don't bother you guys ;) Greenshot in general works ok. Sometimes though I see this behavior and I need to reboot to fix it.

Since you've mentioned a protected window could cause this, I'm going to check if it's not the combination of Windows Terminal and GeForce Experience software messing up fullscreen/windowed mode since I see a notification coming up once in a while GeForce Experience has been activated although no game is running.

I tried to reproduce it but no luck so far. I'll send an update here once I can replicate the issue. If you have a "debug" build which I can use and send you logs, I'm happy to run it.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fgreenshot%2Fgreenshot%2Fissues%2F320%23issuecomment-871276879&data=04%7C01%7C%7Cbfb5bea10bcc49d7ef7b08d93bb048a2%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637606450581255692%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=CvzM0w%2Bp2tA9Jvc3PzP7aJouIztpG5iJjoJczmHMJ5I%3D&reserved=0, or unsubscribehttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FABRPSR335CCBKAFJIR6MW3TTVLVMBANCNFSM47FZWKTA&data=04%7C01%7C%7Cbfb5bea10bcc49d7ef7b08d93bb048a2%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637606450581265689%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=hepwmPDf39kBFVGducvmdjaVQY1zlSGWCo4xBAnpSX0%3D&reserved=0.

Lakritzator commented 3 years ago

I could think of 2 possible issues:

(I first though the most likely option was FancyZones, but I suddenly saw the capture, and it is the same as the following bug: https://greenshot.atlassian.net/browse/BUG-2784)

ceecko commented 3 years ago

Once I replicate the issue, I'm going to try resetting the print screen settings. However I'm using a mac keyboard with Windows which does not really have a print screen button so I mapped it to F14 instead.

image

Lakritzator commented 3 years ago

No, I don't mean the Greenshot settings, go into the settings of windows itself.

Lakritzator commented 3 years ago

enable & disable the radio button here: image

ceecko commented 3 years ago

@Lakritzator I understand, thanks. What I wanted to point out was that my keyboard does not have a print screen button and Greenshot is mapped to F14 instead so I don't use a print screen button to capture regions. Thus I would assume the snipping from Windows is not affecting this.

I'll give it a try though once I replicate the issue.

ceecko commented 3 years ago

The issue has just appeared. I don't see anything in particular in the log though. Turning the print screen shortcut on and off a couple times did not help.

2021-07-01 13:33:37,138 [Greenshot] DEBUG - [Greenshot.Helpers.CaptureHelper] Capturing with mode Region and using Cursor True
2021-07-01 13:33:37,138 [Retrieve window details] DEBUG - [Greenshot.Helpers.CaptureHelper] start RetrieveWindowDetails
2021-07-01 13:33:37,143 [Retrieve window details] DEBUG - [Greenshot.Helpers.CaptureHelper] end RetrieveWindowDetails
2021-07-01 13:33:37,240 [Greenshot] DEBUG - [GreenshotPlugin.Core.WindowCapture] Capturing the mouse cursor.
2021-07-01 13:33:37,240 [Greenshot] DEBUG - [GreenshotPlugin.Core.WindowCapture] CaptureRectangle Called!
2021-07-01 13:33:37,308 [Greenshot] DEBUG - [GreenshotPlugin.Core.Capture] Image is set with the following specifications: {Width=5120, Height=1440} - Format24bppRgb
2021-07-01 13:33:37,319 [Greenshot] DEBUG - [GreenshotPlugin.Controls.GreenshotForm] No Control or ToolStripItem: _mX
2021-07-01 13:33:37,319 [Greenshot] DEBUG - [GreenshotPlugin.Controls.GreenshotForm] No Control or ToolStripItem: _mY
2021-07-01 13:33:37,319 [Greenshot] DEBUG - [GreenshotPlugin.Controls.GreenshotForm] No Control or ToolStripItem: _mouseMovePos
2021-07-01 13:33:37,319 [Greenshot] DEBUG - [GreenshotPlugin.Controls.GreenshotForm] No Control or ToolStripItem: _cursorPos
2021-07-01 13:33:37,319 [Greenshot] DEBUG - [GreenshotPlugin.Controls.GreenshotForm] No Control or ToolStripItem: _captureMode
2021-07-01 13:33:37,319 [Greenshot] DEBUG - [GreenshotPlugin.Controls.GreenshotForm] No Control or ToolStripItem: _windows
2021-07-01 13:33:37,319 [Greenshot] DEBUG - [GreenshotPlugin.Controls.GreenshotForm] No value: _selectedCaptureWindow
2021-07-01 13:33:37,319 [Greenshot] DEBUG - [GreenshotPlugin.Controls.GreenshotForm] No Control or ToolStripItem: _mouseDown
2021-07-01 13:33:37,319 [Greenshot] DEBUG - [GreenshotPlugin.Controls.GreenshotForm] No Control or ToolStripItem: _captureRect
2021-07-01 13:33:37,319 [Greenshot] DEBUG - [GreenshotPlugin.Controls.GreenshotForm] No Control or ToolStripItem: _capture
2021-07-01 13:33:37,319 [Greenshot] DEBUG - [GreenshotPlugin.Controls.GreenshotForm] No Control or ToolStripItem: _previousMousePos
2021-07-01 13:33:37,319 [Greenshot] DEBUG - [GreenshotPlugin.Controls.GreenshotForm] No Control or ToolStripItem: _fixMode
2021-07-01 13:33:37,319 [Greenshot] DEBUG - [GreenshotPlugin.Controls.GreenshotForm] No value: _windowAnimator
2021-07-01 13:33:37,319 [Greenshot] DEBUG - [GreenshotPlugin.Controls.GreenshotForm] No Control or ToolStripItem: _zoomAnimator
2021-07-01 13:33:37,319 [Greenshot] DEBUG - [GreenshotPlugin.Controls.GreenshotForm] No Control or ToolStripItem: _isZoomerTransparent
2021-07-01 13:33:37,319 [Greenshot] DEBUG - [GreenshotPlugin.Controls.GreenshotForm] No Control or ToolStripItem: _isCtrlPressed
2021-07-01 13:33:37,319 [Greenshot] DEBUG - [GreenshotPlugin.Controls.GreenshotForm] No Control or ToolStripItem: _showDebugInfo
2021-07-01 13:33:37,319 [Greenshot] DEBUG - [GreenshotPlugin.Controls.GreenshotForm] No value: components
2021-07-01 13:33:37,319 [Greenshot] DEBUG - [GreenshotPlugin.Controls.GreenshotForm] No Control or ToolStripItem: scrollPosition
2021-07-01 13:33:37,319 [Greenshot] DEBUG - [GreenshotPlugin.Controls.GreenshotForm] No Control or ToolStripItem: deviceDpi
2021-07-01 13:33:39,006 [Greenshot] DEBUG - [Greenshot.Forms.CaptureForm] Closing captureform
2021-07-01 13:33:39,006 [Greenshot] DEBUG - [Greenshot.Forms.CaptureForm] Remove CaptureForm from currentForm
2021-07-01 13:33:39,011 [Greenshot] DEBUG - [Greenshot.Helpers.CaptureHelper] Disposing capture
luckyvalentine commented 3 years ago

Hello. I'm experiencing this same bug. Greenshot has worked well for over a year and I probably use it a handful of times a day.

It just starting acting like this, when I want press PrtSc (to take a screenshot), it shows a small, weird rectangle in the upper left of the screen (there is a good MP4 video in the jira ticket https://greenshot.atlassian.net/browse/BUG-2825)

I checked and the windows snipping tool functionality is "OFF" (like screenshot @Lakritzator posted) I don't have power tools (fanzyzoom) installed.

Since it started happening a couple weeks ago, rebooting usually fixes it, but it always comes back. Greenshot is rendered unusable (ie can't take region screenshot) until system is rebooted.. I've uploaded a screenshot of what it looks like. The text it shows is the same text of the window.

greenshotbug

luckyvalentine commented 3 years ago

As a side note, I just reverted to an older version and it still happens (version Greenshot-INSTALLER-1.2.9.129-RELEASE)

IkerGimenez commented 3 years ago

I could think of 2 possible issues:

  • Most likely issue: Maybe the Windows snipping-tool is somehow intervening, Go into the windows settings, search for “snipping” and you will get an option “Use the PrtScrn button to open screen snipping”, go to that “page” and almost at the bottom you can enable or disable windows snippings. If it's enabled, disable! If it's disabled, enable and disable it. Try working with Greenshot again.
  • You are using PowerToys with FancyZones, if so add greenshot.exe to the exclude list in the powertoys fancy zones configuration.

(I first though the most likely option was FancyZones, but I suddenly saw the capture, and it is the same as the following bug: https://greenshot.atlassian.net/browse/BUG-2784)

For other people coming along looking for info on a similar issue, I have PowerToys installed and disabling FancyZones has fixed Greenshot for me. Specifically I was seeing a small non-interactable window at the top left of my screen when trying to capture a screenshot.

Lakritzator commented 3 years ago

This issue with PowerToys should be solved with our latest builds, planed to be released. See here: https://github.com/greenshot/greenshot/releases

nick-foster commented 3 years ago

I am getting this same issue. I read through the details above and snipping tool is off, I don't have powertoys or fancyzones. This issue manifests as Greenshot working fine for some period, something happens (yet to identify what) and then every attempt to press PrntScreen results in the little window. Multiple presses of PrntScreen simply shows more of those little windows (see attached). I have to reboot to get it working again. Is there anything I can do to help diagnose it as it's super annoying and I really like Greenshot so would love it to work again. Windows version: Edition Windows 10 Home Version 21H1 Installed on ‎23/‎08/‎2021 OS build 19043.1266 Experience Windows Feature Experience Pack 120.2212.3920.0 Greenshot 1.2.10 Build 6

I tried the release candidate mentioned above - 1.3.211 and it had the same issue.

I have noticed that once this issue happens Notepad++ also seems to go weird if I open it up - I just tried the Greenshot.log file and saw Notepad++ all weird with lots of padding. Not sure if that helps.

image

Thanks Nick

Lakritzator commented 3 years ago

@nick-foster It's very unlikely this issue happens if you do not have PowerToys running.

So I have to ask are you sure it's not running in the background? you can see it near the other icons and the clock. image

Or in the Task Manager: image

I just want to make sure we are not tracing ghosts. Even if you tried 1.3, there might be an older version of PowerToys which doesn't handle the Windows correctly.

Can you tell me of any other tools you have installed? Tools that might influence the size of your Windows, like automatically position them?

Did you try the trick with the snipping tool, enable / disable it?

nick-foster commented 3 years ago

Hi @Lakritzator, Thanks for the quick response. A reboot fixed the issue from earlier, but it is likely to happen again but I can't predict when.

I have checked in the system tray and this is what I see: image Nothing that looks like PowerToys from your screenshot. The closest is "Dell PremierColor" but it seems to just be about color.

I don't knowingly have any tools which can influence the size of windows. The only thing I can think of is that I have two screens:

  1. Built in laptop screen - 4K with scaling set to 200%
  2. External WQHD screen 3440 x 1440 - no scaling at 100%

In the Task Manager I only have the following with 'P' image

This is the snipping tool setting when I checked image I have also tried turn it on and off again and restarting.

Any advice on what to capture or trace if it happens again?

Thanks

ceecko commented 3 years ago

@Lakritzator I confirm the same. No PowerToys, FancyZones or other software which could affect this.

ceecko commented 3 years ago

I confirm the issue persists on the latest Windows 11 (22000.282) as well

Lakritzator commented 2 years ago

I'm still at a loss of what is happening here. Also what interaction between notepad++ could be there.

@nick-foster I did see dropbox and evernote (?) icons, can you check if the screenshot integration of dropbox is active.

@ceecko Do you also use notepad++? Just trying to see any relations.

ceecko commented 2 years ago

@Lakritzator I do use notepad++. I did not manage to trigger the bad behavior in relation to notepad++ though yet.

Lakritzator commented 2 years ago

@ceecko

@Lakritzator I do use notepad++. I did not manage to trigger the bad behavior in relation to notepad++ though yet.

Thanks for the feedback, if there is anything else you notice let me know. I'm really still at a loss, more people have this but I myself do not. Troubleshooting such issues can only work if I can reproduce it. Do you use dropbox (I do not) or other apps which are visible on the screen shots of nick?

ceecko commented 2 years ago

@Lakritzator Slack and Geforce Experience utility I guess image

If you'd like to create a build with some "extreme" debugging enabled, I'm happy to install it :)

Lakritzator commented 2 years ago

@ceecko Slack seems to be a common nominator, which I do not use. (GeForce I have) Maybe there is something in Slack, which I doubt as I know most of it's functioning...

I wouldn't know what I could make to add some debugging, besides that I might output the size of the crop window (that which allows you to select your capture). I was in the progress of updating some dependencies for the 1.3 build, so I added this... who knows, maybe it helps.

If you have the Greenshot version 1.3.220 which I just made available, you will need to modify the log4net.xml in the installation directory, and change the line with <level value="INFO" /> to <level value="DEBUG" /> If the issue occurs, not down the time, copy the log file some place, and check if there is anything in there you do not like to have published (username, window titles etc) and attach it. You can find the log with the information here: https://getgreenshot.org/faq/where-can-i-find-greenshots-log-file/

hoomank commented 2 years ago

Just wanted to confirm that I had the same bug ... and was able to stop it from happening by exiting the desktop version of Slack. When I restart Slack the problem does not immediately manifest itself. But I think we confirmed that Slack is the culprit!

ceecko commented 2 years ago

@Lakritzator I confirm what hoomank says - quitting slack solves the issue. I think the easiest way to replicate this is the following:

  1. Start Greenshot
  2. Start Slack
  3. Call someone on slack and share a window (not screen) - this adds a green rectangle around the window
  4. Greenshot stops working
  5. Quit Slack
  6. Greenshot starts working

I'm happy to provide more debugging logs but I think it's going to be easiest to install Slack locally, do a call and figure out what's going on there.

Lakritzator commented 2 years ago

Ah great find!

This might help, and this explains why I could not reproduce it, I do not use Slack. Also I though shortly about Slack, as I saw the icon in the screenshots, but I do not remember it providing functionality which might cause issues with Greenshot. Never thought about Window or Screen sharing... 😒

Even if I will be able to reproduce it, I'm not sure if it is something on our side (I think it is not) so this either means I could workaround the issue (not good) OR it's the small free tool vs a big $$$ corp...

But first let's see where the journey goes 😏

Lakritzator commented 2 years ago

I think I cannot reproduce this, as I do not have a paid slack account. I think what you describe is not available for mere mortals.

image
Lakritzator commented 2 years ago

I reported an issue with Slack here: https://greenshot.slack.com/help/requests/3881492 You probably can't read this, but it's more for my history so I can find it back.

Lakritzator commented 2 years ago

Already got an answer, that was very fast, and I supplied them with more information. Going to bed now, way past my bedtime! 😴

ceecko commented 2 years ago

@Lakritzator I'll be happy to invite you to our channel where we can give it a try. I'll just need an email address to send an invitation to.

Lakritzator commented 2 years ago

The point is that my free time is little and very flexible, I cannot really plan around my day job and my family... It would be much easier if I can just test between 2 accounts whenever I have time. But let's first wait to what the next answer of Slack support will look like.

Lakritzator commented 2 years ago

Slack support is still looking into it, in the mean time I tried to create a workaround but I can't test it as I cannot reproduce the issue myself.

Please try 1.3.223 from here: https://github.com/greenshot/greenshot/releases It's a hack, if something tries to resize Greenshot, it's resized back to the original size. If slack is VERY naughty, your computer screen might start flashing... as slack will try to resize it every time it comes back to the size Greenshot desires. If this happens press ESC a lot!

I hope someone can have a look if that works?

ceecko commented 2 years ago

I just tested the build and the issue is gone. Works like a charm. I'm glad we managed to figure this out. Thank you for your help!

Lakritzator commented 2 years ago

@ceecko that is nice to hear, but the main point is still that it's not a bug in Greenshot. If this workaround fixes the issue, it means that Slack really changes the size of the Greenshot window. That is not good behavior.

So I will keep in contact with Slack, the issue is still open, I really do not like what I had to do.

ceecko commented 2 years ago

Understood. There's also an odd behavior of Slack which I'm not confident the root cause is Greenshot or not. But the idea is after you jump into a call, share a window and leave the call, you cannot right-click Slack icon in the tray. The context menu just does not render. You need to kill Slack from the task manager.

I'll dig around if this only happens with Greenshot running or not. Regardless I agree this is something Slack shall look into.

Lakritzator commented 2 years ago

@ceecko nope, shouldn't be Greenshot, I try to be a good citizen on your PC, not resize/move/disable other apps.

Lakritzator commented 2 years ago

@ceecko So the workaround for Slack caused a lot of other issues on multi display setups, which were reported in #367 I've improved upon the previous workaround, with something that is confirmed to fix #367, but I do not know if the new fix still works for the Slack issue. Could you be so kind to test version 1.3.234 which can be found here: https://github.com/greenshot/greenshot/releases

ceecko commented 2 years ago

@Lakritzator I just tested the version 1.3.239 and still works like a charm. Thank you for your great work!

Lakritzator commented 2 years ago

I'd really like to see that Slack fixes their side, it just feels dirty what I have to do.

I'm still slightly hesitant, to activate this workaround by default as there are some side effects possible. We already got some reports, as mentioned above, for which I made a quick change to the workaround to minimize them.

I was thinking about showing a popup when they do, something in line of:

Slack just resized Greenshot for no clear reason, this has been reported to them on the 17th of January 2022 but they didn't fix this yet. Please report an issue with them, to make it clear it's causing a lot of problems with you and us. As Greenshot is just awesome, we have prepared a work-around to give Slack some slack, we can active this for you so you can use Greenshot normally. Do you want to have this activated? yes / no

The amount of work that we have to do this, against a product which people pay for, is just not fair.

Lakritzator commented 2 years ago

Closing this for now, let's see what Slack does in the next weeks.

Lakritzator commented 2 years ago

I just reopened the issue with the following reason: I reported the issue with background information with Slack for 93 days ago, so far there hasn't been ANY sensible response. Please, all who have this issue report it to Slack, this might help to get a better priority for the issue.

You can reference my issue (which you probably can't read): https://greenshot.slack.com/help/requests/3881492 The issue can be reproduced with the description here: https://github.com/greenshot/greenshot/issues/320#issuecomment-1014674931

Somehow Slack is resizing the Greenshot window, and this is causing the issue here.

dandycyclone commented 2 years ago

I just reopened the issue with the following reason: I reported the issue with background information with Slack for 93 days ago, so far there hasn't been ANY sensible response. Please, all who have this issue report it to Slack, this might help to get a better priority for the issue.

You can reference my issue (which you probably can't read): https://greenshot.slack.com/help/requests/3881492 The issue can be reproduced with the description here: #320 (comment)

Somehow Slack is resizing the Greenshot window, and this is causing the issue here.

I also raised recently (2 weeks ago) Support Request #4093534 and just requested a status update to empathize, it is still not solved.

Lakritzator commented 2 years ago

After 5 months there still is no fix from Slack, a couple of weeks ago they did say how people are supposed to report the issue, the following comes from them:

Reach out to us at feedback@slack.com with their app logs. The more datapoints, the merrier! Here are instructions for collecting logs:

  1. From the Slack desktop app, open the app menu (☰).
  2. Cascade through Help, and Troubleshooting.
  3. Select Show Logs in Explorer.
  4. The zipped file will be saved to your default downloads folder.
anaisbetts commented 2 years ago

Paging @marshallofsound, one of the Calls windows is hanging around and causing Difficulties with screen capture apps

MarshallOfSound commented 2 years ago

Hm, catching up. Is this a phantom calls window or is something resizing a greenshot window? I'm not aware of any code that we have that would resize someone else's window. I can double check this afternoon and 👀 on the support ticket

Lakritzator commented 2 years ago

@MarshallOfSound I only know of the described way to reproduce it: https://github.com/greenshot/greenshot/issues/320#issuecomment-1014674931 What we have been able to track via logs which a user provided, is that something is resizing the Greenshot "CaptureForm". This is a window I create after taking the screenshot, and show this image in a fullscreen window (ontop with focus), so the user can select the part they want to keep (crop). In the described scenario, as soon as this "CaptureForm" is shown, it's resized to what you see in the screen-photo in the initial report.

It took us ages to track it to Slack, but it took Slack even longer to react.. and so far I've only been kept on hold.

MarshallOfSound commented 2 years ago

@Lakritzator I don't believe we're actively resizing any other windows. The code that becomes active when you start sharing a window specifically is just a bunch of window events.

Specifically we call SetWinEventHook for the following events:

We don't modify any values in that event afaics, and also I'm not sure we could if we wanted to.

We also hook a WNDPROC into a custom window class that handles WM_DESTROY, WM_WINDOWPOSCHANGED and WM_SIZE which do mess with the return values but, unless your windows are somehow using our window class, I'm not sure how that would be cause this problem 🤔

I can maybe take a better look next week (didn't have a lot of time to actually investigate today) but I'll be clear we're not actively resizing other apps windows 😆 There's probably just an obscure interaction / collision with our window classes or wndproc handlers that we haven't identified yet 🤷

Lakritzator commented 2 years ago

@MarshallOfSound Thank you for the thorough investigation.

I'm not saying that it's impossible, but AFAIK in Windows applications do not share a WNDPROC, and whatever you return it should not influence our newly generated window.

But there must be a reason why the those events are hooked, maybe something is done with the hWnd (which might be Greenshot) that is passed in the event? Check if SetWindowPos is called somewhere, that is the most likely thing to happen. Maybe, for some weird reason, Slack wants to change the "ontop" and has the flags in the call wrong, causing our window to resize...

Another possibility is MoveWindow

MarshallOfSound commented 2 years ago

@Lakritzator I think I found the source of the issue elsewhere in our code 🤔

Looks like we are intentionally calling SetWindowPos on an external hwnd in certain cases to ensure that our window ends up on top of it. We are calling SetWindowPos with the existing dimensions so it shouldn't be causing your window to resize rather just mess with the z-order. Loose code is below.

RECT rect;
GetWindowRect(hWnd, &rect);
SetWindowPos(hWnd, HWND_TOP, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, SWP_SHOWWINDOW);

I'll take a look next week and see what specifically about that call is causing your window to end up incorrectly sized

Lakritzator commented 2 years ago

@MarshallOfSound Great, thanks.

That call would change the z-order but ALSO does "change" the size. There might be many reasons the specified size is incorrect. e.g. one reason might be that this is triggered from the ontop event, but the size of the window is not yet set. At the moment slack processed the GetWindowRect, the window might have finally gotten it's size but slack still has an old size. Remember, it's multi-threaded and a lot of things happen. Also, if Slack is not running as DPI aware (but I would guess that it is aware) the rectangle size is completely off due to DPI scaling.

But that should be easy to fix, remove the GetWindowRect and forget about the rect.left etc (just use 0), and change the flags to SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE

--- I cut something here as I realized it didn't make sense --- I still do not understand why you would try to change the order of an external window to be on top? That is actually what the capture form does itself. So maybe some details are missing?