Archive

Archive for the ‘windows’ Category

IDE for C under Windows

April 13, 2014 Leave a comment


Problem
A friend of mine asked me to help him in C programming. He has Windows. What IDE to use?

Solution
Code::Blocks is an excellent choice. It has an installer that also contains a C compiler. Awesome. Just install it and you are ready to develop. It has all the nice features that you expect from an IDE.

Code::Blocks is actually cross platform, thus it exists under Linux too! It’s also good for C++. It’s open source.

Categories: c programming language, linux, windows Tags: ,

Linux host, Windows guest, shared Dropbox folder

February 16, 2014 Leave a comment

Problem
My primary operating system is Linux but since I need to work with Powerpoint too, I installed Windows 7 in VirtualBox. Under Windows I prepare my presentations but I want them synchronized on all my machines. For the synchronization I was using Dropbox.

I had Dropbox on Linux (host machine) and on Windows (guest machine) too. When I edited a file under Windows, Dropbox synced it to the Linux host too (the Windows client uploads it to the cloud; the Linux client downloads it from the cloud). It worked fine, though it was not not optimal. If I didn’t use the Windows guest for a long time, then after a boot I had to wait some time till Dropbox synced everything and I could start working only after that.

However, something happened to the Windows Dropbox client recently. Maybe it’s a bug, I don’t know, but the Dropbox client in my Windows guest became terribly slow. It keeps syncing but it doesn’t upload the changes, or I need to wait an hour or so to upload a file 1 MB of size. This is ridiculous and unacceptable. Note that I dind’t experience similar issues with the Linux client.

How to have a synchronized folder between a Linux host and a Windows guest without a Dropbox client on the guest?

Solution
First I made sure that my Dropbox folders were synced between the host and the guest. After this I uninstalled Dropbox on Windows and removed the C:\Dropbox folder entirely. Since it was synced with the Linux host, I had an exact copy of the Dropbox folder on Linux. Then shut down the Windows guest.

