Advertisement
Guest User

AlienFX UDF

a guest
Sep 11th, 2011
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 4.08 KB | None | 0 0
  1. ;BitByteBit
  2. ;AlienFX UDF.
  3. ;AutoIt ;]
  4. Global $hLightFX = @ScriptDir & '\LightFX 64x.dll', $aDefcon, $LFX_GRILL = BitAND(0x001C0E07, 0x000001FF), $aOrig[5]
  5. $SYSTEM_POWER_STATUS = DllStructCreate("byte;byte;byte;byte;int;int")
  6. $PTR = DllStructGetPtr($SYSTEM_POWER_STATUS)
  7. OnAutoItExitRegister('_AlienClose')
  8. _AlienStart()
  9. Func _AlienClose()
  10.     DllCall($hLightFX, 'uint', 'LFX_Reset')
  11.     DllCall($hLightFX, 'uint', 'LFX_Release')
  12.     DllClose($hLightFX)
  13. EndFunc   ;==>_AlienClose
  14. Func _AlienDisco($T = 10)
  15.     Global $Dance = 1
  16.     While $Dance
  17.         $Random = StringReplace(Hex(String(Random(0, 255, 1) & Random(0, 255, 1) & Random(0, 255, 1))), '00', '0xFF')
  18.         _AlienSetColour($Random)
  19.         Sleep(1000)
  20.     WEnd
  21. EndFunc   ;==>_AlienDisco
  22. Func _AlienGetAll()
  23.     For $i = 0 To 3
  24.         $aOrig[$i] = _AlienGetLightColour($i)
  25.         ConsoleWrite($aOrig[$i] & @CRLF)
  26.     Next
  27. EndFunc   ;==>_AlienGetAll
  28. Func _AlienGetLightColour($iLight)
  29. ;~  LFX_GetLightColor(const unsigned int devIndex,const unsigned int lightIndex,PLFX_COLOR const lightCol);
  30.     $Strut = DllStructCreate('UINT')
  31.     DllCall($hLightFX, 'uint', 'LFX_GetLightColor', 'uint', 0, 'uint', $iLight, 'ptr', DllStructGetPtr($Strut))
  32.     DllStructGetData($Strut, 1)
  33.     $iColour = Hex(DllStructGetData($Strut, 1), 8)
  34.     $iColour = '0x' & StringMid($iColour, 1, 2) & StringMid($iColour, 7, 2) & StringMid($iColour, 5, 2) & StringMid($iColour, 3, 2)
  35.     Return $iColour
  36. EndFunc   ;==>_AlienGetLightColour
  37. Func _AlienGetNumLights()
  38. ;~  LFX_GetNumLights(const unsigned int devIndex,unsigned int* const numLights);
  39.     $Strut = DllStructCreate('UINT')
  40.     DllCall($hLightFX, 'uint', 'LFX_GetNumLights', 'uint', 0, 'ptr', DllStructGetPtr($Strut))
  41.     $iNum = DllStructGetData($Strut, 1)
  42.     ConsoleWrite($iNum & @CRLF)
  43.     Return $iNum
  44. EndFunc   ;==>_AlienGetNumLights
  45.  
  46. Func _AlienSetColour($iColour, $iLocation = 0x07FFFFFF)
  47. ;~  LFX_Light(const unsigned int locationMask, const unsigned int colorVal);
  48.     DllCall($hLightFX, 'uint', 'LFX_Light', 'uint', $iLocation, 'uint', $iColour)
  49.     DllCall($hLightFX, 'uint', 'LFX_Update')
  50. EndFunc   ;==>_AlienSetColour
  51. Func _AlienSetLightColour($iColour = 0xFF0000FF, $iLight = 0, $iLocation = 0)
  52.     ;0 - Keyboard.
  53.     ;1 - Left Grill.
  54.     ;2 - Right Grill.
  55.     ;3 - Logo.
  56.     ;4 - Status.
  57.     ;LFX_SetLightColor(const unsigned int devIndex, const unsigned int lightIndex, const PLFX_COLOR lightCol);
  58.     $Strut = DllStructCreate('char red;char green;char blue;char brightness')
  59.     Local $PTR1 = DllStructGetPtr($Strut)
  60.     DllStructSetData($Strut, 1, Number('0x' & StringMid($iColour, 5, 2)))
  61.     DllStructSetData($Strut, 2, Number('0x' & StringMid($iColour, 7, 2)))
  62.     DllStructSetData($Strut, 3, Number('0x' & StringMid($iColour, 9, 2)))
  63.     DllStructSetData($Strut, 4, Number('0x' & StringMid($iColour, 3, 2)))
  64.     $A = DllCall($hLightFX, 'uint', 'LFX_SetLightColor', 'uint', $iLocation, 'uint', $iLight, 'ptr', $PTR1)
  65. EndFunc   ;==>_AlienSetLightColour
  66. Func _AlienUpdate()
  67.     DllCall($hLightFX, 'uint', 'LFX_Update')
  68. EndFunc
  69. Func _AlienStart()
  70.     $hLightFX = DllOpen($hLightFX)
  71.     If $hLightFX = -1 Then Exit MsgBox(48,'FATALITY!', 'Failed to find: "LightFX 64x.dll".')
  72.     DllCall($hLightFX, 'uint', 'LFX_Initialize')
  73.     DllCall($hLightFX, 'uint', 'LFX_Reset')
  74. EndFunc   ;==>_AlienStart
  75.  
  76. Func _AlienCenter($iDefcon, $iDevice)
  77.     ;0 - Keyboard.
  78.     ;1 - Grills
  79.     ;2 - Logo.
  80.     ;3 - Status.
  81.     ;4 - All.
  82.     Opt('GuiOnEventMode', 0)
  83. ;~  DllCall($hLightFX, 'uint', 'LFX_Reset')
  84.     ConsoleWrite('Defcon - ' & $iDefcon & @CRLF)
  85.     ConsoleWrite('Device - ' & $iDevice & @CRLF)
  86.     ConsoleWrite('Colour - ' & $aDefcon[$iDefcon][1] & @CRLF)
  87.  
  88.     Switch $iDevice
  89.         Case 0
  90.             _AlienSetLightColour($aDefcon[$iDefcon][1], 0)
  91.         Case 1
  92.             _AlienSetLightColour($aDefcon[$iDefcon][1], 1)
  93.             _AlienSetLightColour($aDefcon[$iDefcon][1], 2)
  94.         Case 2
  95.             _AlienSetLightColour($aDefcon[$iDefcon][1], 3)
  96.         Case 3
  97.             _AlienSetLightColour($aDefcon[$iDefcon][1], 4)
  98.         Case 4
  99.             _AlienSetColour($aDefcon[$iDefcon][1])
  100.     EndSwitch
  101.     Opt('GuiOnEventMode', 1)
  102. EndFunc   ;==>_AlienCenter
  103.  
  104. Func _GetBattery()
  105.     DllCall("kernel32.dll", "int", "GetSystemPowerStatus", "ptr", $PTR)
  106.     Return DllStructGetData($SYSTEM_POWER_STATUS, 3)
  107. EndFunc   ;==>_GetBattery
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement