Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

Detecting if an Ipad is plugged in

Mobile devices

  • Please log in to reply
8 replies to this topic

#1 shx

shx

    Wayfarer

  • Active Members
  • Pip
  • 58 posts

Posted 26 July 2012 - 01:33 AM

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







#2 Tripredacus

Tripredacus

    K-Mart-ian Legend

  • Active Members
  • PipPipPipPipPipPip
  • 839 posts

Posted 26 July 2012 - 02:13 PM

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. ;)

#3 shx

shx

    Wayfarer

  • Active Members
  • Pip
  • 58 posts

Posted 26 July 2012 - 05:58 PM

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

#4 Tripredacus

Tripredacus

    K-Mart-ian Legend

  • Active Members
  • PipPipPipPipPipPip
  • 839 posts

Posted 27 July 2012 - 04:02 PM

Where is it in Windows? Computer?

#5 DogPaddle

DogPaddle

    Seeker

  • Normal Members
  • 3 posts

Posted 03 August 2012 - 08:09 PM

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

#6 Tripredacus

Tripredacus

    K-Mart-ian Legend

  • Active Members
  • PipPipPipPipPipPip
  • 839 posts

Posted 06 August 2012 - 04:41 PM

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.

#7 DogPaddle

DogPaddle

    Seeker

  • Normal Members
  • 3 posts

Posted 06 August 2012 - 05:37 PM

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.

#8 Tripredacus

Tripredacus

    K-Mart-ian Legend

  • Active Members
  • PipPipPipPipPipPip
  • 839 posts

Posted 06 August 2012 - 08:14 PM

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.

AutoIt         
#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


#9 DogPaddle

DogPaddle

    Seeker

  • Normal Members
  • 3 posts

Posted 07 August 2012 - 11:29 AM

Thanks, I'll use this as a study tool. I appreciate your help!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users