fbpx
Category

Tech

[DEPRECATED] Automatic wallpaper downloader with WSL

Please note, that unsplash has made an app that let users download wallpapers directly off of their website. So this tutorial isn’t really useful any more unless you don’t want to install the app. 

I started using bash on windows (WSL) on my windows 10 PC, a while ago, but so far hasn’t found any real use for it in my work scenario, but that changed when I got the idea to write a script that downloads wallpapers from a remote site to my computer every 2 hours (an interval that I chose). It uses linux and windows together to achieve its goal, and its just beautiful what Microsoft did by adding Ubuntu to run natively on Windows 10.

Let me introduce a website with gorgeous photographs that serves as an amazing source of wallpapers, www.unsplash.com. Now what’s so amazing about this website? Well at source.unsplash.com you can get a get a single link to download different photographs every time you load it, and that is essential to creating a periodic downloader for wallpapers for your PC.

Let’s get started, shall we!

  1. Create a folder anywhere you want your wallpapers to be downloaded to. (Mine was a folder called wallpaper in the picture library). All the script files will be saved in this folder.
  2. [OPTIONAL] Go to https://source.unsplash.com/ and get the link that suits your need the best. You can get a link that downloads wallpaper for your screen resolution, or with different categories etc.
  3. Open notepad, or your favorite text editor
  4. Copy and paste the following code in there (if you have your own unique link for wallpapers, replace the link in the code with your own link)
    @echo off
    bash -c "wget -O "download.jpg" "https://source.unsplash.com/category/nature/1920x1080?""
    set /p name=<filevar.txt
    echo %name%
    ren download.jpg wallpaper_%name%.jpg
    set /A name+=1
    break>filevar.txt
    >filevar.txt echo %name%
     
  5. Save it as download.bat (Make sure you select “All files” in Save type as, when saving the file)
  6. Close this notepad and open a new one, and copy and paste the following code in there (this script makes the bat file run without opening a command prompt console window):
    Set oShell = CreateObject ("Wscript.Shell")
    Dim strArgs
    strArgs = "cmd /c download.bat"
    oShell.Run strArgs, 0, false
  7. Save it as run.vbs
  8. Open another notepad and type 1 in there and save as filevar.txt

  9. [OPTIONAL] Test the script by double clicking the run.vbs file. You won’t see anything pop up, but a photo will be downloaded as download.jpg in the folder, if you are connected to the internet, and renamed to wallpaper1.jpg
  10. Open Task Scheduler (If you don’t know how, press WindowsKey+R and then enter this without quotes “%SystemRoot%\system32\taskschd.msc” and hit enter)
  11. Create a new task
  12. In the general tab, set configure for: Windows 10
  13. In Trigger tab, add new and on Begin the task: At log oncheck Delay task for: 30 Minutes (so that it doesn’t start with boot and increase the boot time), check repeat task and enter your time interval at which you want the wallpapers to be downloaded. I have mine set at 2 hours for a duration of indefinitely. Then made sure Enabled is checked and hit okay.
  14. In the Actions tab, create new and set Action to Start a program. 
  15. In the Program/Script write %systemroot%\system32\wscript.exe or C:\Windows\System32\wscript.exe if you have windows installed in C drive and in the add arguments write //Nologo and then put a space and then the path to your run.vbs file. (To get the path of your run.vbs file, hold shift on your keyboard and right click on it. Then click copy as path from the context menu.) And in the start in, put the path to your folder where you are downloading the wallpapers. (You can simply paste the path of run.vbs and then remove the \run.vbs and the quotes from the box.)
  16. [OPTIONAL] In condition tab, uncheck Start the task only if the computer is on AC power. 
  17. In the settings tab, Check Allow task to be run on demandCheck Stop the task if it runs longer than and input a value of 2 minutes if you have relatively fast internet or 10 minutes if you have a slow one. And in the drop down box, select stop the existing instance. Press okay and you are done.

Ta-da now you have an automatic wallpaper downloader set to run in the background, all you have to do now is set that folder as your windows wallpaper slideshow folder, from the personalize setting.

Have a great day!

[3ds Max] Customizing Autodesk 3ds Max with new icons and colors

One day as I was going through my daily routine of modelling and animating stuff inside 3ds Max, it dawned on me, how boring the interface the looks. And I have always been a freak about customizing UI of the software I use. From making themes for my phone to making custom icon for Windows PC.

