Code Printscreen

0 views
Skip to first unread message

Meri Thilmony

unread,
Aug 5, 2024, 2:14:54 PM8/5/24
to siolatomre
Itmay not be the most common problem, but I've run into it more than a few times. New-ish user asks a question and rather than taking the time to copy and paste their code or console errors into the post they try to just take a screenshot of their editor and dump it into the question...

Images and screenshots can be a nice addition to a post, but please make sure the post is still clear and useful without them. Don't post images of code or error messages. Instead copy and paste or type the actual code/message into the post directly.


Images are useful in a post, but make sure the post is still clear without them. If you post images of code or error messages, copy and paste or type the actual code or message into the post directly.


I think screenshots of errors and code can be useful but only as supplementary information to the actual code/error as text. I find it helpful to see the actual error window sometimes as it helps me remember where I've seen this before or where exactly the error is coming from.


Images and screenshots can be a nice addition to a post, but please make sure the post is still clear and useful without them. If you post images of code or error messages make sure you also copy and paste or type the actual code/message into the post directly.


I agree that most screenshots of code are pure lazyness. And especially because putting stuff in working code will force you to think about what you've done, it is good to enforce a rule like: 'avoid posting screenshots of code'.


But, I can think of a good reason to add screenshots and sometimes even omit the code itself. IDE's like Android Studio can display lots of debug info right next to the code, which will often show that the problem you have is not because of bad input values. Then, the code itself may just be disturbing extra and the screenshot may be much more useful. Moreover, in a screenshot you can grab multiple parts of multiple windows, which can give a good overview.


Sometimes, it's not possible to obtain the text of a console error or multiple errors. This is a big problem when debugging in IE11 or when you have a specific CSS behaviour that should(n't) happen (this point is arguable).


In the situations that it is possible to re-type the whole message, please do so. If not, at least include the title/error number with part of the description and use the image as a suplementar media.


And if they do that, should they do that in the final code they submit? Does the final program code need to match the PPR screenshots, or can the PPR screenshots come from a copy of the program file designed for screenshots?


There are a number of reasons why you might want to make code screenshots: it could be for the purpose of learning, reviewing code, sharing your knowledge or documentation. Whatever your specific use case may be, this VS Code extension allows you to create screenshots of code in the IDE.


I hope this article is helpful and you learned something from it. Being a technical writer and content creator I am passionate about sharing my knowledge (including tips and advice) and helping other people achieve their goals, especially those just starting out in tech. You can connect with me on my social media profiles and blogs here.


It would be useful if Sublime Text had a built-in way to take a screenshot of the current code (or only the currently selected code) with a few twiddly bits (include line numbers or not, show the filename or not, etc.)


This will toggle the sidebar, status bar, minimap, main menu and the tabs. Once you are done, press the same keybinding to come back to the original state. These all are also available as individual menu items in View menu of the main menu.


It implements a share_code command that you can bind to a key, put in a menu, etc. It will create a new window either with the currently selected text or the whole file, depending on the situation. If text is selected, it makes sure to grab full lines.


It then creates a new window, makes a scratch buffer in the window using the same syntax as the source file, and appends the content in, followed by turning off all of the UI elements leaving just the file content.


There are downsides to this though. One would be that it has no effect on the size of a maximized window (if that matters). New windows tend to mimic the size of the window they were created from, so this can end you with it not doing anything (though that might be platform specific).


I edited the sample above to do both things; it inserts a number of newlines equal to the number of lines before the first part of the grabbed text, then sets the viewport of the new view so that the first line appears at the top of the window.


If your messaging app understands markdown, perhaps a better way to go about this is to have a command that wraps the selection in triple backticks and puts a markdown language identifier at the top triple backticks? and then puts it in the clipboard with sublime.set_clipboard so you can paste it immediately?


There are a number of VB6 examples on the web, but they tend to capture the running VB6 application or the desktop only. I am looking for a solution that captures a given window/application. So, I want to be able to supply the name of the application window to capture.


A quick Bing search did result in some code examples, but they captured the desktop or the current running VB6 application. I am willing to modify one of these to capture a given window (named application).


However before I do this, perhaps someone has an link to a vb6 or VBA library code example that will capture/save a given named application window to a bmp or some type of image file on the hard disk.


You probably already know this, but windows are identified by a unique 4-byte long called the window handle. Any code sample to get a screen capture can do any window: the desktop, the current application, or any running application. You just need to use the right window handle.


If you are truly interested in this topic, you need to go deeper. TextRecognize uses Tesseract under the hood and getting familiar with how to train its ML algorithm is important in understanding how you can improve the outcome.


As said in my comment above, TextRecognize is trained for English text and not code that contains wild variable names and many additional characters that usually don't appear in written text. However, when I trained my own Tesseract, I saw that the text in the training images was pretty bold


I really didn't spend too much time on this, because my main objective was to find out if we can use the .traineddata directly with Mathematica. If you follow the video, you see he uses a training script. I used the following


For the training data, I used a very simple approach which leaves a lot of room for improvement. I used the packages available as AddOns and joined them into a big text file, but I removed empty lines, indentation and I trimmed the code to 80 chars per line. Here is a hacky version


To maximize the performance on source code recognition, one has to spend substantially more time with this topic and look at each step in the chain.The training I did, only improved an already existing classifier which bases on the English language. I'm not sure this is the best way and this should probably be discussed with one of the Tesseract developers. Maybe it would be advantageous to train a completely new language from the ground up.


As I said earlier, we trained the new LSTM neural network for Tesseract 4.0 but I'm not sure Mathematica even uses this. The approach still works because in the .traineddata file both to old and the new LSTM classifier information are stored. At least this is how I understood it.


Therefore, if I had to work on this, I would start with plain Tesseract and work towards a good source code recognition. Once this works, you can use it from Mathematica. The Tesseract Tools which are the core of TextRecognize are available in source under


Often I see new users posting images, containing the text of the question they were intending to ask, or a part of it. This is especially true for the science and math based sites where new users don't know how to use MathJax. I tried searching through the previous questions on Meta SE, but couldn't find a Q&A thread dedicated to this. As we know, the common reasons are along the lines of "images are not text-searchable", "can't be read by screen reader applications", etc.


Google sees an image by its alt attribute. In many questions, it's simply "enter images description", which is not descriptive. Therefore, a text image alone can hardly be useful to the search engine.


As the name "Stack Exchange" suggests, this network promotes and facilitates the exchange of ideas between individuals. In the next section, you're going to see why SE's moderators are against the use of text images.


Despite Euler's blindness, he had been contributing to the math that we're now using. While standing on the shoulder's of disabled savants, should we help interested (potential) readers with disabilities in return?


Obviously, a screenshot requires me to retype the code in step #1. It's always possible I'll make a typo and answer the wrong question. It's also irritating since the OP could have copied the code directly rather than posting a screenshot. So maybe I won't try to answer that question after all.


When answering a question, one often needs to quote a piece of text from the question or report an equation. If the piece of text or the equation are contained in a picture, the answerer needs to rewrite them completely, wasting a lot of time.


The intent of this Success Criterion is to encourage authors, who are using technologies which are capable of achieving their desired default visual presentation, to enable people who require a particular visual presentation of text to be able to adjust the text presentation as needed. This includes people who require the text in a particular font size, foreground and background color, font family, line spacing or alignment.

3a8082e126
Reply all
Reply to author
Forward
0 new messages