Geekzone: technology news, blogs, forums
Welcome Guest.
You haven't logged in yet. If you don't have an account you can register now.

4 posts

Wannabe Geek

Topic # 32132 14-Apr-2009 08:07
Send private message

I am trying to make my pc add automatically a bluetooth device by just double-clicking an icon on my desktop.
So I thought of making a batch that would open "devicepairingwizard" (I found that it can be opened just by typing it in the command line box); and then add automatically the device knowing its name or address(mac address) .
But is the creation of such batch possible? If yes, how should I proceed?
Thanks in advance!

Create new topic
637 posts

Ultimate Geek
+1 received by user: 92


  Reply # 207800 18-Apr-2009 16:54
Send private message

You could do it using AutoHotkey.

Start off the script with something like this:

Run, devicepairingwizard
WinWaitActive, Pair with a wireless device

Then keep using
SendInput, {Space}
or w/e, use this to click the default control - eg: 'Next', 'OK', etc. Use a combination of {Up}/{Down} or {Tab} to get to the appropriate control.

Also use WinWaitActive to wait till the window with the appropriate title (or text) is active.

SendInput, Name of the bluetooth device

If you can get the control name of the Edit box using AU3_Spy (included in package), then you can use ControlSetText, which can be faster and more reliable.

or w/e when the appropriate box is visible. Just use a combination of WinWaitActive, SendInput, ControlClick and Sleep if necessary. Everything is explained nicely in the help file.

4 posts

Wannabe Geek

  Reply # 207804 18-Apr-2009 17:18
Send private message

Thanks! I actually already started coding with autokey and it works! But I still need to do some debugging because it does not always run how it is supposed to... Also I am trying to do some optimisations and remove the "Sleep" and replace them by some conditions like "if ... then" or "while",
Here is my code:

; AutoIt Version: 3.0
; Language:       English
; Platform:       WinVista 32bit
; Author:         DGlower
; Script Function:
;   Intalls Bluetooth Device

;_Make sound when installed or finished
;_replace sleep statements with conditions

; Run the devicepairingwizard

; Wait for the devicepairingwizard become active
WinWaitActive("Pair with a wireless device")

Sleep (1000)
$WinTitle = 'Pair with a wireless device'            ;;Fill in details
$WinText = ''                                        
$CID1 = "SysListView321"
$CID2 = "SysLink2"

$Name1 = "Input Device"                    ;wiimote name before recognition  
$Name2 = "Nintendo RVL-CNT-01"                ;wiimote name after recongnition

$Name3 = "&Pair without using a code"
$Name4 = "Click Close to continue using your computer while driver installation completes."
$NameSearch1 = ControlListView($WinTitle,$WinText, $CID1,"FindItem",$Name1)
$NameSearch2 = ControlListView($WinTitle,$WinText, $CID1,"FindItem",$Name2)
$NameSearch4 = ControlListView($WinTitle,$WinText, "Static14" ,"FindItem",$Name4)

$NameSelect1 = ControlListView($WinTitle,$WinText, $CID1, "Select", $NameSearch1)
$NameSelect2 = ControlListView($WinTitle,$WinText, $CID1, "Select", $NameSearch2)
$NameSelect4 = ControlListView($WinTitle,$WinText, "Static14", "Select", $NameSearch4)

    Func check()
        Sleep ( 2000 )    ;wait for loading of phase 1 to finish
        $NameSearch3 = ControlListView($WinTitle,$WinText, "Button6","FindItem",$Name3)
        $NameSelect3 = ControlListView($WinTitle,$WinText, "Button6", "Select", $NameSearch3)    ;Select $Name3
        If $NameSelect3 <> -1  Then
            Sleep ( 400 )
            $Confirm1 = ControlClick($WinTitle,$WinText,'Button6')    ;confirm selection of $Name3
            Sleep ( 5500 )         ;wait for loading phase 2 to finish
            ;try to eliminate the previous Sleep(5000) but closing action occures to fast
            If $Confirm1 <> -1 Then
                While $NameSelect4 <> -1
                    $Confirm2 = ControlSend($WinTitle,$WinText, "DirectUIHWND1",'{ENTER}')
                    If $Confirm2 <> -1 Then
                    $NameSelect4 = -1

    If $NameSearch1 <> -1 Then
        $NameSelect1 = 1    ;execute selection of $Name1
        ControlSend($WinTitle,$WinText, $CID1,'{ENTER}')
    ElseIf $NameSearch2 <> -1 Then
        $NameSelect2 = 1    ;execute selection of $Name2
        ControlSend($WinTitle,$WinText, $CID1,'{ENTER}')
        Sleep (500)
        MsgBox(0, "Bluetooth Device Remover by NAL", "Wiimote was NOT installed!", 2 )
        WinClose($WinTitle, "" )


Create new topic

Twitter »

Follow us to receive Twitter updates when new discussions are posted in our forums:

Follow us to receive Twitter updates when news items and blogs are posted in our frontpage:

Follow us to receive Twitter updates when tech item prices are listed in our price comparison site:

Geekzone Live »

Try automatic live updates from Geekzone directly in your browser, without refreshing the page, with Geekzone Live now.

Are you subscribed to our RSS feed? You can download the latest headlines and summaries from our stories directly to your computer or smartphone by using a feed reader.

Alternatively, you can receive a daily email with Geekzone updates.