I created custom Icons for Max, changed the colors, added new keyboard shortcuts etc to give it a brand new look.

Here are some of the screenshots

Splash Screen
UI

If you like the theme and want it for yourself, follow these instructions:

Warning: For 3ds max 2017 SP2

  1.  Download my files and extract using 7zip or winrar
  2. For splash screen
    • Copy the dll file to your max installation folder (usually at %programfiles%\Autodesk\3ds max 2017).
    • Optional backup: rename 3dsmax.branding.dll to 3dsmax.branding.old.dll
    •  Replace upon prompt when copying.
    •  Enjoy the beautiful splash screen next time you open it.
  3. For UI Icons
    •  Copy the three folders, Command Panel, MainToolbar and SnapsControls to C:\Program Files\Autodesk\3ds Max 2017\UI_ln\Icons\Dark (if you have max installed in the current location)
    • . Restart 3dsmax
  4. For UI Colors and Enhanced Menu
    • Copy the contents of the folder “For new UI” (not the folder itself) to C:\Program Files\Autodesk\3ds Max 2017\en-US\UI
    • Replace Files (Backup first)
    • Restart Max.

[AHK] [WSL] MD5 hash of a selected file with a key press

INFO: Script Requires Bash on Windows 10, also known as windows subsystem on linux (WSL).

If you use Autohotkey to make your own macros and do super awesome stuff with the push of a key, like I do, you may find this useful, specially if you download from the internet a lot, or transfer files over wireless network. You may need to compare the MD5 hash of files to check the integrity of transfer. Here is a quick code I wrote in Autohotkey script to get the MD5 hash of a file that you have selected in windows explorer.

Without further adieu, let me show the script to you.

Backspace::

;Get MD5SUM using WSL of selected file

var1 := % Explorer_GetSelection() ;stores the file path

Explorer_GetSelection(hwnd=””) { ;Script to get the path of the selected file >>>> START <<<<

    hwnd := hwnd ? hwnd : WinExist(“A”)

    WinGetClass classahk_id %hwnd%

    if (class=“CabinetWClass” or class=“ExploreWClass” or class=“Progman”)

        for window in ComObjCreate(“Shell.Application”).Windows

            if (window.hwnd==hwnd)

    sel := window.Document.SelectedItems

    for item in sel

    ToReturn .= item.path “`n”

    return Trim(ToReturn,“`n”)

;Script to get the path of the selected file >>>> END <<<<

StringReplace, var2, var1, \, /, all ;Replace \ with /

StringReplace, var3, var2, :, , all  ;Remove the colon from the address

RegExMatch(var3, “^[A-Z]”, Var4) ;Storing Drive letter to another variable

StringLower, Var4, Var4 ;changing drive letter to lowercase

StringTrimLeft, VarString1, Var3, 1 ;Removing the capital drive letter from the path

VarStringFinal = /mnt/%Var4%%VarString1% ;Joining together all the part of the path to be converted to a linux path

code =

(@echo off

bash -c “md5sum ‘%VarStringFinal%'”

)

run %comspec% /k %code%

return

The script is pretty self explanatory with the comments making it easier to understand. I have the Macro assigned to backspace key on a separate keyboard but you can assign it to any key you want. How I assigned it to a separate keyboard is a post for another day.

Why so many variables you may ask, because you need to change the file path to linux’s file path in WSL for the md5sum to work. Let’s say you have a file called file.txt in C drive, you will need it to be /mnt/c/file.txt in WSL. I used a lot of variables and I am sure a professional coder can make it much shorter.

This is how the end result looks like, see the selected file in the file explorer in the background.

In the end what you have is basically a bash script running inside a batch script running inside an autohotkey script. Scriptception!!

[3ds Max] Recover your work from animation error after skinning

Hello everyone! I ran into a problem the other day with exporting a mesh that I had skinned in 3ds Max. I hand painted the vertex weight and animated it, only to find errors during export. I was in a bad state at that point as it had taken me hours of work to hand paint the vertex weights during skinning process and I was in no mood to  have to go through it all, just because I missed to reset xform on the mesh and scaled the bones a bit to fit the mesh.

I was frantically searching for a solution on the web to no avail until I saw a tool called skin utlities. It hardly had a lot of documentation work for it but it was a life saver, and got my project working with just a few simple clicks.

So I decided to make a tutorial for anyone who might be in a fix as I was and looking for a solution. I realise I sound a  bit weird after listening to it and that it might be somewhat hard for people to understand what I am saying but the tutorial is pretty clear with whats going on in the screen so it all should be fine.And like an irresponsible child, I am going to put the blame for this on a severe toothache I was suffering from at the moment.

Here’s the video, take a look:

Hardware color calibrate your monitor without a colorimeter

So why do you need color calibration? Ever bought a monitor and the color seems a bit off? All monitor which aren’t factory calibrated will have a slight variation of color from real world colors, so white may appear as greenish or reddish, some colors may be washed out or darkened etc. If you are a photo editor who must produce color accurate results, you are recommended to get a colorimeter. They are specialised hardware which color calibrates your monitor. You can buy one from Amazon or maybe you can ask one of your local photo studio to rent it for a while. 

However if you are a gamer, and animator like me and you just wanna see the colors as they were supposed to be without the need to be 100% accurate, you can save some money and try your hand at this method instead.

Before you proceed with this, let me tell you that it still may not be 100% accurate but at least it will be better than most software solutions out there, if you wanna save a few bucks. Software solutions are limited by perception of your eye, this method isn’t.

Stuff you will need:

  1. A software which can pick color from an image’s pixel and display it’s RGB and LAB color value.
    Photoshop can do that. You can download photoshop’s trial.
  2. A good quality camera. A DSLR works best, but any camera which can shoot color accurate photos will do. Your budget smartphone camera won’t work.
  3. A lamp with white LED.
  4. A white thin paper to diffuse the LED lamp. You can read this article for a complete guide on how to diffuse light using household object.
  5. Basic knowledge of Photoshop.

Here are the steps:

  1. Let’s start by creating a diffused white light solution using a paper (or a white tshirt) and a white LED lamp. Place the lamp parallel to and beside your monitor, and point it in the same direction of your screen. 
  2. Open photoshop, create a new document with white as the background color. 
  3. Make the document full screen and zoom in so that the whole white covers the screen. 
  4. With the on screen control of your monitor, increase the brightness to the max. 
  5. Switch on your camera, go to setting, turn down your ISO to the lowest value, make sure hue/tone is set to auto (or neutral), and EV is set to 0. 
  6. Turn off all the lights in the room, if you have backlit keyboard, RGB mouse, etc cover it with something. 
  7. Point at the screen so that your lens is at the center, and now go back so that the lamp is in the frame too. (We added the lamp as a guide for the camera to not adjust to the tint of the monitor and display the color accurately. Some camera might adjust the to the light and change its own settings to make it appear white).

    I used my second monitor (not calibrated) as a reference instead of the lamp


  8. Click a few pictures (we will pick the best one out later) 
  9. Transfer these photos to your pc. 
  10. Drag and drop the best looking image to your photoshop document (you can turn off full screen now). 
  11. Pick your foreground color, from the center of the screen.

     

  12. Take a note of the values.
  13. Reverse the sign of the a and b values of the LAB color. (Like in the picture above, -1 will turn to 1, and 8 will turn to -8).
  14. Now write down the values of the RGB color values.
  15. You need to do some basic math now to get the value your of your monitor’s color correction settings. First step would be to look at the default values of the RGB setting of your monitor’s on screen control. Some companies like BenQ have their values at 100 while other like Samsung have that at 50.
  16. Use this formula for each other the red, green and blue (RGB) to get the values your monitor needs to be set at
    Color value of monitor = (color value of Photoshop/255) X default value of monitor’s color
    Something like
    R = 184/255*50
    G=187/255*50
    B=202/255*50
    for a samsung monitor displaying the values of the picture above.
  17. Enter these values on your monitor’s setting. (NOTE: While doing this, you may feel like the color on your screen isn’t what it should be. Change the values anyway. This is likely the effect of your eyes adapting to the tint of the monitor that was present before. Now go away from your monitor for a while, about 20-30minutes and don’t look at any digital screen in the meantime. When you come back, your screen will look natural)
  18. Now open your windows inbuilt calibration tool to set your gamma, brightness and contrast and you are good to go. You can open it by searching for Calibrate display color. 
    Note: click next on the page where it display sliders to correct color, without touching the sliders itself.