Jump to content

Bluetooth Detector/Switching Script


stormbreaker
 Share

Recommended Posts

:) Hello everybody, this is my first example script weeks after giving my exams. Here is it:

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Bluetooth Manager (just something)", 409, 135, 192, 124)
$Label1 = GUICtrlCreateLabel("This script will check if your PC is bluetooth enabled.", 8, 8, 368, 17)
$Button1 = GUICtrlCreateButton("Check if device present", 112, 48, 171, 25, $WS_GROUP)
$Checkbox1 = GUICtrlCreateCheckbox("Disable Discovery for all Bluetooth Devices on PC", 16, 96, 257, 17)
$Button2 = GUICtrlCreateButton("Exit", 312, 96, 75, 25, $WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
$RESULT = DllCall("bthprops.cpl", "Bool", "BluetoothEnableIncomingConnections", "Handle", 0, "Bool", 1)
If $RESULT[0] = 1 then
msgbox(64, "Message", "Congrats! Your Computer is bluetooth enabled.")
    else
    msgbox(16, "", "No device found")
EndIf
Case $Checkbox1
If BitAND(GUICtrlRead($Checkbox1), $GUI_CHECKED) Then
                $RESULT = DllCall("bthprops.cpl", "Bool", "BluetoothEnableDiscovery", "Handle", 0, "Bool", 0)
                msgbox(64, "", "Discovery Disabled.")
            Else
                $RESULT = DllCall("bthprops.cpl", "Bool", "BluetoothEnableDiscovery", "Handle", 0, "Bool", 1)
                msgbox(64, "", "Discovery Enabled.")
            EndIf
Case $Button2
Exit
EndSwitch
WEnd

It can check if your PC is bluetooth enabled and can switch between bluetooth discovery modes. All functions taken from Microsoft's bthprops.cpl

;) Constructive suggestions are always welcome

Enjoy.

Note: Bluetooth discoverability can be controlled as long as the script is running. Once terminated, bluetooth state changes back to previously set by user. This is a Microsoft bluetooth function issue.

EDIT: This script is only meant for discovering Bluetooth Radios on a PC. That's all.

Edited by MKISH

----------------------------------------

:bye: Hey there, was I helpful?

----------------------------------------

My Current OS: Win8 PRO (64-bit); Current AutoIt Version: v3.3.8.1

Link to comment
Share on other sites

Sorry, but I have not studied the functions thoroughly. Furthermore, I only used the discovery functions to control bluetooth devices on my friend's cyber cafe. You can take a look at: http://msdn.microsoft.com/en-us/library/windows/desktop/aa362927(v=vs.85).aspx.

Happy coding with autoit.

----------------------------------------

:bye: Hey there, was I helpful?

----------------------------------------

My Current OS: Win8 PRO (64-bit); Current AutoIt Version: v3.3.8.1

Link to comment
Share on other sites

  • 4 weeks later...

Well sorry for Interuption MKISH

But Your Script Didn't Work

I'm Having BlueSoleil

Windows 7 32 Bit 2GB Ram and Core 2 Duo Processor Buld 7600

If Possible can U tell what iz the Problem in my Computer

I actually didnt have a integrated Bluetooth

I'm Having a Bluetooth Dongle and It works

Thnx For any Possible Help

Regards

Phoenix XL

Edited by PhoenixXL

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Link to comment
Share on other sites

This one uses the functions from bthprops.cpl. Maybe they are only applicable on specific devices. Further, I believe that Blue-Soleil has its own API (or so)... ;)

----------------------------------------

:bye: Hey there, was I helpful?

----------------------------------------

My Current OS: Win8 PRO (64-bit); Current AutoIt Version: v3.3.8.1

Link to comment
Share on other sites

I dont have Any Knowledge.

Anyways Keep Up the Good Work.. ;)

Edited by PhoenixXL

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Link to comment
Share on other sites

  • 4 months later...
:guitar: Take a look carefully at the topic, I just made it to detect BTH devices. You would need windows sockets for this purpose. Lookup on MSDN, they have plenty of samples. Regardless, I suggest you try my Bluetooth Finder Tool in place of this script (its much better).

----------------------------------------

:bye: Hey there, was I helpful?

----------------------------------------

My Current OS: Win8 PRO (64-bit); Current AutoIt Version: v3.3.8.1

Link to comment
Share on other sites

  • 4 years later...

Hi all,

        I am trying to automate bluetooth pairing in windows 8 by following steps Click on Start->bluetooth settinggs-> scan the devices-> here i would like to read device name.

 

How can i ensure it is clicking on correct device(whatever i am expecting).  Can any one help get the name of bluetooth scanned

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...