#cs Thanks for downloading... from the official site (DropBox) This program is provided as-is, without any warranty or claims whatsoever for solely learning purposes of the end-users. You are not permitted to copy, re-distribute the source code or this program itself without the prior permission of the author. Regards, MKISH E-mail: maheep.kathuria@gmail.com #ce #include #include"GUIConstants.au3" #include #include ;global $WS_EX_CLIENTEDGE,$LVS_EX_GRIDLINES,$LVS_EX_FULLROWSELECT, $LVM_SETCOLUMNWIDTH Local $phRadio $hFind = _BluetoothFindFirstRadio($phRadio) If $hFind = 0 then msgbox(16, "Hardware error", "Unable to find compatible Bluetooth radio(s) on this machine.") _WinAPI_CloseHandle($phRadio) _BluetoothFindRadioClose($hFind) Exit else _WinAPI_CloseHandle($phRadio) _BluetoothFindRadioClose($hFind) EndIf $Form1 = GUICreate("Bluetooth Finder - by MKISH", 292, 394, 336, 268) $ListView1 = GUICtrlCreateListView("Device name|Device address|Class of Device", 0, 0, 290, 318, -1, BitOR($WS_EX_CLIENTEDGE,$LVS_EX_GRIDLINES,$LVS_EX_FULLROWSELECT)) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 90) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 100) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 90) $StatusBar1 = _GUICtrlStatusBar_Create($Form1) Dim $StatusBar1_PartsWidth[2] = [50, -1] _GUICtrlStatusBar_SetParts($StatusBar1, $StatusBar1_PartsWidth) _GUICtrlStatusBar_SetText($StatusBar1, "Status", 0) _GUICtrlStatusBar_SetText($StatusBar1, "Active", 1) $Button1 = GUICtrlCreateButton("Find new", 16, 336, 75, 25, $WS_GROUP) $Button3 = GUICtrlCreateButton("Exit", 192, 336, 75, 25, $WS_GROUP) $Button2 = GUICtrlCreateButton("Go offline", 104, 336, 75, 25, $WS_GROUP) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button3 Exit Case $Button2 If GUICtrlRead($Button2) = "Go offline" Then $RESULT = DllCall("bthprops.cpl", "Bool", "BluetoothEnableDiscovery", "Handle", 0, "Bool", 0) msgbox(64, "", "Discovery Disabled.") GuiCtrlSetData($Button2, "Go online") Else $RESULT = DllCall("bthprops.cpl", "Bool", "BluetoothEnableDiscovery", "Handle", 0, "Bool", 1) msgbox(64, "", "Discovery Enabled.") GuiCtrlSetData($Button2, "Go offline") EndIf Case $Button1 GuiCtrlSetState($Button1, $GUI_DISABLE) GuiCtrlSetData($Button1, "Please Wait...") _GUICtrlListView_DeleteAllItems($ListView1) _GUICtrlStatusBar_SetText($StatusBar1, "Finding", 1) $RESULT = _BluetoothFindFirstDevice(True) If _GUICtrlListView_FindInText($ListView1, "" & $RESULT[0]) = "-1" then If $RESULT[0] <> "" then GuiCtrlCreateListViewItem($RESULT[0] & "|" & Hex($RESULT[1]) & "|" & $RESULT[2], $ListView1) EndIf $RESULTX = _BluetoothFindFirstDevice() If _GUICtrlListView_FindInText($ListView1, "" & $RESULTX[0]) = "-1" then If $RESULTX[0] <> "" then GuiCtrlCreateListViewItem($RESULTX[0] & "|" & Hex($RESULTX[1]) & "|" & $RESULTX[2], $ListView1) EndIf _GUICtrlStatusBar_SetText($StatusBar1, "Currently active", 1) GuiCtrlSetData($Button1, "Find new") GuiCtrlSetState($Button1, $GUI_ENABLE) EndSwitch WEnd Func _BluetoothFindFirstDevice($REMEMBER = False) Local $HRESULT[3], $tBLUETOOTH_DEVICE_INFO $tBLUETOOTH_DEVICE_SEARCH_PARAMS = DllStructCreate('DWORD;BOOL;BOOL;BOOL;BOOL;BOOL;BYTE;HANDLE') DllStructSetData($tBLUETOOTH_DEVICE_SEARCH_PARAMS, 1 , DllStructGetSize($tBLUETOOTH_DEVICE_SEARCH_PARAMS)) DllStructSetData($tBLUETOOTH_DEVICE_SEARCH_PARAMS, 2 , False) DllStructSetData($tBLUETOOTH_DEVICE_SEARCH_PARAMS, 3 , $REMEMBER) DllStructSetData($tBLUETOOTH_DEVICE_SEARCH_PARAMS, 4 , True) DllStructSetData($tBLUETOOTH_DEVICE_SEARCH_PARAMS, 5 , True) DllStructSetData($tBLUETOOTH_DEVICE_SEARCH_PARAMS, 6 , True) DllStructSetData($tBLUETOOTH_DEVICE_SEARCH_PARAMS, 7 , 6) DllStructSetData($tBLUETOOTH_DEVICE_SEARCH_PARAMS, 8 , 0) $tBLUETOOTH_DEVICE_INFO = DllStructCreate('DWORD;UINT64;ULONG;BOOL;BOOL;BOOL;word[8];word[8];WCHAR[248]') DllStructSetData($tBLUETOOTH_DEVICE_INFO,1,DllStructGetSize($tBLUETOOTH_DEVICE_INFO)) $RESULT = DllCall("bthprops.cpl", "handle", "BluetoothFindFirstDevice", "struct*", $tBLUETOOTH_DEVICE_SEARCH_PARAMS, "struct*", $tBLUETOOTH_DEVICE_INFO) $HRESULT[0] = DllStructGetData($tBLUETOOTH_DEVICE_INFO, 9) $HRESULT[1] = DllStructGetData($tBLUETOOTH_DEVICE_INFO, 2) $HRESULT[2] = DllStructGetData($tBLUETOOTH_DEVICE_INFO, 3) Do $ULTRA = _BluetoothFindNextDevice($RESULT[0]) until $ULTRA = "0" Return $HRESULT EndFunc Func _DelItem() If GuiCtrlGetState($ListView1)<>0 then _GUICtrlListView_DeleteItemsSelected($ListView1) EndIf EndFunc Func _BluetoothFindFirstRadio(ByRef $phRadio) $tBLUETOOTH_FIND_RADIO_PARAMS = DllStructCreate('DWORD') DllStructSetData($tBLUETOOTH_FIND_RADIO_PARAMS, 1 , DllStructGetSize($tBLUETOOTH_FIND_RADIO_PARAMS)) $aResult = DllCall("bthprops.cpl", "handle", "BluetoothFindFirstRadio", "struct*", $tBLUETOOTH_FIND_RADIO_PARAMS, "handle*", 0) If @error Then Return SetError(2, @error, 0) $phRadio = $aResult[2] Return SetError($aResult[0] = 0, 0, $aResult[0]) EndFunc Func _BluetoothFindRadioClose($hBtFind) Local $aResult = DllCall("bthprops.cpl", "bool", "BluetoothFindRadioClose", "handle", $hBtFind) If @error Then Return SetError(2, @error, 0) Return SetError($aResult[0] = 0, 0, $aResult[0]) EndFunc Func _BluetoothFindNextDevice($HANDLE) $t1BLUETOOTH_DEVICE_INFO = DllStructCreate('DWORD;UINT64;ULONG;BOOL;BOOL;BOOL;word[8];word[8];WCHAR[248]') $RESULTX = DllCall("bthprops.cpl", "Bool", "BluetoothFindNextDevice", "handle", $HANDLE, "struct*", $t1BLUETOOTH_DEVICE_INFO) If _GUICtrlListView_FindInText($ListView1, "" & DllStructGetData($t1BLUETOOTH_DEVICE_INFO, 9)) = "-1" then If DllStructGetData($t1BLUETOOTH_DEVICE_INFO, 9) <> "" then GuiCtrlCreateListViewItem(DllStructGetData($t1BLUETOOTH_DEVICE_INFO, 9) & "|" & Hex(DllStructGetData($t1BLUETOOTH_DEVICE_INFO, 2)) & "|" & DllStructGetData($t1BLUETOOTH_DEVICE_INFO, 3), $ListView1) EndIf Return $RESULTX[0] EndFunc