Here (http://www.maketecheasier.com/share-files-in-virtualbox-between-vista-guest-ubuntu-host) you can find an excellent post on how to set up a shared folder between a Linux host and a Windows guest. On the Linux host I shared my Dropbox folder ($HOME/Dropbox) that appears now as a new drive in the Windows guest (G:\ in my case). Now, if I modify something under Windows, it will be visible immediately in the Linux file system that the Dropbox client on Linux will notice and sync.

With this I could solve two problems. First, when I boot up the Windows guest, I don’t need to wait for the Dropbox client to sync. Second, if I change something under Windows, it is still synced to the Dropbox cloud, though I have no Dropbox client on Windows anymore.

Installing Vagrant on Windows

January 15, 2014 Leave a comment

Problem
You have a Windows machine and you want to use Linux (e.g. Ubuntu) in it. That is, you want to install an Ubuntu VM (virtual machine) inside Windows. You want to use the command line only, thus you don’t need any graphical interface. Maybe you have a weak laptop where a graphical VM wouldn’t even run normally. In addition, you want to get it done quickly, you have no time to download an Ubuntu image and go through the installation process. What to do?

Solution
Use Vagrant. Vagrant is a tool for building complete development environments. We will use Vagrant with VirtualBox, so we need to install both.

Install VirtualBox
Visit https://www.virtualbox.org/ and select Downloads on the left side. Download and install the latest version for Windows hosts. You can also install the Extension Pack. Make sure to install the version that matches with the previously installed VirtualBox version. We won’t work with VirtualBox directly, but Vagrant is built on top of it, so Vagrant will need it.

Install Vagrant
Visit http://www.vagrantup.com/downloads and install the Windows version. For the curious, Vagrant is written in Ruby. It is very likely that you will have to restart your computer after the installation. After the restart, you can use the command “vagrant” in the shell, it is added to the PATH by the installer.

Basic usage of Vagrant
As indicated in the official guide, using vagrant is very easy.

I suggest that you should create a dedicated directory for your first Ubuntu VM, C:\vagrant for instance. Enter this directory, open a terminal (with the command “cmd“) and execute the following commands:

c:\vagrant> vagrant init precise32 http://files.vagrantup.com/precise32.box
c:\vagrant> vagrant up

The first command downloads a basic Ubuntu 12.04 LTS image. The second command starts the VM.

Now it’s time to log in to the running VM:

c:\vagrant> vagrant ssh    # there is a chance that it won't work...

Well, if it doesn’t work for you under Windows, here is alternative solution: use Putty. Details: hostname: 127.0.0.1, port: 2222, username: vagrant, password: vagrant.

Some other useful commands:

c:\vagrant> vagrant status  # Is the VM running?
c:\vagrant> vagrant halt    # stop the VM; counterpart of "vagrant up"

Use Bash as your shell
The default Windows shell “cmd” is quite lame. If you want to use a better shell, install the Cygwin environment, which is a Unix compatibility layer for Windows. It’s enough to install the default packages, but don’t forget to add the “openssh” package too. In my case, I installed the 64-bit version and added the “c:\cygwin64\bin” directory to my PATH. After this you can launch the command “bash” and execute these commands:

$ cd /cygdrive/c/vagrant
$ vagrant status    # Is it running?
$ vagrant up        # if it was not running
$ vagrant ssh       # thanks to the openssh package, it works now
...                 # work with the VM
$ vagrant halt      # stop it if you don't need it anymore


Using Vagrant under Linux

vagrant

Ubuntu: disable Alt to launch HUD

September 26, 2013 Leave a comment

Problem
In Ubuntu (with Unity), Alt launches the HUD. Fine. However, if you have a Windows in VirtualBox and you want to switch windows in the guest VM with Alt+TAB, that damn HUD always appears in the host. How to disable it?

Solution
I found the solution here.

In short: top right corner, System settings… -> Keyboard -> Shortcuts tab -> Launchers. Assign a new key to “Key to show the HUD“, or disable it completely by pressing the Backspace.

Categories: ubuntu, windows Tags: , , , ,

Automate a Windows application from Linux using Python

January 22, 2013 Leave a comment

Problem
For my everyday work I use Linux. I also have a Windows 7 in VirtualBox. Under Windows I’ve found a very nice movie catalogue called Movie Collector. It’s not free though; unfortunately I didn’t find any good open-source alternative for this task.

So, I had this software running in VirtualBox and I wanted to input a list of movies. I collected the list in a file. Movie Collector has a GUI interface where you can insert the title of a movie and it’s put in a queue (see the figure below). Then you can verify for each item if it found the correct movie.

The question is: how to insert the movie titles via the GUI interface in an automated fashion? I won’t type 100 titles by hand…

add_movies

Solution
It’s a perfect job for Python. There is a great module called autopy that includes functions for controlling the keyboard and mouse. I already had it under Linux. Fortunately, you can launch an autopy script under Linux and it can interact with a Windows GUI that runs in VirtualBox.

The idea is simple: read the input file, where there is a movie title in each line. Put the movie title on the clipboard (we are lucky again, if you put something on the clipboard under Linux, it’s available under Windows too in VirtualBox). Click in the Title text field, select everything with Ctrl+A, press Del to delete the content, paste from the clipboard and click on the Add to Queue button. Then repeat: take the next movie title, etc.

The following script does exactly this:

#!/usr/bin/env python

from autopy import key
from time import sleep
from jabbapylib.mouse import mouse
from jabbapylib.clipboard.clipboard import text_to_clipboards

TITLE = (68, 124)    # input text field's position
ADD = (575, 123)     # button's position

def delete():
    mouse.click_to(TITLE)
    key.tap('a', key.MOD_CONTROL)    # Ctrl+A
    key.tap(key.K_DELETE)            # Del
    sleep(.1)

def paste():
    mouse.click_to(TITLE)
    key.tap('v', key.MOD_CONTROL)    # Ctrl+V
    sleep(.1)

def add():
    mouse.click_to(ADD)
    sleep(.1)

def main():
    cnt = 0
    with open('movies.txt') as f:
        for title in f:
            title = title.rstrip('\n')
            text_to_clipboards(title)

            delete()
            paste()
            add()
            cnt += 1

    print cnt

#############################################################################

if __name__ == "__main__":
    print 'Switch to VirtualBox...'
    sleep(3)
    main()

The imported modules are here:

To figure out the position of GUI elements (to know where to click to), you can use this little helper.

Git for Windows

January 9, 2013 Leave a comment
Categories: windows Tags: ,

Tools menu in Windows Firefox

January 9, 2013 Leave a comment

Problem
Today I wanted to try a Firefox add-on under Windows too. Under Linux, it can be configured via the Tools menu. However, under Windows Firefox there is no Tools menu. What da…?

Solution
Tools is hidden because… Well, just like that. Press Alt or F10 to make the whole menubar visible.

Categories: firefox, windows Tags: , ,

Getting an Artec e+ Pro Scanner work

September 15, 2012 Leave a comment

Problem
I have an Artec e+ Pro scanner that I used years ago under Windows XP without any problem. It’s a great scanner, I liked it. I found it a few weeks ago and today I wanted to use it. Well, I was too naive again…

(The exact text I have on its box: Artec e+ Pro Scanner, 1200×2400 dpi, 48 bits true color quality).

The official driver for this model is up to Windows XP. I only have Windows 7 and Linux, so first I tried to use it under Windows 7. On the installation CD there is a SETUP.EXE that I opened in Windows XP compatibility mode. The installation of the driver went smoothly but when I opened the application and clicked on “Scan”, it told me that a Twain driver is missing. I was looking for it everywhere but I didn’t find it. In the forums I read that Artec didn’t make a Windows 7 driver for this model.

Solution
OK, it won’t work under Windows 7. Then I thought: “Hey, let’s try it under Linux too!” And you know what? It worked! :) Here is what to do.

