Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

How to create GUI on the windows7 Desktop?

  1. Dec 6, 2015 #1
    Dear Group,

    I am trying to to build a button ( with rectangle size) on the desktop of windows7,

    Whenever I click on that button, it will connect to batch file (which I created for some function) and run that batch file (filename.bat),

    Can you give me ideals that how to have that button on the desktop? I had some research and most people use python and java, but I would like to know a specific software which easiest to help me get that point.

    Please help!

    Thank you, Group.

    Best regards,

    Nate Duong.
  2. jcsd
  3. Dec 6, 2015 #2
    If you have no previous programming experience you would probably find Visual BASIC to be the easiest way to produce a simple app for Windows like you describe.
  4. Dec 6, 2015 #3


    User Avatar
    Science Advisor
    Homework Helper
    Gold Member

    Would a shortcut do? Eg just create a shortcut to the batch file and put it on the desktop.
  5. Dec 6, 2015 #4
    That should work, though It might be necessary to invoke the command line program with the batch file supplied as a parameter.
    Probably not though, the OS would most likely figure out for itself that it needs to run the command line program.
    However that approach won't allow for the possibility to have a rectangular depressable button.
    Last edited: Dec 6, 2015
  6. Dec 6, 2015 #5
    Dear CWatters,

    I've done that ideal but I really do not like it, it is not professional, But thank you so much for your help...
  7. Dec 6, 2015 #6
    Dear Rootone,

    Thank you for your recommendation, let me try to work on it,


    Nate Duong.
  8. Dec 6, 2015 #7
    Good luck! :smile:
  9. Dec 13, 2015 #8


    User Avatar
    Science Advisor
    Gold Member
    2017 Award

    The professional way is to use the system to get the job done in the simplest, most reliable way. A shortcut will do that. If you want the rectangle icon, you can convert a .jpg to .ico file type and change the shortcut icon. Google will give you links to conversion programs.

    If you are more interested in learning how to do graphics, that is another thing entirely. Visual Basic, Open GL, and Microsoft Foundation Class are some options.
  10. Dec 15, 2015 #9


    User Avatar

    Staff: Mentor

    Professional way is to not introduce new elements of the GUI to not confuse users - it is a so called principle of least astonishment. I have no "buttons" on my desktop and I wouldn't know what to expect from one if it will appear. Shortcuts on the other hand are quite typical and it is obvious they will start some kind of action.
  11. Dec 18, 2015 #10
    I am not sure you can change the GUI in Windows. I think the closest you're going to get to buttons on your desktop that you can program would be widgets.

    Windows has a "side bar" where you can load widgets, people often have the clock and CPU meter there. You can create your own widget and place it there, program it with buttons that execute some code when clicked.

    I've never built one so I'm afraid I cannot guide you on what to do. I would start with googling something like "create Microsoft widget" or "create sidebar widget"

    I would imagine it would be done in visual studio, visual studio express is the free version you can download.

    Hope this helps.
  12. Dec 22, 2015 #11


    User Avatar
    Gold Member

    Although it wouldn't precisely be "on the desktop", an appropriate way to accomplish this would be to write an application that places an icon in the system tray so that, when you right-click the icon, you can run the application, or exit it, or whatever.

    The difficulty really is, that Windows GUI applications have some issues when they call a batch file, because they cannot ascertain when the batch file has completed it's work. There are clunky workarounds, subject to occasional issues, such as using file creation semaphones.

    I have written system tray apps using Visual Studio and it's not difficult per se, but it is a little bit arcane. Code samples are likely freely available on the world wide web.
  13. Dec 22, 2015 #12
    Honestly, if you really want a button that you click once, just write a batch script and put it in there.
    It's on your gui and you have to click it once just like a button and then it does exactly what you want.

    Attached Files:

  14. Dec 29, 2015 #13
    Ideally, the shortcut solution described above is the best way.
    There is no way to actually have an interactive button on the desktop buffer.

    What you can do, if you really must have a the button on the desktop itself, is to create a WINDOWLESS program that draws directly to the desktop buffer and checks for mouseclick on the button to call the batch file. This is not ideal and contrary to good programming practice.

    There is no double buffering performed on the deskto background, it is simply drawn first onto the screen and then windows are drawn over it.

    Also, since Windows Vista, the DWM (Desktop Window Manager) will only redraw certain parts of the desktop and taskbar at certain times to make things a little faster - your button will be flickery and may be corrupted with mouse interaction etc. frequently.

    Obviously, you must ensure the windowless program is running.
  15. Jan 2, 2016 #14


    User Avatar
    Science Advisor
    Gold Member

    Also the links toolbar works well.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook