Advertisement
Guest User

AutoIt Bluetooth udf

a guest
Aug 28th, 2013
1,085
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 3.09 KB | None | 0 0
  1. #include <WinAPI.au3>
  2.  
  3.  
  4. Func _BluetoothFindFirstDevice($REMEMBER = False)
  5. Local $HRESULT[3], $tBLUETOOTH_DEVICE_INFO
  6. $tBLUETOOTH_DEVICE_SEARCH_PARAMS = DllStructCreate('DWORD;BOOL;BOOL;BOOL;BOOL;BOOL;BYTE;HANDLE')
  7. DllStructSetData($tBLUETOOTH_DEVICE_SEARCH_PARAMS, 1 , DllStructGetSize($tBLUETOOTH_DEVICE_SEARCH_PARAMS))
  8. DllStructSetData($tBLUETOOTH_DEVICE_SEARCH_PARAMS, 2 , False)
  9. DllStructSetData($tBLUETOOTH_DEVICE_SEARCH_PARAMS, 3 , $REMEMBER)
  10. DllStructSetData($tBLUETOOTH_DEVICE_SEARCH_PARAMS, 4 , True)
  11. DllStructSetData($tBLUETOOTH_DEVICE_SEARCH_PARAMS, 5 , True)
  12. DllStructSetData($tBLUETOOTH_DEVICE_SEARCH_PARAMS, 6 , True)
  13. DllStructSetData($tBLUETOOTH_DEVICE_SEARCH_PARAMS, 7 , 6)
  14. DllStructSetData($tBLUETOOTH_DEVICE_SEARCH_PARAMS, 8 , 0)
  15. $tBLUETOOTH_DEVICE_INFO = DllStructCreate('DWORD;UINT64;ULONG;BOOL;BOOL;BOOL;word[8];word[8];WCHAR[248]')
  16. DllStructSetData($tBLUETOOTH_DEVICE_INFO,1,DllStructGetSize($tBLUETOOTH_DEVICE_INFO))
  17. $RESULT = DllCall("bthprops.cpl", "handle", "BluetoothFindFirstDevice", "struct*", $tBLUETOOTH_DEVICE_SEARCH_PARAMS, "struct*", $tBLUETOOTH_DEVICE_INFO)
  18. $HRESULT[0] = DllStructGetData($tBLUETOOTH_DEVICE_INFO, 9)
  19. $HRESULT[1] = DllStructGetData($tBLUETOOTH_DEVICE_INFO, 2)
  20. $HRESULT[2] = DllStructGetData($tBLUETOOTH_DEVICE_INFO, 3)
  21. Do
  22. $ULTRA = _BluetoothFindNextDevice($RESULT[0])
  23. until $ULTRA = "0"
  24. Return $HRESULT
  25. EndFunc
  26.  
  27. Func _BluetoothFindFirstRadio(ByRef $phRadio)
  28. $tBLUETOOTH_FIND_RADIO_PARAMS = DllStructCreate('DWORD')
  29. DllStructSetData($tBLUETOOTH_FIND_RADIO_PARAMS, 1 , DllStructGetSize($tBLUETOOTH_FIND_RADIO_PARAMS))
  30. $aResult = DllCall("bthprops.cpl", "handle", "BluetoothFindFirstRadio", "struct*", $tBLUETOOTH_FIND_RADIO_PARAMS, "handle*", 0)
  31. If @error Then Return SetError(2, @error, 0)
  32. $phRadio = $aResult[2]
  33. Return SetError($aResult[0] = 0, 0, $aResult[0])
  34. EndFunc
  35.  
  36. Func _BluetoothFindRadioClose($hBtFind)
  37. Local $aResult = DllCall("bthprops.cpl", "bool", "BluetoothFindRadioClose", "handle", $hBtFind)
  38. If @error Then Return SetError(2, @error, 0)
  39. Return SetError($aResult[0] = 0, 0, $aResult[0])
  40. EndFunc
  41.  
  42. Func _BluetoothFindNextDevice($HANDLE)
  43. $t1BLUETOOTH_DEVICE_INFO = DllStructCreate('DWORD;UINT64;ULONG;BOOL;BOOL;BOOL;word[8];word[8];WCHAR[248]')
  44. $RESULTX = DllCall("bthprops.cpl", "Bool", "BluetoothFindNextDevice", "handle", $HANDLE, "struct*", $t1BLUETOOTH_DEVICE_INFO)
  45. Return $RESULTX[0]
  46. EndFunc
  47.  
  48. Func _BluetoothRegisterForAuthenticationEx()
  49. Local $ZRESULT, $tBLUETOOTH_DEVICE_REG
  50. $tBLUETOOTH_DEVICE_REG = DllStructCreate('DWORD;UINT64;ULONG;BOOL;BOOL;BOOL;word[8];word[8];WCHAR[248]')
  51. DllStructSetData($tBLUETOOTH_DEVICE_REG,1,DllStructGetSize($tBLUETOOTH_DEVICE_REG))
  52. DllStructSetData($tBLUETOOTH_DEVICE_REG, 2 , 560)
  53. DllStructSetData($tBLUETOOTH_DEVICE_REG, 3 , 550377916751)
  54. DllStructSetData($tBLUETOOTH_DEVICE_REG, 4 , 9600)
  55. DllStructSetData($tBLUETOOTH_DEVICE_REG, 5 , False)
  56. DllStructSetData($tBLUETOOTH_DEVICE_REG, 6 , False)
  57. DllStructSetData($tBLUETOOTH_DEVICE_REG, 7 , False)
  58. $ZRESULT = DllCall("bthprops.cpl", "handle", "BluetoothRegisterForAuthenticationEx", "struct*",  $tBLUETOOTH_DEVICE_REG, "handle*", 0)
  59. Return $ZRESULT
  60. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement