shx Posted July 26, 2012 Posted July 26, 2012 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
Tripredacus Posted July 26, 2012 Posted July 26, 2012 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. Twitter | MSFN | VGCollect
shx Posted July 26, 2012 Author Posted July 26, 2012 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
Tripredacus Posted July 27, 2012 Posted July 27, 2012 Where is it in Windows? Computer? Twitter | MSFN | VGCollect
DogPaddle Posted August 3, 2012 Posted August 3, 2012 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
Tripredacus Posted August 6, 2012 Posted August 6, 2012 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. Twitter | MSFN | VGCollect
DogPaddle Posted August 6, 2012 Posted August 6, 2012 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." I've done simple scripts with variables in them and somehow managed to get away without doing this.
Tripredacus Posted August 6, 2012 Posted August 6, 2012 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 Twitter | MSFN | VGCollect
DogPaddle Posted August 7, 2012 Posted August 7, 2012 Thanks, I'll use this as a study tool. I appreciate your help!
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now