Jump to content

Recommended Posts

Posted

When my Ipad is plugged into my windows7 computer I can see it appearing under mobile devices.

Is there any way for an autoit script to retrieve the mobile devices plugged in. ( or any other way of knowing if an Ipad is plugged in.

Thanks

Steven

Posted

Its quite likely that the device will appear in WMI. You should first check with WMI (use WMI Toolkit for example) to find where the device appears, then you can use that in your script. Here is an example where I check for a biometric device being present.

$sWMIService = "winmgmts:" & @ComputerName & "rootCIMV2"
$objWMIService = ObjGet($sWMIService)
IF IsObj($objWMIService) Then
    $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_PnPEntity WHERE Name LIKE '%Fingerprint%'")
    If IsObj($colItems) Then
        For $oItem In $colItems
            $sName = $oItem.Name
        Next
    EndIf
    If StringStripWS($sName, 2) = "Fingerprint" Then
      MsgBox (4096, "Success", "Fingerprint is present")
    EndIf
EndIf

In this example, the If statement at the end which generates the MsgBox has been changed from my original script and is shown as an example. But you would want to match the name to what actually shows up in the Name object for that Entity.

You can use Scriptomatic to generate the WMI script for you... seems to be a popular choice. ;)

Posted

Tripredacus,

Many thanks. Your suggestion worked.

Would you know if there is a way of opening up that device as if it was clicked in windows?

Steven

Posted

Hi Tripedacus:

I tried your script, since I am looking for something to do the same thing with smart card readers.

I'm a novice when it comes to AutoIt.

I didn't make any changes, just copied and pasted, checked syntax, and built it.

Unfortunately, I get an error from the exe, "Line 10" "Error:Variable used without being declared."

FWIW, I was actually planning to use SELECT * FROM Win32_PnPEntity WHERE ClassGuid = '{50dd5230-ba8a-11d1-bf5d-0000f805f530}' but potayto, potahto...

Thanks,

DP

Posted

I didn't make any changes, just copied and pasted, checked syntax, and built it.

Unfortunately, I get an error from the exe, "Line 10" "Error:Variable used without being declared."

That is to be expected, I only posted a snippet. You need to declare those vars in there, I usually Global them all.

Posted

Well, I guess that's part of me being a novice... that part is unfamiliar to me. Does it just consist of putting the word "global" or "local" in front of each $whatever = whatever? I tried this, and it didn't work, so I assume the answer is, "no." :mellow:

I've done simple scripts with variables in them and somehow managed to get away without doing this.

Posted

I keep an au3 file just for WMI testing... so here it is (note it has stuff you don't need and stuff commented out, etc). That being said, it is currently commented out so it tells you the Model of the computer.

#include <file.au3>
#include <array.au3>
#Include <String.au3>

Global $bin
Global $itdid, $objWMIService, $colItems, $sWMIService, $sName, $sModel, $uuItem, $objSWbemObject, $strName, $strVersion, $strWMIQuery, $objItem, $uiDitem, $strDesc
$sWMIService = "winmgmts:" & @ComputerName & "rootCIMV2"
$objWMIService = ObjGet($sWMIService)
IF IsObj($objWMIService) Then
;$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_PnPEntity WHERE Name LIKE '%Fingerprint%'")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem")
    If IsObj($colItems) Then
        For $oItem In $colItems
            ;$sName = StringRegExpReplace($oItem.NumberOfLogicalProcessors , "[/()]", "")
            ;$sModel = $oItem.Name
            $sModel = StringStripWS(StringReplace( $oItem.Model , "/" , "" ),2)
        Next
    Else
        MsgBox (4096, "Error", "Device not found")
    EndIf
MsgBox (4096, "test", "Name = " & $sModel)
EndIf

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...