Jump to content

Leaderboard


Popular Content

Showing most liked content since 06/05/2020 in Posts

  1. 2 points
    Talvez seja possível iniciar algo do tipo a partir desse código Instalei o BluetoothCLTools-1.2.0.56 e é possível gerenciar as conexões de bluetooth apartir dele Porém ainda não entendi como funciona todas as conexões. Todos os parâmetros estão neste link http://bluetoothinstaller.com/bluetooth-command-line-tools/ ou é possível visualizar pelo prompt de comando o help do arquivo digitando -h Exemplo: btcom.exe -h Este script eu desenvolvi no Windows 10. Não testei e outras versões. #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.14.5 Author: Rodrigo Chaves Script Function: Bluetooth Script 06/2020 #ce ---------------------------------------------------------------------------- #RequireAdmin ;Necessario para mudar o status do servico #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <WindowsConstants.au3> #include <File.au3> #include <GuiListView.au3> #include <SendMessage.au3> #include <ProgressConstants.au3> #include <StaticConstants.au3> #include <Services.au3> Dim $sRoot = @ScriptDir hWnd_Main() Func hWnd_Main() ; Cria a GUI principal $hWnd_Main = GUICreate("AutoitBrasil", 620, 380, -1, -1) $ListView1 = GUICtrlCreateListView("Mac Address|Friendly Name|Type", 0, 0, 620, 320) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 130) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 150) $idBtn_Remove = GUICtrlCreateButton("Remove", 365, 330, 75, 25) $idBtn_Connect = GUICtrlCreateButton("Conectar", 445, 330, 75, 25) $idBtn_Pair = GUICtrlCreateButton("Parear", 525, 330, 75, 25) $idBtn_Refresh = GUICtrlCreateButton("Atualizar", 10, 330, 75, 25) $idBtn_ConnectView = GUICtrlCreateButton("Ver conexões", 95, 330, 75, 25) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit ;Verifica quais conexoes bluetooth estao disponiveis e visiveis Case $idBtn_ConnectView $iStatusProgress = hWnd_Status($hWnd_Main, 'Obtendo informações das conexões visíveis. . .') viewConnections() GUIDelete($iStatusProgress) ;Atualiza a lista de dispoitivos Case $idBtn_Refresh $iStatusProgress = hWnd_Status($hWnd_Main, 'Executando discovery. . .') $aDiscovery = discoveryDevices() If IsArray($aDiscovery) Then _GUICtrlListView_DeleteAllItems($ListView1) For $i = 1 To UBound($aDiscovery) - 1 GUICtrlCreateListViewItem($aDiscovery[$i], $ListView1) Next EndIf GUIDelete($iStatusProgress) ;Remove o dispositivos das conexoes conhecidas Case $idBtn_Remove Local $aItem = _GUICtrlListView_GetItemTextArray($ListView1) If IsArray($aItem) Then If $aItem[1] <> '' Then $iStatusProgress = hWnd_Status($hWnd_Main, 'Tentando remover. . .') Local $iQuestion = MsgBox(262144 + 32 + 4, 'Debug', 'Tem certeza que deseja remover o dispositivo selecionado?' & @CRLF & @CRLF & 'Mac Address: ' & $aItem[1] & @CRLF & 'Device: ' & $aItem[2] & 'Type: ' & $aItem[3], 60) If $iQuestion = 6 Then bluetoothRemove($aItem[1]) EndIf GUIDelete($iStatusProgress) Else MsgBox(262144 + 16, 'Debug', 'Selecione um item da lista') EndIf EndIf ;Conecta um dispositivo bluetooth Case $idBtn_Connect Local $aItem = _GUICtrlListView_GetItemTextArray($ListView1) If IsArray($aItem) Then If $aItem[1] <> '' Then $iStatusProgress = hWnd_Status($hWnd_Main, 'Conectando. . .') bluetoothConnect($aItem[1]) GUIDelete($iStatusProgress) Else MsgBox(262144 + 16, 'Debug', 'Selecione um item da lista') EndIf EndIf ;Pareia um dispositivo bluetooth Case $idBtn_Pair Local $aItem = _GUICtrlListView_GetItemTextArray($ListView1) If IsArray($aItem) Then If $aItem[1] <> '' Then $iStatusProgress = hWnd_Status($hWnd_Main, 'Pareando. . .') bluetoothPair($aItem[1]) GUIDelete($iStatusProgress) Else MsgBox(262144 + 16, 'Debug', 'Selecione um item da lista') EndIf EndIf EndSwitch WEnd EndFunc ;==>hWnd_Main Func viewConnections() checkIsBluettothOn() Local $iPID Local $iPID = Run(@ComSpec & ' /c "' & $sRoot & '\btdiscovery.exe -s"', '', @SW_HIDE, 0x2) ProcessWaitClose($iPID) Local $sOutput = StdoutRead($iPID) MsgBox(262144 + 64, 'Debug', $sOutput) EndFunc ;==>viewConnections Func bluetoothConnect($sByRefDevice) checkIsBluettothOn() Local $iPID Local $sOutput $iPID = Run(@ComSpec & ' /c "' & $sRoot & '\btcom.exe" -b' & $sByRefDevice & ' -c -s110b', '', @SW_HIDE, 0x2) ProcessWaitClose($iPID) $sOutput = StdoutRead($iPID) ConsoleWrite($sOutput & @CRLF) $iPID = Run(@ComSpec & ' /c "' & $sRoot & '\btcom.exe" -b' & $sByRefDevice & ' -c -s110e', '', @SW_HIDE, 0x2) ProcessWaitClose($iPID) $sOutput = StdoutRead($iPID) ConsoleWrite($sOutput & @CRLF) EndFunc ;==>bluetoothConnect Func bluetoothPair($sByRefDevice) checkIsBluettothOn() Local $iPID Local $sOutput $iPID = Run(@ComSpec & ' /c "' & $sRoot & '\btpair.exe -b' & $sByRefDevice & ' -c -s110b"', '', @SW_HIDE, 0x2) ProcessWaitClose($iPID) $sOutput = StdoutRead($iPID) ConsoleWrite($sOutput & @CRLF) $iPID = Run(@ComSpec & ' /c "' & $sRoot & '\btpair.exe -b' & $sByRefDevice & ' -c -s110e"', '', @SW_HIDE, 0x2) ProcessWaitClose($iPID) $sOutput = StdoutRead($iPID) ConsoleWrite($sOutput & @CRLF) EndFunc ;==>bluetoothPair Func bluetoothRemove($sByRefDevice) checkIsBluettothOn() Local $iPID Local $sOutput $iPID = Run(@ComSpec & ' /c "' & $sRoot & '\btcom.exe" -b' & $sByRefDevice & ' -r -s110b', '', @SW_HIDE, 0x2) ProcessWaitClose($iPID) $sOutput = StdoutRead($iPID) ConsoleWrite($sOutput & @CRLF) $iPID = Run(@ComSpec & ' /c "' & $sRoot & '\btcom.exe" -b' & $sByRefDevice & ' -r -s110e', '', @SW_HIDE, 0x2) ProcessWaitClose($iPID) $sOutput = StdoutRead($iPID) ConsoleWrite($sOutput & @CRLF) EndFunc ;==>bluetoothRemove Func discoveryDevices() checkIsBluettothOn() Local $iPID Local $sOutput, $sTab = ' ' Local $aOutput, $aDevice, $aReturn Local $iPID = Run(@ComSpec & ' /c "' & $sRoot & '\btdiscovery.exe -s"', '', @SW_HIDE, 0x2) ProcessWaitClose($iPID) Local $sOutput = StdoutRead($iPID) ConsoleWrite($sOutput & @CRLF) $aOutput = StringSplit($sOutput, @CRLF, 1) If IsArray($aOutput) Then For $i = 1 To UBound($aOutput) - 1 If StringLeft($aOutput[$i], 1) = '(' Then $aDevice = StringSplit($aOutput[$i], $sTab, 1) If IsArray($aDevice) Then If $aDevice[0] > 2 Then $aReturn &= $aDevice[1] & '|' & $aDevice[2] & '|' & $aDevice[3] & @CRLF EndIf EndIf EndIf Next EndIf $aReturn = StringSplit($aReturn, @CRLF, 1) Return $aReturn EndFunc ;==>discoveryDevices Func hWnd_Status($hWnd_ByRef, $sByRefText = 'Aguarde') $hWnd_Status = GUICreate("", 620, 380, 0, 0, $WS_POPUP, $WS_EX_MDICHILD, $hWnd_ByRef) GUISetBkColor(0x252525) Local $aGetPos = WinGetPos($hWnd_Status) Local $Graphic1 = GUICtrlCreateGraphic(0, 95, $aGetPos[2] - 2, 160) Local $Label1 = GUICtrlCreateLabel($sByRefText, 0, 155, $aGetPos[2] - 2, 17, $SS_CENTER) GUICtrlSetFont(-1, 10, 400, 0, "Segoe UI") GUICtrlSetBkColor(-1, -2) GUICtrlSetColor(-1, 0xFFFFFF) Local $Progress1 = GUICtrlCreateProgress(165, 185, 310, 12, 0x8) _SendMessage(GUICtrlGetHandle($Progress1), $PBM_SETMARQUEE, 1, 16) WinSetTrans($hWnd_Status, '', 230) GUISetState() WinActivate($hWnd_ByRef) Return $hWnd_Status EndFunc ;==>hWnd_Status Func checkIsBluettothOn() Local $sParam1 = 'bthserv', $sParam2 = 'bthHFSrv' Local $aCheckService = _Service_QueryStatus($sParam1) If $aCheckService[1] <> 4 Then Local $iQuestion = MsgBox(262144 + 32 + 4, 'Debug', 'O serviço bluetoth não está habilitado' & @CRLF & @CRLF & 'Deseja habilitar agora?', 60) If $iQuestion = 6 Then _Service_Start($sParam1) _Service_Start($sParam2) EndIf EndIf EndFunc ;==>checkIsBluettothOn Os demais arquivos necessários estão no link https://1drv.ms/u/s!AnsPM67Cyv4Xk9MKRtGzYbK2dTsCIA?e=Y3nXkD
  2. 1 point
    Esqueci de anexar SecurityEx.au3
  3. 1 point
    Dessa vez esta com banco de dados em SQL
  4. 1 point
    Olá pessoal. Com esta udf que eu fiz há a possibilidade de usar teclas de atalho de uma maneira diferente, semelhante a quando você pressiona SHIFT 5x. Você especifica uma tecla, quantidade de vezes para ela ser pressionada e um tempo limite para monitorar e contar o pressionamento. ; #FUNCTION# ==================================================================================================================== ; Name...........: _IsPressedTimes ; Description ...: Checks if a key has been pressed for a specified amount of time ; Syntax.........: _IsPressedTimes($sHexKey, $times, [$timeout = 1000]) ; Parameters ....: $sHexKey -> Key to check for ; $times -> Times to pressing key to return true ; $timeout -> [optional] Timeout to monitor the activation key after the first press of the button ; Return values .: True ; False ; Author ........: Antony Gabarron ; Modified.......: ; Remarks .......: See _IsPressed remarks to know the hexcodes ; Related .......: ; Link ..........: ; Example .......: Yes ; While 1 ; sleep(1) ; if _IsPressedTimes(11, 2) then ConsoleWrite("True" & @CRLF) ; WEnd ; =============================================================================================================================== Func _IsPressedTimes($sHexKey, $times, $timeout = 1000) $hDLL = DllOpen("user32.dll") Local $count if __IsPressed($sHexKey, $hDLL) Then $start = TimerInit() While TimerDiff($start) < $timeout sleep(1) if __IsPressed($sHexKey, $hDLL) Then While __IsPressed($sHexKey, $hDLL) WEnd $count += 1 EndIf if $count >= $times Then Return True ExitLoop EndIf WEnd if $count < $times Then Return False EndIf DllClose($hDLL) EndFunc ;==>_IsPressedTimes ; #FUNCTION# ==================================================================================================================== ; Name...........: __IsPressed ; Description ...: Check if key has been pressed ; Syntax.........: __IsPressed($sHexKey[, $vDLL = 'user32.dll']) ; Parameters ....: $sHexKey - Key to check for ; $vDLL - Handle to dll or default to user32.dll ; Return values .: True - 1 ; False - 0 ; Author ........: ezzetabi and Jon ; Modified.......: ; Remarks .......: If calling this function repeatidly, should open 'user32.dll' and pass in handle. ; Make sure to close at end of script ; 01 Left mouse button ; 02 Right mouse button ; 04 Middle mouse button (three-button mouse) ; 05 Windows 2000/XP: X1 mouse button ; 06 Windows 2000/XP: X2 mouse button ; 08 BACKSPACE key ; 09 TAB key ; 0C CLEAR key ; 0D ENTER key ; 10 SHIFT key ; 11 CTRL key ; 12 ALT key ; 13 PAUSE key ; 14 CAPS LOCK key ; 1B ESC key ; 20 SPACEBAR ; 21 PAGE UP key ; 22 PAGE DOWN key ; 23 END key ; 24 HOME key ; 25 LEFT ARROW key ; 26 UP ARROW key ; 27 RIGHT ARROW key ; 28 DOWN ARROW key ; 29 SELECT key ; 2A PRINT key ; 2B EXECUTE key ; 2C PRINT SCREEN key ; 2D INS key ; 2E DEL key ; 30 0 key ; 31 1 key ; 32 2 key ; 33 3 key ; 34 4 key ; 35 5 key ; 36 6 key ; 37 7 key ; 38 8 key ; 39 9 key ; 41 A key ; 42 B key ; 43 C key ; 44 D key ; 45 E key ; 46 F key ; 47 G key ; 48 H key ; 49 I key ; 4A J key ; 4B K key ; 4C L key ; 4D M key ; 4E N key ; 4F O key ; 50 P key ; 51 Q key ; 52 R key ; 53 S key ; 54 T key ; 55 U key ; 56 V key ; 57 W key ; 58 X key ; 59 Y key ; 5A Z key ; 5B Left Windows key ; 5C Right Windows key ; 60 Numeric keypad 0 key ; 61 Numeric keypad 1 key ; 62 Numeric keypad 2 key ; 63 Numeric keypad 3 key ; 64 Numeric keypad 4 key ; 65 Numeric keypad 5 key ; 66 Numeric keypad 6 key ; 67 Numeric keypad 7 key ; 68 Numeric keypad 8 key ; 69 Numeric keypad 9 key ; 6A Multiply key ; 6B Add key ; 6C Separator key ; 6D Subtract key ; 6E Decimal key ; 6F Divide key ; 70 F1 key ; 71 F2 key ; 72 F3 key ; 73 F4 key ; 74 F5 key ; 75 F6 key ; 76 F7 key ; 77 F8 key ; 78 F9 key ; 79 F10 key ; 7A F11 key ; 7B F12 key ; 7C-7F F13 key - F16 key ; 80H-87H F17 key - F24 key ; 90 NUM LOCK key ; 91 SCROLL LOCK key ; A0 Left SHIFT key ; A1 Right SHIFT key ; A2 Left CONTROL key ; A3 Right CONTROL key ; A4 Left MENU key ; A5 Right MENU key ; BA ; ; BB = ; BC , ; BD - ; BE . ; BF / ; C0 ` ; DB [ ; DC \ ; DD ] ; Related .......: ; Link ..........: ; Example .......: Yes ; =============================================================================================================================== Func __IsPressed($sHexKey, $vDLL = 'user32.dll') Local $a_R = DllCall($vDLL, "short", "GetAsyncKeyState", "int", '0x' & $sHexKey) If @error Then Return SetError(@error, @extended, False) Return BitAND($a_R[0], 0x8000) <> 0 EndFunc ;==>__IsPressed
×