There is a scanner howto for Ubuntu (see here). I installed xsane but it dropped me an error message similar to this: “Failed to open device 'artec_eplus48u:libusb:001:003': Invalid argument.” Fortunately there is a page that explains how to configure this particular scanner for xsane (see here).

The page ArtecEplus48uConf explains the configuration of a 48U scanner. However, my scanner must be a variation of this scanner, its official name is “e+ Pro”. But they are very similar. Here is what I did to resurrect my e+ Pro scanner:

  • download the firmware 1200.usb and extract it (you can also copy it from the official CD)
  • copy the file 1200.usb to /etc/sane.d/
  • edit the file artec_eplus48u.conf and modify the part shown below
# This section is for the Artec E+ Pro
# Note, that the name of the firmware file is called 1200.usb for
# this device
usb 0x05d8 0x4004
option artecFirmwareFile /etc/sane.d/1200.usb
option ePlusPro   1
option vendorString "Artec"
option modelString "E+ Pro"

I only had to edit just one line to precise the path of the file 1200.usb.

Now xsane should be able to handle your scanner correctly :)

Update (20120916)

There is a solution to make it work under Windows 7. Install XP Mode, which is a virtual Windows XP inside your Windows 7. In this XP I could install the official CD and I could use the scanner.

When I launched the scanner application, it still said that the Twain driver is missing. But then XP noticed the new hardware and asked for a location from where it could install the driver. After specifying the XP folder on the CD, the Twain driver got installed.

Remove arrows from desktop icons (Windows 7)

September 11, 2012 Leave a comment

To get rid of the arrows on the desktop icons in Windows 7, use the Ultimate Windows Tweaker.

Auto Login to Windows 7

August 8, 2012 Leave a comment

Problem
I have a Windows 7 in VirtualBox. When I launch it, I don’t want to spend time with logging in. How to skip this step?

Solution
I found the solution here.

In short: launch netplwiz, in the Users tab, uncheck the box next to “Users must enter a user name and password to use this computer”, press Apply, provide the password, then OK, OK.

Categories: windows Tags: ,
Follow

Get every new post delivered to your Inbox.

Join 61 other followers