Jump to content

Search the Community

Showing results for tags 'usb'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • Forum FAQ
  • AutoIt

Calendars

  • Community Calendar

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 18 results

  1. This is an small script to Control Android Devices by USB using adb, you can use it with phones with a Cracked Screen or not working Touch Screen. What it Does: - Show your Android Screen on your Desktop. - Allow you to Swipe or Tap on the screen. - Allow you to send BACK button event. - Allow you to send WakeUp event. - Allow you to move in List Menu using Swipe gestures or Mouse Wheel Forward or Backward. - Refresh Screen with Wheel Click(Wheel Down)(To update your device screen on your desktop view). - Allow you to unlock your Device with Pattern only 3 points pattern for now. What it does not: - Complex Unlock Pattern not supported yet I'm working on that. - Complex Swipe gesture not supported yet, only straight lines. - PC Keyboard to write SMS or Email not Supported yet, I'm working on that. - Volume UP or Down not supported yet I will add it soon. - No configuration interface or file yet, keys and actions are pre set on script code. I will change that. What it Requires: - In order to Compile the Script you need 3 files: adb.exe, AdbWinApi.dll, AdbWinUsbApi.dll - In order to use the script without these files or without compile it you need to copy that files to user Temp Dir, or windows Temp dir I mean @TempDir. Keys Used and Notes: - Left Click will tap on the screen. - Keep Left Click down, move the mouse and release it with perform a Swipe operation.(Mouse Drag = Swipe). - Right Click will go back. - Enter on the keyboard will send WakeUp event(Power Button) - Wheel Down will Refresh the screen on your desktop, also F5.(Take last pictures of your android device screen) IMPORTANT: There is an $scale variable on the script that scale down your Phone screenshot image to a good resolution to show on your Desktop, I use 1.5 of scale factor because my phone resolution is 480x800 and my Desktop Screen is 1366x768 and that scale factor is good enough for me.(I will calculate that in the future to make it automatic). IMPORTANT 2: If you feel is very slow feel free to decrease Sleep() values from 400 to 200, that will be faster but you will need to Refresh with Wheel Click after you perform certain actions. Thanks and Credits: UDFs\MouseControl.au3 Base on Low Level Mouse Hook by @_Kurt all credits to him. UDFs\GUICtrlPicPNG.au3 Based on PNG work around by @UEZ from the help file, All credits to him. Kind Regards Alien. AndroidControl.zip
  2. Edit: If you already read this post, I updated it to better fit the scope of what I want to do. My goal is to be able to read the raw output from a usb type controller (or mouse or keyboard, don't want it to be controller-only) so i can see how / what changes when i hit buttons. I've gotten as far as finding HID page documentation and documentation for the device Struct, but I don't know where to go from here How do I tell what and Useage to use for any given controller / Keyboard / Mouse? How do I get a list of all HID devices connected and their UsagePage / Usage? How do I register multiple devices / get raw input from multiple devices at once? Here is the modified example script i am using: #include <APISysConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WinAPIGdi.au3> #include <WinAPIMisc.au3> #include <WinAPISys.au3> #include <WindowsConstants.au3> Opt('TrayAutoPause', 0) Global $iFlagsOld = 0, $iDataOld = 0 ; Create GUI Global $g_hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 160, 212, @DesktopWidth - 179, @DesktopHeight - 283, BitOR($WS_CAPTION, $WS_POPUP, $WS_SYSMENU), $WS_EX_TOPMOST) ; To obtain the values of "UsagePage" and "Usage" members of this structure read HID Usage Tables documentation ; http://www.usb.org/developers/devclass_docs/HID1_11.pdf ; Disregaurd that, official USB documention = useless. Here is a human/normal-person friendly list ; http://www.freebsddiary.org/APC/usb_hid_usages.php ; Information on the Struct (eg what Flags and hTarget do) can be found here ; https://msdn.microsoft.com/en-us/library/ms645565(v=vs.85).aspx Local $tRID = DllStructCreate($tagRAWINPUTDEVICE) DllStructSetData($tRID, 'UsagePage', 0x01) ; Generic Desktop Controls DllStructSetData($tRID, 'Usage', 0x06) ; Mouse DllStructSetData($tRID, 'Flags', $RIDEV_INPUTSINK) ; This flag makes window hTarget accept input even when it's not active. MUST define hTarget DllStructSetData($tRID, 'hTarget', $g_hForm) ; The target window that will be sent events, used with some Flags ; Register HID input to obtain row input _WinAPI_RegisterRawInputDevices($tRID) ; Register WM_INPUT message GUIRegisterMsg($WM_INPUT, 'WM_INPUT') ;~ GUISetState(@SW_SHOW) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE Func WM_INPUT($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $wParam Switch $hWnd Case $g_hForm Local $tRIM = DllStructCreate($tagRAWINPUTMOUSE) If _WinAPI_GetRawInputData($lParam, $tRIM, DllStructGetSize($tRIM), $RID_INPUT) Then Local $iFlags = DllStructGetData($tRIM, 'Flags') Local $sFlag = "", $sData = "" $iFlags = DllStructGetData($tRIM, 'ButtonFlags') If $iFlags <> $iFlagsOld Then $sFlag = $iFlags $iFlagsOld = $iFlags EndIf $iData = DllStructGetData($tRIM, 'ButtonData') If $iData <> $iDataOld Then $sData = $iData $iDataOld = $iData EndIf If $sFlag&$sData <> "" Then ConsoleWrite($sFlag&" "&$sData&@CRLF) EndIf EndIf EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_INPUT Old post:
  3. Hi, i searched the forum to communicate with a logitech G600 without using Shortcuts or Default Mouse Keys. the code below lets u use your sidekeys whenever you press down the ring key. before using the code you will have to unassign the keys in the logitech mouse driver software. The source of my code is a wacom usb script, wich was heavily modified to work. you might find some parts wierd, thats because this is my first attempt to communicate via raw hid. #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Change2CUI=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <APISysConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WinAPIGdi.au3> #include <WinAPIMisc.au3> #include <WinAPISys.au3> #include <WindowsConstants.au3> #cs ; #include "CommMG.au3" $mgdebug = True Global $sportSetError $tset = _ComGetPortNames() for $i = 0 to UBound($tset) -1 if $tset[$i][1] = "Serielles USB-Gerät" Then $COMPort = StringTrimLeft($tset[$i][0],3) ConsoleWrite("Teensy an Port COM" & $COMPort & " gefunden!" & @CRLF) EndIf Next $resOpen = _CommSetPort($COMPort,$sportSetError,31250, 8,0,1,0,0,0) if $resOpen = 0 then ConsoleWrite($sportSetError & @LF) ;~ Exit EndIf #ce $atagRID_DEVICE_INFO_HID = 'struct;dword VendorId;dword ProductId;dword VersionNumber;ushort UsagePage;ushort Usage;endstruct' $atagRID_INFO_HID = 'dword Size;dword Type;' & $atagRID_DEVICE_INFO_HID & ';dword Unused[2]' Opt('TrayAutoPause', 0) ; Create GUI Global $g_hForm = GUICreate('G600', 100, 25, -1, -1, BitOR($WS_CAPTION, $WS_POPUP, $WS_SYSMENU)) Local $tRID = DllStructCreate($tagRAWINPUTDEVICE) DllStructSetData($tRID, 'Flags', $RIDEV_INPUTSINK) DllStructSetData($tRID, 'hTarget', $g_hForm) DllStructSetData($tRID, 'UsagePage', 0x80) ; Logitech G600 DllStructSetData($tRID, 'Usage', 0x0A) ; _WinAPI_RegisterRawInputDevices($tRID) ; Now iterate to find other devices Local $tText, $aData = _WinAPI_EnumRawInputDevices() If IsArray($aData) Then ReDim $aData[$aData[0][0] + 1][3] $tText = DllStructCreate('wchar[256]') For $i = 1 To $aData[0][0] If _WinAPI_GetRawInputDeviceInfo($aData[$i][0], $tText, 256, $RIDI_DEVICENAME) Then $aData[$i][2] = DllStructGetData($tText, 1) Else $aData[$i][2] = '' EndIf If $aData[$i][1] = $RIM_TYPEHID Then $devInf = DllStructCreate($atagRID_INFO_HID) If _WinAPI_GetRawInputDeviceInfo($aData[$i][0], $devInf, DllStructGetSize($devInf), $RIDI_DEVICEINFO ) Then If DllStructGetData($devInf, 'VendorId') = 0x046D And DllStructGetData($devInf, 'ProductId') = 0xC24A then ; G600 VID & PID ConsoleWrite ("Device Info:-" & @CRLF) ConsoleWrite ('VendorId: ' & Hex(DllStructGetData($devInf, 'VendorId'),4) & @CRLF) ConsoleWrite ('ProductId: ' & Hex(DllStructGetData($devInf, 'ProductId'),4) & @CRLF) ConsoleWrite ('VersionNumber: ' & DllStructGetData($devInf, 'VersionNumber') & @CRLF) ConsoleWrite ('UsagePage: ' & Hex(DllStructGetData($devInf, 'UsagePage'),2) & @CRLF) ConsoleWrite ('Usage: ' & Hex(DllStructGetData($devInf, 'Usage'),2) & @CRLF) DllStructSetData($tRID, 'UsagePage', DllStructGetData($devInf, 'UsagePage')) DllStructSetData($tRID, 'Usage', DllStructGetData($devInf, 'Usage')) _WinAPI_RegisterRawInputDevices($tRID) EndIf EndIf EndIf Next EndIf ; Register WM_INPUT message GUIRegisterMsg($WM_INPUT, 'WM_INPUT') GUISetState(@SW_SHOW) Global $structHID_DATA = "struct;" & _ "dword Type;" & _ "dword Size;" & _ "handle hDevice;" & _ "wparam wParam;" & _ "dword dwSizeHid;" & _ "dword dwCount;" & _ "endstruct;" Global $structWACOM_PEN_DATA = "struct;" & _ "dword Type;" & _ "dword Size;" & _ "handle hDevice;" & _ "wparam wParam;" & _ "dword dwSizeHid;" & _ "dword dwCount;" & _ "ubyte bRawData00;" & _ "ubyte penvsEraser;" & _ "word x;" & _ "word y;" & _ "word proximity;" & _ "word pressure;" & _ "ubyte bRawData09;" & _ "ubyte bRawData10;" & _ "ubyte bRawData11;" & _ "ubyte bRawData12;" & _ "ubyte bRawData13;" & _ "ubyte bRawData14;" & _ "ubyte bRawData15;" & _ "ubyte bRawData16;" & _ "ubyte bRawData17;" & _ "ubyte bRawData18;" & _ "ubyte bRawData19;" & _ "ubyte bRawData20;" & _ "ubyte bRawData21;" & _ "ubyte bRawData22;" & _ "ubyte bRawData23;" & _ "ubyte bRawData24;" & _ "ubyte bRawData25;" & _ "ubyte bRawData26;" & _ "ubyte bRawData27;" & _ "ubyte bRawData28;" & _ "ubyte bRawData29;" & _ "ubyte bRawData30;" & _ "ubyte bRawData31;" & _ "ubyte bRawData32;" & _ "ubyte bRawData33;" & _ "ubyte tilt_ba;" & _ "ubyte bRawData35;" & _ "ubyte tilt_na;" & _ "ubyte bRawData37;" & _ "endstruct;" Do Until GUIGetMsg() = $GUI_EVENT_CLOSE Func WM_INPUT($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $wParam Switch $hWnd Case $g_hForm Local $tRIM = DllStructCreate($tagRAWINPUTHEADER) If _WinAPI_GetRawInputData($lParam, $tRIM, DllStructGetSize($tRIM), $RID_HEADER) Then ; Retrieves the raw input from the specified device $devType = DllStructGetData($tRIM, 'Type') $devSize = DllStructGetData($tRIM, 'Size') Else ConsoleWrite ("Device Header Retrieval Failed" & @CRLF) Return EndIf ; Now use the handle to the device to get it's name Local $tText = DllStructCreate('wchar[256]') If _WinAPI_GetRawInputDeviceInfo(DllStructGetData($tRIM, 'hDevice'), $tText, 256, $RIDI_DEVICENAME) Then $devName = DllStructGetData($tText, 1) Else ConsoleWrite ("Device Name Retrieval Failed" & @CRLF) EndIf if $devType = $RIM_TYPEHID Then $tRIM = DllStructCreate($structWACOM_PEN_DATA) If _WinAPI_GetRawInputData($lParam, $tRIM, DllStructGetSize($tRIM), $RID_INPUT) Then if DllStructGetData($tRIM, 8) = 32 Then ; filter for ring key down (G-Mode) Switch DllStructGetData($tRIM, 9) ; if in g mode assign the Keys G9 to G20 to autoit functions. case 0 Return ; key released case 1 g1() case 2 g2() case 4 g3() case 8 g4() case 16 g5() case 32 g6() case 64 g7() case 128 g8() case 256 g9() case 512 g10() case 1024 g11() case 2048 g12() Case Else ;;; ConsoleWrite(DllStructGetData($tRIM, 9) & @CRLF) EndSwitch EndIf EndIf EndIf EndSwitch sleep(50) Return $GUI_RUNDEFMSG EndFunc ;==>WM_INPUT Func g1() ;~ Send("2") ConsoleWrite("g1" & @CRLF) ;~ _CommSendString("KEY_TAB" & @LF) ;~ Sleep(random(50,100,1)) ;~ _CommSendString("KEY_RELEASE_ALL" & @LF) ;~ Sleep(random(50,100,1)) ;~ _CommSendString("KEY_2" & @LF) ;~ Sleep(random(50,100,1)) ;~ _CommSendString("KEY_RELEASE_ALL" & @LF) EndFunc Func g2() ConsoleWrite("g2" & @CRLF) EndFunc Func g3() ConsoleWrite("g3" & @CRLF) EndFunc Func g4() ConsoleWrite("g4" & @CRLF) EndFunc Func g5() ConsoleWrite("g5" & @CRLF) EndFunc Func g6() ConsoleWrite("g6" & @CRLF) EndFunc Func g7() ConsoleWrite("g7" & @CRLF) EndFunc Func g8() ConsoleWrite("g8" & @CRLF) EndFunc Func g9() ConsoleWrite("g9" & @CRLF) EndFunc Func g10() ConsoleWrite("g10" & @CRLF) EndFunc Func g11() ConsoleWrite("g11" & @CRLF) EndFunc Func g12() ConsoleWrite("g12" & @CRLF) EndFunc
  4. I know that this theme was discussed several times but I read all These threats with no helping result. I have two pieces of TEMPer1F USB Thermometer. It is a Standard Windows HID device with no add. Driver needed. With the device I got an App reading from it and showing Graphs and much more and which can handle several devices. With the Software came also a RDingUSB.dll file handling the communication with the device. I can call the dll without any error. But the Problem is how to Access the device using the DLL and Access more than one of same VID/PID by Serial or anything else useful. I have also sources in c# doing the Job, but no experience in C# to successfuly port it to AutoIT. So my question: Can anyone help me to realize the simple pull of the temperature value from the devices based on C# source? The rest to write it to MySQL DB and repeat it etc. is no Problem for me. *************************************** The C# part with the DLL functions class: *************************************** using System; using System.Runtime.InteropServices; namespace TEMPer { internal class RDing { [DllImport("RDingUSB.dll")] public static extern IntPtr OpenUSBDevice(int VID, int PID); [DllImport("RDingUSB.dll")] public static extern IntPtr CloseUSBDevice(IntPtr hDevice); [DllImport("RDingUSB.dll")] public static extern bool WriteUSB(IntPtr hDevice, byte[] pBuffer, uint dwBytesToWrite, ref ulong lpNumberOfBytesWritten); [DllImport("RDingUSB.dll")] public static extern bool ReadUSB(IntPtr hDevice, byte[] pBuffer, uint dwBytesToRead, ref ulong lpNumberOfBytesRead); [DllImport("RDingUSB.dll")] public static extern ushort GetInputLength(IntPtr hDevice); [DllImport("RDingUSB.dll")] public static extern ushort GetOutputLength(IntPtr hDevice); [DllImport("RDingUSB.dll")] public static extern uint GetErrorMsg(ref string[] lpErrorMsg, uint dwErrorMsgSize); } } ********************************* The C# code snippet working with the functions of the class above is in the attachment this is the interesting part where the data is sent and pulled which I do not understand to transcode to AutoIT Important my devices are the type2 (TEMPer1F) : ********************************* So in the end I Need: Call DLL, read all devices in array Loop the Array until ubound(Array) and for each device in Array read the temperature value and prepare the data to decimal 6,1 (SQL Format) and °C So how to pull the value from the devices? Maybe somwbody finds the important part in the C# (the code above is for different models, mine is TEMPer1F Or maybe someone has solved this and has maybe a uDF for this MainForm.cs
  5. Hello, I can easily find my modem comport number using the code below:- #include <FileConstants.au3> #include <MsgBoxConstants.au3> #include <WinAPIFiles.au3>    Global $key = RegRead("HKLM\HARDWARE\DEVICEMAP\SERIALCOMM","\Device\ssudmdm0000")     Local $iError = 0     If @error Then        ; The server is probably offline/port is not opened on the server.        $iError = @error         MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Client:" & @CRLF & "Could not connect, Error code: " & $iError)         Else         MsgBox($MB_ SYSTEMMODAL, "MODEM:", $key)         EndIf but the thing is I am planning to design a small tool by which it can read the modem COM port and set the COM number and send AT command to modem port using UDF CommMG.au3 created by Martin. I added some below code to martins file :- ;====================================================================================================================== ;CommSendStandard,a new function for sending information to a serial port. ;====================================================================================================================== Func _CommSendStandard($port,$error,$command)    _CommSetPort($port,$error,9600,8,0,1,2)  if $error <> '' Then      MsgBox(262144,'Port Error = ',$error)  EndIf  _CommSendString($command & @CR) EndFunc   ;==>_CommGetLineStates ;=============================================================================================== After adding I wrote the below code for sending AT command to modem port but its not working. Please check the below code and let me know for the issue. ;===================================================================================== #include "C:\Program Files (x86)\AutoIt3\SciTE\CommMG.au3" #include <FileConstants.au3> #include <MsgBoxConstants.au3> #include <WinAPIFiles.au3>    Global $key = RegRead("HKLM\HARDWARE\DEVICEMAP\SERIALCOMM","\Device\ssudmdm0000")     Local $iError = 0     If @error Then        ; The server is probably offline/port is not opened on the server.        $iError = @error         MsgBox(BitOR($MB_SYSTEMMODAL, $MB_ICONHAND), "", "Client:" & @CRLF & "Could not connect, Error code: " & $iError)         Else         MsgBox($MB_SYSTEMMODAL, "MODEM:", $key)         EndIf Local $port=$key Local $porterror _CommSendStandard($port,$portError,"AT+CFUN=1,1") ;================================================================================================ but If I set the port number by my own in the code (for eg :- port number 8 or any value instead of $key) it works fine and the modem gets reset.I want to know if there is any way to get the port number to a variable $port and discarding so that my above code works fine...In that case user donot have to take care of entering the port manually everytime and the script will automatically read the port number and set itself. Please help Regards, SAM
  6. Hi. I have several different devices connected to my desktop PC with USB COM adapters. Sometimes there is some error that will cut my USB COM device communication (usualy caused by lose USB connector)... After reconnecting that USB COM adapter, by some reason, Windows will give it different COM port number. I know there are some devices with integrated COM port circuit and they are used by client programs that can found them and only them by some USB hardware relate details and then use their COM port to communicate with correct COM device. It would be better to define some known and static hardware related string from device managers USB COM adapter details to my script config file, than always redefine different COM port to it. How can I do this trick with autoit? I communicate COM devices with cfxUDF.au3 AutoIt UDF.
  7. Connect Android phone > enable USB file transfer > go to My Computer, there's an icon, but no drive letter - this is normal. Open phone icon > go to Internal Storage > go to DCIM > copy all files and folders to computer. Now, I want a quick AutoIt script / windows batch to do this automatically. Get USB path with this - it works OK: #include <WinAPICom.au3> Global Const $sCLSID_PortableDeviceManager = "{0af10cec-2ecd-4b92-9581-34f6ae0637f3}" Global Const $sIID_IPortableDeviceManager = "{a1567595-4c2f-4574-a6fa-ecef917b9a40}" Global Const $sTagIPortableDeviceManager = "GetDevices hresult(ptr;dword*); RefreshDeviceList hresult(); " & _ "GetDeviceFriendlyName hresult(wstr;wstr;dword*); GetDeviceDescription hresult(wstr;wstr;dword*); " & _ "GetDeviceManufacturer hresult(wstr;wstr;dword*); GetDeviceManufacturer hresult(wstr;wstr;ptr;dword*dword*); " & _ "GetPrivateDevices hresult(ptr;dword*)" Global Enum $eDevID, $eDevName, $eDevManufacturer, $eDevDescription Local $aPnPDevices = GetPortableDevices() If IsArray($aPnPDevices) Then _ArrayDisplay($aPnPDevices) ;~ Success: Return 0 ;~ Failure: Return 2DArray [n][4] |;[n][0]$eDevID, [n][1]$eDevName, [n][2]$eDevManufacturer,[n][3] $eDevDescription Func GetPortableDevices() Local $aDevicesInfo[0][0] ;[n][0]$eDevID, [n][1]$eDevName, [n][2]$eDevManufacturer,[n][3] $eDevDescription Local $oPortableDeviceManager = 0 Local $SizeofArray = 0 Local $hr = 0x80004005 ;E_Fail Just to Initialized <0 Local $taPnPDeviceIDs = 0 Local $tName = 0 $oPortableDeviceManager = ObjCreateInterface($sCLSID_PortableDeviceManager, $sIID_IPortableDeviceManager, $sTagIPortableDeviceManager) If Not IsObj($oPortableDeviceManager) Then Return 0 If FAILED($oPortableDeviceManager.GetDevices(Null, $SizeofArray)) Then Return 0 If $SizeofArray < 1 Then Return 0 $taPnPDeviceIDs = DllStructCreate("ptr[" & $SizeofArray & "]") If FAILED($oPortableDeviceManager.GetDevices(DllStructGetPtr($taPnPDeviceIDs), $SizeofArray)) Then Return 0 ReDim $aDevicesInfo[$SizeofArray][4] For $i = 0 To $SizeofArray - 1 $tName = DllStructCreate("wchar[512]", DllStructGetData($taPnPDeviceIDs, 1, $i + 1)) $aDevicesInfo[$i][$eDevID] = DllStructGetData($tName, 1) $aDevicesInfo[$i][$eDevName] = _GetFriendlyName($oPortableDeviceManager, $aDevicesInfo[$i][$eDevID]) $aDevicesInfo[$i][$eDevManufacturer] = _GetDeviceManufacturer($oPortableDeviceManager, $aDevicesInfo[$i][$eDevID]) $aDevicesInfo[$i][$eDevDescription] = _GetDeviceDescription($oPortableDeviceManager, $aDevicesInfo[$i][$eDevID]) $tName = 0 _WinAPI_CoTaskMemFree(DllStructGetData($taPnPDeviceIDs, 1, $i + 1)) Next Return $aDevicesInfo EndFunc ;==>GetPortableDevices Func _GetDeviceManufacturer($oInterface, $PnPDeviceID) Local $sString = "" $oInterface.GetDeviceManufacturer($PnPDeviceID, $sString, 128) Return $sString EndFunc ;==>_GetDeviceManufacturer Func _GetDeviceDescription($oInterface, $PnPDeviceID) Local $sString = "" Local Const $Size = 128 $oInterface.GetDeviceDescription($PnPDeviceID, $sString, 128) Return $sString EndFunc ;==>_GetDeviceDescription Func _GetFriendlyName($oInterface, $PnPDeviceID) Local $sString = "" Local Const $Size = 128 $oInterface.GetDeviceFriendlyName($PnPDeviceID, $sString, 128) Return $sString EndFunc ;==>_GetFriendlyName Func _GetProperty($oInterface, $PnPDeviceID) Local $sString = "" Local Const $Size = 128 $oInterface.GetDeviceFriendlyName($PnPDeviceID, $sString, 128) Return $sString EndFunc ;==>_GetProperty Func FAILED($hr) Return ($hr < 0) EndFunc ;==>FAILED Path looks like this: \\?\usb#vid_0e8d&pid_201d&mi_00#7&37c4bb9&0&0000#{6ac27878-a6fa-4155-ba85-f98f491d4f33} I can open this in a Windows Explorer windows and it works ok. Now, search for files using AutoIt - does not work: #include <GUIConstantsEx.au3> #include <Array.au3> #include <File.au3> Local $f $f = _RecFileListToArray("\\?\usb#vid_0e8d&pid_201d&mi_00#7&37c4bb9&0&0000#{6ac27878-a6fa-4155-ba85-f98f491d4f33}", "*.*", 0, 1, 1) _ArrayDisplay($f) ; Name...........: _RecFileListToArray ; Description ...: Lists files and\or folders in a specified path (Similar to using Dir with the /B Switch) ; Syntax.........: _RecFileListToArray($sPath[, $sFilter = "*"[, $iFlag = 0[, $iRecur = 0[, $iFullPath = 0]]]]) ; Parameters ....: $sPath - Path to generate filelist for. ; $sFilter - Optional the filter to use, default is *. Search the Autoit3 helpfile for the word "WildCards" For details. ; $iFlag - Optional: specifies whether to return files folders or both ; |$iFlag=0 (Default) Return both files and folders ; |$iFlag=1 Return files only ; |$iFlag=2 Return Folders only ; $iRecur - Optional: specifies whether to search in subfolders ; |$iRecur=0 (Default) Do not search in subfolders ; |$iRecur=1 Search in subfolders ; $iFullPath - Optional: specifies whether to include initial path in result string ; |$iFullPath=0 (Default) Do not include initial path ; |$iFullPath=1 Include initial path ; Return values .: @Error - 1 = Path not found or invalid ; |2 = Invalid $sFilter ; |3 = Invalid $iFlag ; |4 = Invalid $iRecur ; |5 = Invalid $iFullPath ; |6 = No File/Folder Found ; Author ........: SolidSnake <MetalGX91 at GMail dot com> ; Modified.......: 22 Jan 09 by Melba23 - added recursive search and full path options ; Remarks .......: The array returned is one-dimensional and is made up as follows: ; $array[0] = Number of Files\Folders returned ; $array[1] = 1st File\Folder ; $array[2] = 2nd File\Folder ; $array[3] = 3rd File\Folder ; $array[n] = nth File\Folder ; Related .......: ; Link ..........; ; Example .......; Yes ; ==================================================================================================== ;Special Thanks to Helge and Layer for help with the $iFlag update ; speed optimization by code65536 ;=============================================================================== Func _RecFileListToArray($sPath, $sFilter = "*", $iFlag = 0, $iRecur = 0, $iFullPath = 0) Local $asFileList[1], $sFullPath If Not FileExists($sPath) Then Return SetError(1, 1, "") If StringRight($sPath, 1) <> "\" Then $sPath = $sPath & "\" If (StringInStr($sFilter, "\")) Or (StringInStr($sFilter, "/")) Or (StringInStr($sFilter, ":")) Or (StringInStr($sFilter, ">")) Or (StringInStr($sFilter, "<")) Or (StringInStr($sFilter, "|")) Or (StringStripWS($sFilter, 8) = "") Then Return SetError(2, 2, "") If Not ($iFlag = 0 Or $iFlag = 1 Or $iFlag = 2) Then Return SetError(3, 3, "") If Not ($iRecur = 0 Or $iRecur = 1) Then Return SetError(4, 4, "") If $iFullPath = 0 Then $sFullPath = $sPath ElseIf $iFullPath = 1 Then $sFullPath = "" Else Return SetError(5, 5, "") EndIf _FLTA_Search($sPath, $sFilter, $iFlag, $iRecur, $sFullPath, $asFileList) If $asFileList[0] = 0 Then Return SetError(6, 6, "") Return $asFileList EndFunc ;==>_FileListToArray ; #INTERNAL_USE_ONLY#================================================================================= ; Name...........: _FLTA_Search ; Description ...: Searches folder for files and then recursively searches in subfolders ; Syntax.........: _FLTA_Search($sStartFolder, $sFilter, $iFlag, $iRecur, $sFullPath, ByRef $asFileList) ; Parameters ....: $sStartFolder - Value passed on from UBound($avArray) ; $sFilter - As set in _FileListToArray ; $iFlag - As set in _FileListToArray ; $iRecur - As set in _FileListToArray ; $sFullPath - $sPath as set in _FileListToArray ; $asFileList - Array containing found files/folders ; Return values .: None ; Author ........: Melba23 based on code from _FileListToArray by SolidSnake <MetalGX91 at GMail dot com> ; Modified.......: ; Remarks .......: This function is used internally by _FileListToArray. ; Related .......: ; Link ..........; ; Example .......; ; ==================================================================================================== Func _FLTA_Search($sStartFolder, $sFilter, $iFlag, $iRecur, $sFullPath, ByRef $asFileList) Local $hSearch, $sFile If StringRight($sStartFolder, 1) <> "\" Then $sStartFolder = $sStartFolder & "\" ; First look for filtered files/folders in folder $hSearch = FileFindFirstFile($sStartFolder & $sFilter) If $hSearch > 0 Then While 1 $sFile = FileFindNextFile($hSearch) If @error Then ExitLoop Switch $iFlag Case 0; Both files and folders If $iRecur And StringInStr(FileGetAttrib($sStartFolder & $sFile), "D") <> 0 Then ContinueLoop Case 1; Files Only If StringInStr(FileGetAttrib($sStartFolder & $sFile), "D") <> 0 Then ContinueLoop Case 2; Folders only If StringInStr(FileGetAttrib($sStartFolder & $sFile), "D") = 0 Then ContinueLoop EndSwitch If $iFlag = 1 And StringInStr(FileGetAttrib($sStartFolder & $sFile), "D") <> 0 Then ContinueLoop If $iFlag = 2 And StringInStr(FileGetAttrib($sStartFolder & $sFile), "D") = 0 Then ContinueLoop _FLTA_Add($asFileList, $sFullPath, $sStartFolder, $sFile) WEnd FileClose($hSearch) ReDim $asFileList[$asFileList[0] + 1] EndIf If $iRecur = 1 Then ; Now look for subfolders $hSearch = FileFindFirstFile($sStartFolder & "*.*") If $hSearch > 0 Then While 1 $sFile = FileFindNextFile($hSearch) If @error Then ExitLoop If StringInStr(FileGetAttrib($sStartFolder & $sFile), "D") And ($sFile <> "." Or $sFile <> "..") Then ; If folders needed, add subfolder to array If $iFlag <> 1 Then _FLTA_Add($asFileList, $sFullPath, $sStartFolder, $sFile) ; Recursive search of this subfolder _FLTA_Search($sStartFolder & $sFile, $sFilter, $iFlag, $iRecur, $sFullPath, $asFileList) EndIf WEnd FileClose($hSearch) EndIf EndIf EndFunc ; #INTERNAL_USE_ONLY#================================================================================= ; Name...........: _FLTA_Add ; Description ...: Searches folder for files and then recursively searches in subfolders ; Syntax.........: _FLTA_Add(ByRef $asFileList, $sFullPath, $sStartFolder, $sFile) ; Parameters ....: $asFileList - Array containing found files/folders ; $sFullPath - $sPath as set in _FileListToArray ; $sStartFolder - Value passed on from UBound($avArray) ; $sFile - Full path of file/folder to add to $asFileList ; Return values .: Function only changes $asFileList ByRef ; Author ........: Melba23 based on code from _FileListToArray by SolidSnake <MetalGX91 at GMail dot com> ; Modified.......: ; Remarks .......: This function is used internally by _FileListToArray. ; Related .......: ; Link ..........; ; Example .......; ; ==================================================================================================== Func _FLTA_Add(ByRef $asFileList, $sFullPath, $sStartFolder, $sFile) Local $sAddFolder $asFileList[0] += 1 If UBound($asFileList) <= $asFileList[0] Then ReDim $asFileList[UBound($asFileList) * 2] If $sFullPath = "" Then $sAddFolder = $sStartFolder Else $sAddFolder = StringReplace($sStartFolder, $sFullPath, "") EndIf $asFileList[$asFileList[0]] = $sAddFolder & $sFile EndFunc File copy using Autoit - does not work: FileCopy("\\?\usb#vid_0e8d&pid_201d&mi_00#7&37c4bb9&0&0000#{6ac27878-a6fa-4155-ba85-f98f491d4f33}\Internal storage\DCIM\Camera MX\PHOTO_20161007_123935.jpg", 'd:\Diverse 2\654\0\') Copy using Windows batch - does not work: xcopy /Y /E "\\?\usb#vid_0e8d&pid_201d&mi_00#7&37c4bb9&0&0000#{6ac27878-a6fa-4155-ba85-f98f491d4f33}\Internal storage\DCIM\*.*" "d:\Diverse 2\654\0\"
  8. This peace of code does not work. I'm trying to copy all my usb files to desktop. What is wrong with it? DirCopy("E:", @DesktopDir & "\Backups\MyWork", $FC_OVERWRITE) ;Tried also this, not working. DirCopy("E:\", @DesktopDir & "\Backups\MyWork\", $FC_OVERWRITE)
  9. How do I close a usb pop up window with auto it. If one plugs in a usb a pop up window appears like "would you like to check and repait the device..." The window has a window class of #32770, since I have to open permanently another window with that same class, I cannot WinClose("[#32770]"). Is it possible to close the window with it's Basic Control Info Class? In this case it would be 'DirectUIHWND'
  10. Just like it says in the title. A scripter from my company gave me a script to make it run, but he's not around anymore, and my drive finally failed with no working backup. I run PortableRoboForm (http://www.roboform.com/for-usb-roboform2go-windows) version 6 from a USB drive to automate password management for hundreds of accounts with different passwords.RoboForm lets me do this, and they even have a Portable version, but it's not that portable and I'd like to use it inside a PortableApps (http://portableapps.com/) launcher. I'd like to create a script to go to the root of the USB drive and run "PortableRoboForm.exe". PortableApps only sees executables in subdirectories of the \PortableApps folder of the USB drive. RoboForm2Go only installs and executes in the root directory of the USB drive. I tried using the fantastic little _GetFileDrive function, but I keep getting an error indicating it's trying to run the file in the subdirectory so obviously I'm not using _GetFileDrive right. Any help for a newbie would be appreciated. ; Change the working directory to the root of this file. FileChangeDir(_GetFileDrive(@ScriptDir)) ; Run the PortableRoboForm executable. Run(PortableRoboForm.exe,"") ; Get the drive letter of a filepath. Idea from _PathSplit. Func _GetFileDrive($sFilePath) Return StringLeft($sFilePath, StringInStr($sFilePath, ":", 2, 1) + 1) EndFunc ;==>_GetFileDriveEDIT: Nevermind, found the option to set it up to run from the PortableApps menu.
  11. I want to know that is there any way to detect an USB device when it gets plugged into the system and call some function connected to that event? I was able to do this using C#, there is a class available, but I am wondering if the same can be done with autoIT by any chance. Thank You
  12. I had problem differentiating drives of system and External drives as they're both of same type - "FIXED" when using DriveGetDrive and DriveGetType, so managed to make a small script to detect External ones. Im a newb, so you may will find silly, unnecessary code which could have been done better with smart work instead of hard work, if you know what i mean #include <Array.au3> Local $drivelist = DriveGetDrive("FIXED"), $addspace = 0, $getspace, $systemdrives, $externaldrives ;~ _ArrayDisplay($drivelist) findexthdd() Func findexthdd() RunWait(@ComSpec & " /c " & 'wmic diskdrive get PNPDeviceID, size /format:csv | find /v "USBSTOR" > wmic.txt', @ScriptDir, @SW_HIDE) $file = FileOpen("wmic.txt") $readfile = FileRead($file) $readfile = StringSplit($readfile, ",") ;~ _ArrayDisplay($readfile) $last = $readfile[0] $totalsize = $readfile[$last] $totalsize = $totalsize / 1024 / 1024 / 1024 ;MB Do Local $c = 1 $totalsize = StringTrimRight($totalsize, $c) $c = $c + 1 $return = StringInStr($totalsize, ".") Until $return = 0 $return = 1 For $w = 1 To UBound($drivelist) - 1 $getspace = DriveSpaceTotal($drivelist[$w]) / 1024 Do Local $z = 1 $getspace = StringTrimRight($getspace, $z) $z = $z + 1 $return = StringInStr($getspace, ".") Until $return = 0 $addspace += $getspace If $addspace <= $totalsize Then ;463 vs 465 $systemdrives &= $drivelist[$w] & "," Else ;~ MsgBox(0, "", $drivelist[$w] & " is the f****** external hard drive!") $externaldrives &= $drivelist[$w] & "," EndIf Next $systemdrives = StringTrimRight($systemdrives, 1) $systemdrives = StringSplit($systemdrives, ",") _ArrayDisplay($systemdrives, "SYSTEM DRIVES LIST") $externaldrives = StringTrimRight($externaldrives, 1) $externaldrives = StringSplit($externaldrives, ",") _ArrayDisplay($externaldrives, "EXTERNAL DRIVES LIST") EndFunc ;==>findexthdd
  13. Ever wanted to use Autoit to lock up your flash drive at home? Well here's the code for it. Code from user LvlUp and some minor modification from me. All props to LvlUp and his coding abilities and assistance with this code. Here's the main code: #NoTrayIcon #include <Misc.au3> #include <eject.au3> Opt("TrayMenuMode",1) $menu = TrayCreateItem("DriveLocker") $menu2 = TrayCreateItem("") $menuLock = TrayCreateItem("Lock Drive") $menuExit = TrayCreateItem("Exit") TraySetState() While 1 $letter = DriveGetDrive("REMOVABLE") If IsArray($letter) Then For $i = 1 to $letter[0] _Check($letter[$i]) Next EndIf $time = TimerInit() While TimerDiff($time) < 10000 $msg = TrayGetMsg() TrayItemSetState($msg,4) Select Case $msg = $menuLock _LockDrive() Case $msg = $menuExit Exit EndSelect Sleep(100) WEnd WEnd Func _Check($strDriveLetter) If FileExists($strDriveLetter & "\IAmLocked") Then _Unlock($strDriveLetter) EndFunc Func _Unlock($strDriveLetter) $strPassword = InputBox("Security Check", "Enter your password.", "", "*", "", "", @DesktopWidth/2, @DesktopHeight/2,15, "passwordBox") ToolTip("Enter Password NOW.") _MouseTrap(@DesktopWidth, @DesktopHeight-100) If ($strPassword = "password") Then _MouseTrap() FileDelete($strDriveLetter & "\IAmLocked") _ReAnimate($strDriveLetter) Else EjectVolume($strDriveLetter) _MouseTrap() EndIf EndFunc Func _ReAnimate($strDriveLetter) ;Closes the autoplay window if open WinClose("AutoPlay") EndFunc Func _LockDrive() $letter = DriveGetDrive("REMOVABLE") If IsArray($letter) Then For $i = 1 To $letter[0] If MsgBox(36,"Lock This Drive?","Do you wish to lock the " & StringUpper($letter[$i]) & " drive?") = 6 Then FileWrite($letter[$i] & "\IAmLocked","Locked") EjectVolume($letter[$i]) EndIf Next EndIf EndFunc And the includes file for eject.au3 #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <WinApi.au3> ;Prototypes ;BOOL EjectVolume(TCHAR cDriveLetter); ;HANDLE OpenVolume(TCHAR cDriveLetter); ;BOOL LockVolume(HANDLE hVolume); ;BOOL DismountVolume(HANDLE hVolume); ;BOOL PreventRemovalOfVolume(HANDLE hVolume, BOOL fPrevent); ;BOOL AutoEjectVolume(HANDLE hVolume); ;BOOL CloseVolume(HANDLE hVolume); ;StringFormat Output $szVolumeFormat = "\\\\.\\%s" $szRootFormat = "%s\\" $szErrorFormat = "Error %d: %s\n" ;------------------------------------------ ;Arbitrary variables ;;Global Const $INVALID_HANDLE_VALUE = 0 ;------------------------------------------ ;DeviceIoControl Contants Global Const $FSCTL_LOCK_VOLUME = int(0x090018) Global Const $FSCTL_DISMOUNT_VOLUME = int(0x00090020) Global Const $IOCTL_STORAGE_EJECT_MEDIA = int(0x002D4808) Global Const $IOCTL_STORAGE_MEDIA_REMOVAL = int(0x002D4804) ;------------------------------------------ ;Retry Constants Global Const $LOCK_TIMEOUT = 10000 ; 10 Seconds Global Const $LOCK_RETRIES = 20 ;$OpenVolume = InputBox("Ejecting...", "Enter the drive to eject", "G:") ;ConsoleWrite("Trying to Eject the drive " & EjectVolume($OpenVolume) & @crlf) Func ReportError($szMsg) ConsoleWrite(StringFormat($szErrorFormat, _WinAPI_GetLastErrorMessage (), $szMsg) & @CRLF) Exit EndFunc ;==>ReportError Func OpenVolume($cDriveLetter) ;HANDLE hVolume ;UINT uDriveType ;TCHAR szVolumeName[8] ;TCHAR szRootName[5] ;DWORD dwAccessFlags $szRootName = StringFormat($szRootFormat, $cDriveLetter) $uDriveType = DriveGetType($szRootName); ConsoleWrite($szRootName & @tab & $uDriveType & @crlf) Switch $uDriveType Case "Removable" $dwAccessFlags = 6 Case "CDROM" $dwAccessFlags = 2 Case Else ConsoleWrite("Cannot eject. Drive type is incorrect." & @CRLF) Return $INVALID_HANDLE_VALUE EndSwitch $szVolumeName = StringFormat($szVolumeFormat, $cDriveLetter) ;$szVolumeName = $szVolumeFormat & $cDriveLetter ConsoleWrite($szVolumeName & @crlf ) $hVolume = _WinAPI_CreateFile ($szVolumeName, 2,$dwAccessFlags, 6) #cs hVolume = CreateFile( szVolumeName, dwAccessFlags, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL ); #ce If ($hVolume == $INVALID_HANDLE_VALUE) Then ReportError("CreateFile"); Return $hVolume; EndFunc ;==>OpenVolume Func CloseVolume($hVolume) Return _WinAPI_CloseHandle ($hVolume); EndFunc ;==>CloseVolume Func LockVolume($hVolume) Local $dwBytesReturned Local $dwSleepAmount Local $nTryCount local $iRead $dwSleepAmount = $LOCK_TIMEOUT / $LOCK_RETRIES; ; Do this in a loop until a timeout period has expired For $nTryCount = 0 To $nTryCount < $LOCK_RETRIES If _Device_Control($hVolume, $FSCTL_LOCK_VOLUME, $iRead) Then Return True Else Sleep($dwSleepAmount); EndIf Next Return False; EndFunc ;==>LockVolume Func DismountVolume($hVolume) ConsoleWrite("Dismount " & $hVolume & @crlf) Local $dwBytesReturned, $iRead local $aResult = _Device_Control($hVolume, $FSCTL_DISMOUNT_VOLUME, $iRead) ;msgbox(0,"",$aResult) Return $aResult ;Return $dwBytesReturned EndFunc ;==>DismountVolume Func PreventRemovalOfVolume($hVolume, $fPreventRemoval) Local $dwBytesReturned Local $aResult Local $lpInbuffer,$nInBufferSize,$lpOutBuffer,$nOutBufferSize,$lpOverlapped $PMRBUFFER = DllStructCreate("bool PreventMediaRemoval") DllStructSetData($PMRBUFFER,"PreventMediaRemoval",$fPreventRemoval) $lpBytesReturned = DllStructCreate("int Read") $pRead = DllStructGetPtr($lpBytesReturned, "Read") $aResult = Dllcall("kernel32.dll","int","DeviceIoControl","hwnd",$hVolume,"uint",$IOCTL_STORAGE_MEDIA_REMOVAL,"ptr",DllStructGetPtr($PMRBUFFER),"uint",DllStructGetSize($PMRBUFFER), _ "ptr",$lpOutBuffer,"uint",$nOutBufferSize,"ptr",$pRead,"ptr",$lpOverlapped) if $aResult = 0 then msgbox(0,"",_WinAPI_GetLastErrorMessage()) Return $aResult <> 0 ;& PMRBuffer, sizeof (PREVENT_MEDIA_REMOVAL), ;NULL, 0, ; & dwBytesReturned, ;NULL); EndFunc ;==>PreventRemovalOfVolume Func AutoEjectVolume($hVolume) Local $aResult, $iRead; $aResult = _Device_Control($hVolume, $IOCTL_STORAGE_EJECT_MEDIA, $iRead) Return $aResult EndFunc ;==>AutoEjectVolume Func EjectVolume($cDriveLetter) Local $hVolume; Local $fRemoveSafely = False; Local $fAutoEject = False; ; Open the volume. $hVolume = OpenVolume($cDriveLetter); If $hVolume == $INVALID_HANDLE_VALUE Then Return False ; Lock and dismount the volume. If LockVolume($hVolume) And DismountVolume($hVolume) Then $fRemoveSafely = True; ConsoleWrite("Volume Locked and Dismounted, trying to Eject " & @crlf) ; Set prevent removal to false and Eject the volume. If PreventRemovalOfVolume($hVolume, False) And AutoEjectVolume($hVolume) Then $fAutoEject = True; EndIf Else ConsoleWrite("Volume can't be locked or dismounted, please close possible opened files" & @crlf) EndIf ; Close the volume so other processes can use the drive. If CloseVolume($hVolume) = False Then Return False; EndIf If $fAutoEject Then ConsoleWrite(StringFormat("Media in drive %s has been ejected safely.\n", $cDriveLetter)) Else If $fRemoveSafely Then ConsoleWrite(StringFormat("Media in drive %s can be safely removed.\n", $cDriveLetter)) EndIf EndIf Return True; EndFunc ;==>EjectVolume Func _Device_Control($hDevice, $dwIoControlAutoit, ByRef $iRead) Local $aResult Local $lpInbuffer,$nInBufferSize,$lpOutBuffer,$nOutBufferSize,$lpOverlapped $tRead = DllStructCreate("int Data") $aResult = Dllcall("kernel32.dll","int","DeviceIoControl","hwnd",$hDevice,"uint",$dwIoControlAutoit,"ptr",$lpInBuffer,"uint",0, _ "ptr",$lpOutBuffer,"uint",0,"ptr",DllStructGetPtr($tRead),"ptr",$lpOverlapped) $iRead = DllStructGetData($tRead, "Data") ConsoleWrite("Device Control " & $iRead & @CRLF) Return $aResult<>0 EndFunc ;==>_Device_Control Enjoy.
  14. Hi, I'm trying to develope a program to safely eject an USB device. I have tried a lot of way but there was no satisfactory result. I used to consult wraithdu's script here : but that script wasn't work on my Win7 machine, then I heard someone talk about Devcon, then I started to explore it, I have scripted, tested for days and get nothing but errors. I used this command : devcon remove @usb\* to remove all removable devices but here the result goes : All failed? I have just plugged on two USB Kingmax and Transcend! I need some professional guys to solve the problem:D Thanks!
  15. Hi all, First of all, not sure whether to post this here or example scripts as although it works it does have a problem This is my first script I have made with AutoIT, its very basic but does some deployment tasks to make my life easier. Script: 2 Questions: 1, Why doesn't this part work? If the Computer has a floppy disk, the script still tries to read it even though I have specified no A:\ When it tries to read A:\ the files do not copy from the usb stick & then the script continues to add users to admins. ; Locate USB Drive & assigned drive letter, then copy files. $var = DriveGetDrive( "removable" ) If NOT @error Then For $i = 1 to $var[0] If $var[$i] = "a:" Then ContinueLoop $usbdrive = $var[$i] 2, Can you suggest any improvements to the code, as I've said this is my first one and I've never tried scripting before.
  16. I'm running Windows 7. I have an autorun.inf file on a removable drive that looks like this: [autorun] label=My Drive Label When I plug in that USB drive and open Windows Explorer, I see that drive properly labeled. It says "My Drive Label (G:)" next to the drive icon. However, I can't figure out how to read that label (without reading the ini file, of course). If I use DriveGetLabel("G:"), it returns the string that is stored when you right-click the drive and select properties and type in a label. I can't figure out how to make it return the label that is displayed in Windows Explorer. Any ideas?
  17. I have searched the forum and really can't find what I'm looking for. I would like to find a script that can scan a computer and find devices plugged into a USB port that DOESN'T have a drive letter. I can detect devices that have a drive letter without a problem, but what I'm looking for are devices that don't produce a drive letter but show up as say an "Audio Device". Some personal audio devices show up as a device of this type and they are not assigned a drive letter. This is what I want to find. A flatbed scanner would show up as an imaging device. Any help would be appreciated.
  18. Note: This is completely unrelated to the program offered on TuCows and CNET, I named it without ever checking the title, and I may decide to change it at will. What Does it do? This program allows you to require a specific drive (USB preferably) to be connected to the computer to gain access while the program is running. Downloads: USBLock.zip (Includes Source code, Compiled version, and English .LANG file) UPDATES: (click "see post" to see notes on changes) Version 6: see post Version 5: see post Version 4: see post Version 3: see post Version 2: see post ----------------------------------- -How does it do it? 1a. On a normal run, the program will ask you for a drive letter to assign as a "Key Drive". 1b. A drive letter is assigned by command-line parameter. 1c. The "auto" parameter is used, and we skip to Step 4. 2. The Program will then generate a random keyfile, save a hash of the keyfile locally and save the actual keyfile on the root of the chosen/validated drive. 3. Waits until the keydrive is removed. 4. BlockInput is called 5. Then the program then checks repeatedly for the existence of the keyfile on all drives 6. The keyfile is validated, if it is valid, BlockInput is released and we return tp Step 2. 7. Assuming the keyfile is invalid, it is deleted and we return to step 5. Note: There is a special keyfile that can be saved on a drive that will shut down the program to allow emergency access. (if you edit the emergency text in the script, you will need to edit your own emergency keyfile) USBLock_Emergency_Keyfile.zip Requirements: WindowsConstants.au3 GUIConstants.au3 StaticConstants.au3 String.au3 Misc.au3 myToast.au3 - by me (given) MD5.au3 - which is either by: - Ward (Using CallWindowProc; I suggest this one.) - Frez Systems Ltd and SvenP (all AutoIt) - Other Credits: Monitor On/Off Example - MrCreatoR MD5 - SvenP or Ward ... let me know if you were missed for credit. EDIT: fixed the "steps" explanation 5-5-13 Edit: Re-added images to post
×
×
  • Create New...