Jump to content

divadnivip007

Members
  • Posts

    12
  • Joined

  • Last visited

divadnivip007's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. Another quick question, If I wanted to check if another usb device is connected or disconnected how would the code change. I tried to make to of the same code but it didint worked. Here is the same script but by adding a second usb device. I want to run a different program depending on the usb that is connected. ;Gamepad XBOX_360_DEVICE_00:00 HotKeySet("{ESC}", "_Exit") Global $sDeviceProperty = "PNPDeviceID" ;Caption, Description, DeviceID, Name, PNPDeviceID Global $sUSBDevice = "USB\VID_045E&PID_02A1&IG_00\6&366022B6&1&00" ;property value for Caption, Description, DeviceID, Name or PNPDeviceID. For PNPDeviceID : Find --> Device Instance Path. Global $sUSBDevice = "USB\VID_045E&PID_02A1&IG_02\6&366022B6&1&02" ;second usb device Global $fDeviceActive = _FindUSBDevice($sDeviceProperty) ;initialize variable with device state. global var prevents retriggering by other device insertion/removal If $fDeviceActive = -1 Then ConsoleWrite("! Error finding device: " & @error & @LF) ConsoleWrite("> Monitoring - Press ESC to Exit: " & @LF) _Main() Func _Main() Local Const $WM_DEVICE_CHANGE = 0x0219 GUICreate("") ;dummy gui for receiving window messaging GUIRegisterMsg($WM_DEVICE_CHANGE, "_WM_DEVICE_CHANGE") While 1 Sleep(1000) WEnd EndFunc ;==>_Main Func _Exit() Exit EndFunc ;==>_Exit Func _WM_DEVICE_CHANGE($hWnd, $Msg, $wParam, $lParam) #forceref $hWnd, $Msg, $wParam, $lParam Local Const $DBT_DEVNODES_CHANGED = 0x00000007 If $wParam = $DBT_DEVNODES_CHANGED Then Switch _FindUSBDevice($sDeviceProperty) Case 1 If Not $fDeviceActive Then ;check current state buffer to prevent events from other usb devices $fDeviceActive = True Run("Whatever program") ; when 1 usb device is connected Run("Whatever program") ; when 2 usb device is connected EndIf Case 0 If $fDeviceActive Then ;check current state buffer to prevent events from other usb devices $fDeviceActive = False ConsoleWrite("! Device Disconnected" & @LF) EndIf Case -1 ConsoleWrite("! WMI Error: " & @error & @LF) EndSwitch EndIf Return "GUI_RUNDEFMSG" EndFunc ;==>_WM_DEVICE_CHANGE Func _FindUSBDevice($sProperty = "*", $strComputer = ".") Local $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2") If @error Then Return SetError(1, 0, -1) Local $colDevices = $objWMIService.ExecQuery("Select Dependent From Win32_USBControllerDevice") ;Select Dependent instead of Select * - limit items in collection to speed up response slightly If Not IsObj($colDevices) Then Return SetError(2, 0, -1) Local $arrDeviceNames, $colUSBDevices For $objDevice In $colDevices $arrDeviceNames = StringSplit(StringReplace($objDevice.Dependent, Chr(34), ""), "=", 2) If @error Or UBound($arrDeviceNames) <> 2 Then Return SetError(3, 0, -1) $colUSBDevices = $objWMIService.ExecQuery("Select " & $sProperty & " From Win32_PnPEntity Where DeviceID = '" & $arrDeviceNames[1] & "'");Select $sProperty instead of Select * - limit items in collection to speed up response slightly If Not IsObj($colUSBDevices) Then Return SetError(4, 0, -1) For $objUSBDevice In $colUSBDevices ;ConsoleWrite("USB Description: " & Execute("$objUSBDevice." & $sProperty) & @LF) If (Execute("$objUSBDevice." & $sProperty) == $sUSBDevice) Then Return 1 ;device found If @error Then Return SetError(5, 0, -1) Next Next Return 0 ;device not found EndFunc ;==>_FindUSBDevice Thx for your help Dave
  2. Hi everyone, I am migrating all my Eventghost configuration to AutoIt for my HTPC. I am using the official PS3 Blu-Ray Disc Controller. For now I use a program called "PS3 Blumote" that I can map keyboard keys to it. I then have to make a script in AutoIt: #include < Misc.au3 > HotKeySet("{NUMPAD0}", "Terminate") While 1 WEnd Func Terminate() Run("C:\Program Files (x86)\XBMC\XBMC.exe" ) Exit 0 EndFunc I dont want to use the PS3 Blu mote software. I would like to have a script like the one of Djarlo Westmaas for the Xbox 360 controller but for the PS3 BD Controller : #include-once #Region _IsPressed360 ; #FUNCTION# ==================================================================================================================== ; Name...........: _IsPressed360 ; Description ...: Checks if key on Xbox360 controller has been pressed ; Syntax.........: _IsPressed360($iKey[, $vDLL = 'user32.dll']) ; Parameters ....: $iKey - Key to check for ; $vDLL - Handle to dll or default to user32.dll ; Return values .: True - 1 ; False - 0 ; Author ........: Djarlo Westmaas (with the help of scripts made by Oxin8, ezzetabi and Jon) ; Modified.......: ; Remarks .......: If calling this function repeatidly, you should open 'xinput9_1_0.dll' and pass in handle. ; Make sure to close at end of script ; If requesting state of one of the Joysticks or triggers its press value will be returned as @extended ; -32768 Y ; 1 Up ; 2 Down ; 4 Left ; 8 Right ; 16 Start ; 32 Back ; 64 LeftJoyStick ; 128 RightJoyStick ; 256 LB ; 512 RB ; 4096 A ; 8192 B ; 16384 X ; 32768 LeftTrigger (@extended 0 - 255) ; 65536 RightTrigger (@extended 0 - 255) ; 131072 LeftJoyStick-X (@extended -32768 - 32767) ; 262144 LeftJoyStick-Y (@extended -32768 - 32767) ; 524288 RightJoyStick-X (@extended -32768 - 32767) ; 1048576 RightJoyStick-Y (@extended -32768 - 32767) ; Related .......: ; Link ..........: http://www.autoitscript.com/forum/topic/133663-udf-ispressed360au3-xbox360-controller/ ; Example .......: Yes ; =============================================================================================================================== Func _IsPressed360($iKey, $vDLL = 'xinput9_1_0.dll') Local $hStruct, $iValue = 0 $hStruct = DllStructCreate("dword;short;ubyte;ubyte;short;short;short;short") If DllCall($vDLL, "long", "XInputGetState", "long", 0, "ptr", DllStructGetPtr($hStruct)) = 0 Then Return SetError(5, 0, False) If @error Then Return SetError(@error, @extended, False) Select Case $iKey < 16385 Return Number(BitAND($iKey, DllStructGetData($hStruct, 2)) <> 0) Case $iKey = 32768 $iValue = DllStructGetData($hStruct, 3) If $iValue > 10 Then Return SetError(0, $iValue, 1) Case $iKey = 65536 $iValue = DllStructGetData($hStruct, 4) If $iValue > 10 Then Return SetError(0, $iValue, 1) Case $iKey = 131072 $iValue = DllStructGetData($hStruct, 5) If $iValue > 10000 Or $iValue < -10000 Then Return SetError(0, $iValue, 1) Case $iKey = 262144 $iValue = DllStructGetData($hStruct, 6) If $iValue > 10000 Or $iValue < -10000 Then Return SetError(0, $iValue, 1) Case $iKey = 524288 $iValue = DllStructGetData($hStruct, 7) If $iValue > 10000 Or $iValue < -10000 Then Return SetError(0, $iValue, 1) Case $iKey = 1048576 $iValue = DllStructGetData($hStruct, 8) If $iValue > 10000 Or $iValue < -10000 Then Return SetError(0, $iValue, 1) EndSelect Return SetError(0, $iValue, 0) EndFunc ;==>_IsPressed360 #EndRegion _IsPressed360 Can anyone point me to the right direction. Windows 7 pairs it with bluetooth and then assigns a driver. I don't know how to find the .dll that it works with? Thx Dave
  3. It works perfectly!!!! It is much more faster to sense if the drive connects or disconnects then the other code that I posted!!!! You make my day Unmutual Thx!! Dave
  4. Thx unmutual, Is your code supposed to tell if there is a device change? Do i have to change part of the code? Sorry but I'm a newbie. I've run into another thread from someone. When I start my ps3 controller, and when I disconnect the controller, a GUI pops up and says "Token Removed ". I don't have a clue of what it does but I think it can lead to the right direction. The code detects changes from any usb dongle. Here is the code : Global $Paused HotKeySet("{Pause}","TogglePause") $WM_DEVICE_CHANGE = 0x0219 $DBT_DEVNODES_CHANGED = "0x00000007" GUICreate("") GUIRegisterMsg($WM_DEVICE_CHANGE , "MyFunc") Func MyFunc($hWndGUI, $MsgID, $WParam, $LParam) If $WParam == $DBT_DEVNODES_CHANGED Then If($PAUSED <> True)Then tokenChk() EndIf EndIf EndFunc While 1 $GuiMsg = GUIGetMsg() WEnd Func TogglePause() $Paused = NOT $Paused While $Paused sleep(100) ToolTip('Script is "Paused"',0,0) WEnd ToolTip("") EndFunc Func tokenChk() $mcount = 0 $strComputer = "." $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2") $colDevices = $objWMIService.ExecQuery ("Select * From Win32_USBControllerDevice") For $objDevice in $colDevices $strDeviceName = $objDevice.Dependent $strQuotes = Chr(34) $strDeviceName = StringReplace($strDeviceName, $strQuotes, "") $arrDeviceNames = StringSplit($strDeviceName, "=") $strDeviceName = $arrDeviceNames[2] $colUSBDevices = $objWMIService.ExecQuery ("Select * From Win32_PnPEntity Where DeviceID = '" & $strDeviceName & "'") For $objUSBDevice in $colUSBDevices If($objUSBDevice.Description == "USB Token")Then $mcount = 1 MsgBox(0,"USB Description",$objUSBDevice.Description) MsgBox(0,$objUSBDevice.Description,$objUSBDevice.Manufacturer) EndIf Next Next If ($mcount<>1)Then MsgBox(0,"Alert!","Token Removed") EndIf EndFunc
  5. file:///C:/Users/Mistgun/Desktop/New%20Bitmap%20Image.bmp Thx guys for your fast response, It works great with usb with a letter in windows ex. G\:, D:\. What I want is to know when a USB bluetooth dongle is connected to the computer. The dongle is listed in the Device and Printers. (See image below). I have tried with other functions like DriveGet"serials" but it dosent work. Is my USB bluetooth dongle a Drive? Maybe there is another function for this sort of dongle. Here are the information that I can have (See the image for the complete list): - Manufacturer ID - Address ex : (00:11:67:d6:01:37) - The location ex: Port_#0002.Hub_#0001 - The adapter MAC ex: 57.0a.3d.83.15.00 This is the complete list of what information i can obtain:
  6. Hi everyone, I have search the forum for a couple of hours without finding a clue to where to begin with my problem. Here is what I want: I want to be able to start a program when a SPECIFIC usb device is connected. I want it to work also regardless of the usb port. (I have a usb bluetooth dongle paired with a PS3 Controller. When I put it on from the controller, the dongle connects. It does the same thing as if I would have a usb plugged in the PC.) What I would like it to be able to do is something like this: If usb_id "0A56D777E" is connected Then Run : '''whatever application' Any help is appreciated. Maybe there is already something similar to what I want to achieve. Thx Dave
  7. There is also an error in Advance-Launcher or XBMC. If the laucher's (begining) name is the same as the program and is in the same directorie, it will open the program and not the launcher. Here is an exemple: My autoIt script is named like this. SSF (E)-Launcher.exe (C:EmulatorsSega Saturn) The program is named like this. SSF.exe (C:EmulatorsSega Saturn) With this configuration even though the launcher is redirected to SSF (E)-Launcher.exe it will open SSF.exe instead! Solutions : - Name your launcher differently (Ex: Launcher-SSF.exe) - Put the launcher in a different directory (Ex: Put SSF (E)-Launcher.exe to "C:Emulators" instead of "C:EmulatorsSega Saturn") Will try to see if it's a bug from XBMC or Advanced Launcher Dave
  8. I've solved my problem!! When I was using Clone Virtual Drive I was opening the .iso of the game. Now with Daemon Tools I was able to open the game with the .cue file format. 80% of my roms had errors in the .cue file. That is why when i tried my script it didin't mount the rom. Yup I'm using XBMC as the GUI with AdvanceLauncher for all my games. Thx for helping me!!!
  9. I am trying to mount a .cue file image in XBMC via Advance Launcher. I was using virtual clone drive and it worked pretty well. The downside of virtual clone drive is that it cannot mount .cue image files. I have now switched to daemon tools. I've tried the Lite and Pro Advanced versions but it dosent mount any image file. With a batch file it works. Here is the batch file : "C:\Program Files (x86)\DAEMON Tools Lite\DTLite.exe" -mount scsi, 0,%1 Here is my script with autoIt. If $CmdLine[0] == 1 Then RunWait ( '"C:\Program Files (x86)\DAEMON Tools Lite\DTLite.exe" -mount scsi, 0,"' & $CmdLine[1] & '"') Sleep(2000) RunWait('"C:\Users\Il be back\Desktop\Windows 7 XBMC Project\Emulators\Sega\Saturn\EmuCR_SSF_012_beta_R3\SSF_012_beta_R3 (E)\SSF.exe"') EndIf While 1 WEnd Func Terminate() ProcessClose ( "SSF.exe" ) Sleep(10) RunWait( '"C:\Program Files (x86)\DAEMON Tools Lite\DTLite.exe" -unmount scsi, 0' ) Sleep(100) Run ("XBMC.exe") WinSetState("[CLASS:XBMC]", "", @SW_Maximize) Exit 0 EndFunc Thx Dave
  10. It works perfectly! Thx a lot Boththose!!
  11. Great script. Could it be changed so I don't have to hold down "F2"? I would like to send a different number every time I presses "F2" and make a infinite loop for it. Thx Dave
  12. Hey, First I am a newb with AutoIt. I've tried to do it by myself but I cannot figure how to manage the function "If is pressed again". Is there a way to do something like this: If "F2" is pressed then send "1" If "F2" is pressed again then send "2" If "F2" is pressed again send "1" If "F2" is pressed again then send "2" Here is my script so far: While 1 If _IsPressed("71") = 1 Then ;IF F2 is pressed Send("{1}") ; Send 1 Thx a lot Dave
×
×
  • Create New...