Sign in to follow this  
Followers 0
stormbreaker

Bluetooth Detector/Switching Script

9 posts in this topic

#1 ·  Posted (edited)

:) 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
2 people like this

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

:bye: Hey there, was I helpful?

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

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

Share this post


Link to post
Share on other sites



You can write out the UDF can send files to your mobile phone?

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

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.

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

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.

Share this post


Link to post
Share on other sites

How to send (Transfer pc to phone) file with it ?

Share this post


Link to post
Share on other sites
: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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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
Sign in to follow this  
Followers 0

  • Similar Content

    • lesther
      By lesther
      Hi,
      I´m making a script to send and receive data to/from Bluetooth serial, but I´m having a problem to connect to the com port.
      The problem is that I´ve two ports, one is the COM4 and the other is COM6 (not using at the same time)
      COM4 is a standard com port thought USB port that I can connect using CommMG, it´s working fine.
      _CommSetPort($port, $sportSetError, 9600, 8, 0 ,1,0) COM6 is a Bluetooth serial, that only works (I mean I can connect, send and receive data) with _WinAPI_CreateFile.
      $openport = _WinAPI_CreateFile("COM6", 2, 6) . . . _WinAPI_ReadFile($openport, DllStructGetPtr($tBuffer), 1, $nRead) $sText = BinaryToString(DllStructGetData($tBuffer, 1))  
      If I try to connect the COM4 with _WinAPI_CreateFile it´s not working... and when I try to connect with CommMG to COM6 it´s give a -16 (Port not found) error..
      The problem is:
      How can I open/connect to the bluetooth (COM6) port using CommMG  ( to write one single script instead of two - one using CommMG and another using  _WinAPI_CreateFile)...
       
      Thanks in advance!
    • stormbreaker
      By stormbreaker
      Hello everyone. This is my second tool concerned with Bluetooth Technology. It uses native windows bluetooth functions to discover bluetooth devices near you.

      Workable for all devices supporting Plug-And-Play in Windows. Download here (source code included).

      All suggestions are welcome.