Jump to content
31290

Combine 32 & 64 Reg values

Recommended Posts

31290

Hi everyone, 

I'm currently writing a script that allow me to list all currently installed software on a computer but some of the are listed in the HKLM64 hive of the registry whereas 95% of all others are in the HKLM "normal" one.

Thing is, I'd like to combine these two reg key into one single ListView item.

Here's my code so far, knowing that it's working on both cases (changing to HKLM64 or HKLM short)

Spoiler
#include <GuiListView.au3>
Opt("TrayAutoPause", 0)
Opt('GUIOnEventMode', 1)
Opt('GUICloseOnEsc' , 1)

Global $i
Local $sSft
Global $sGui = GUICreate('Currently Installed Software', 810, 650, -1, -1)
Global $sLvw = GUICtrlCreateListView('#|Installed Software|Display Version|Publisher|Uninstall String', 5, 5, 800, 600)
_ComputerGetSoftware($sSft)

For $i = 1 To ubound($sSft) - 1
    GUICtrlCreateListViewItem($i & '|' & $sSft[$i][0] & '|' & $sSft[$i][1] & '|' & $sSft[$i][2] & '|' & $sSft[$i][3], $sLvw)
Next

GUICtrlSendMsg($sLvw, 0x101E, 1, 175)
GUICtrlSendMsg($sLvw, 0x101E, 2, 65)
GUICtrlSendMsg($sLvw, 0x101E, 3, 150)
GUICtrlSendMsg($sLvw, 0x101E, 4, 350)
Local $mMen = GUICtrlCreateContextMenu($sLvw)
Local $Uninstall = GUICtrlCreateMenuItem('Proceed to Software uninstallation', $mMen)
GUICtrlSetOnEvent($Uninstall, '_Uninstall')
Local $exp = GUICtrlCreateButton('  Expand  ', 720, 615)
GUICtrlSetOnEvent($exp, '_Expand')
GUISetOnEvent(-3, '_AllExit')
GUISetState(@SW_SHOW, $sGui)

While 1
    Sleep(10)
WEnd
;
Func _AllExit()
    GUIDelete($sGui)
    Exit
EndFunc

Func _Uninstall()
   Local $proc = StringSplit(GUICtrlRead(GUICtrlRead($sLvw)), '|', 1)
   If $proc[1] == 0 Then Return -1
   ShellExecuteWait ($proc[5])
EndFunc

Func _ComputerGetSoftware(ByRef $aSoftwareInfo)
    Local Const $UnInstKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
    Local $i = 1
    Dim $aSoftwareInfo[1][4]
        For $j = 1 To 500
            $AppKey = RegEnumKey($UnInstKey, $j)
            If @error <> 0 Then Exitloop
            If RegRead($UnInstKey & "\" & $AppKey, "DisplayName") = '' Then ContinueLoop
            ReDim $aSoftwareInfo[UBound($aSoftwareInfo) + 1][4]
            $aSoftwareInfo[$i][0] = StringStripWS(StringReplace(RegRead($UnInstKey & "\" & $AppKey, "DisplayName"), " (remove only)", ""), 3)
            $aSoftwareInfo[$i][1] = StringStripWS(RegRead($UnInstKey & "\" & $AppKey, "DisplayVersion"), 3)
            $aSoftwareInfo[$i][2] = StringStripWS(RegRead($UnInstKey & "\" & $AppKey, "Publisher"), 3)
            $aSoftwareInfo[$i][3] = StringStripWS(RegRead($UnInstKey & "\" & $AppKey, "UninstallString"), 3)
            $i = $i + 1
        Next
        $aSoftwareInfo[0][0] = UBound($aSoftwareInfo, 1) - 1
        If $aSoftwareInfo[0][0] < 1 Then SetError(1, 1, 0)
        Return _ArraySort($aSoftwareInfo,0,1)
        For $j = 1 To 500
            $AppKey = RegEnumKey($UnInstKey, $j)
            If @error <> 0 Then Exitloop
            $Reg = RegRead($UnInstKey & "\" & $AppKey, "DisplayName")
            $string = stringinstr($Reg, $input)
            If $string = 0 Then Continueloop
            ReDim $aSoftwareInfo[UBound($aSoftwareInfo) + 1][4]
            $aSoftwareInfo[$i][0] = StringStripWS(StringReplace(RegRead($UnInstKey & "\" & $AppKey, "DisplayName"), " (remove only)", ""), 3)
            $aSoftwareInfo[$i][1] = StringStripWS(RegRead($UnInstKey & "\" & $AppKey, "DisplayVersion"), 3)
            $aSoftwareInfo[$i][2] = StringStripWS(RegRead($UnInstKey & "\" & $AppKey, "Publisher"), 3)
            $aSoftwareInfo[$i][3] = StringStripWS(RegRead($UnInstKey & "\" & $AppKey, "UninstallString"), 3)
            $i = $i + 1
        Next
        $aSoftwareInfo[0][0] = UBound($aSoftwareInfo, 1) - 1
        If $aSoftwareInfo[0][0] < 1 Then SetError(1, 1, 0)
        Return _ArraySort($aSoftwareInfo,0,1)
EndFunc
;
Func _Expand()
    _GUICtrlListView_SetColumnWidth($sLvw, 1, $LVSCW_AUTOSIZE)
    _GUICtrlListView_SetColumnWidth($sLvw, 2, $LVSCW_AUTOSIZE)
    _GUICtrlListView_SetColumnWidth($sLvw, 3, $LVSCW_AUTOSIZE)
    _GUICtrlListView_SetColumnWidth($sLvw, 4, $LVSCW_AUTOSIZE)
EndFunc

 

Thanks in advance for the help :)

-31290-


~~~ Doom Shall Never Die, Only The Players ~~~

Share this post


Link to post
Share on other sites
Earthshine
Posted (edited)

change your function that reads the reg. pass it the key once for 32 bit, once for 64 in main loop

Func _ComputerGetSoftware(ByRef $aSoftwareInfo, $UnInstKey)

then don;t do this, remark that out.

 Local Const $UnInstKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"

pass that key to your function 2 times, 32 and 64 values and add them to the one array.

Edited by Earthshine
  • Like 1

My resources are limited. You must ask the right questions

 

Share this post


Link to post
Share on other sites
Earthshine

by the way, your code doesn't compile so i'm not going to test it.


My resources are limited. You must ask the right questions

 

Share this post


Link to post
Share on other sites
31290
12 minutes ago, Earthshine said:

by the way, your code doesn't compile so i'm not going to test it.

What do you mean by that? I've just compiled it and ran just fine.

Thanks for your info above, I'll test that.

-31290-


~~~ Doom Shall Never Die, Only The Players ~~~

Share this post


Link to post
Share on other sites
Subz

Maybe something like:

#include <GuiListView.au3>
Opt("TrayAutoPause", 0)
Opt('GUIOnEventMode', 1)
Opt('GUICloseOnEsc' , 1)

Global $aSoftwareInfo[0][5]
    _SoftwareInfo("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall")
    _SoftwareInfo("HKLM64\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall")

Global $hGui = GUICreate('Currently Installed Software', 810, 650, -1, -1)
Global $idListView = GUICtrlCreateListView('#|Installed Software|Display Version|Publisher|Uninstall String', 5, 5, 800, 600)
_GUICtrlListView_AddArray($idListView, $aSoftwareInfo)

GUICtrlSendMsg($idListView, 0x101E, 1, 175)
GUICtrlSendMsg($idListView, 0x101E, 2, 65)
GUICtrlSendMsg($idListView, 0x101E, 3, 150)
GUICtrlSendMsg($idListView, 0x101E, 4, 350)
Local $mMen = GUICtrlCreateContextMenu($idListView)
Local $Uninstall = GUICtrlCreateMenuItem('Proceed to Software uninstallation', $mMen)
GUICtrlSetOnEvent($Uninstall, '_Uninstall')
Local $exp = GUICtrlCreateButton('  Expand  ', 720, 615)
GUICtrlSetOnEvent($exp, '_Expand')
GUISetOnEvent(-3, '_AllExit')
GUISetState(@SW_SHOW, $hGui)

While 1
    Sleep(10)
WEnd
;
Func _AllExit()
    GUIDelete($hGui)
    Exit
EndFunc

Func _Uninstall()
   Local $proc = StringSplit(GUICtrlRead(GUICtrlRead($idListView)), '|', 1)
   If $proc[1] == 0 Then Return -1
   ShellExecuteWait ($proc[5])
EndFunc

Func _SoftwareInfo($_sHKLMUninstall)
    Local $i = 1
    While 1
        $sRegKey = RegEnumKey($_sHKLMUninstall, $i)
        If @error Then Exitloop
        If RegRead($_sHKLMUninstall & "\" & $sRegKey, "DisplayName") = '' Then
            $i += 1
            ContinueLoop
        EndIf
        $sDisplayName = StringStripWS(StringReplace(RegRead($_sHKLMUninstall & "\" & $sRegKey, "DisplayName"), " (remove only)", ""), 3)
        $sDisplayVersion = StringStripWS(RegRead($_sHKLMUninstall & "\" & $sRegKey, "DisplayVersion"), 3)
        $sPublisher = StringStripWS(RegRead($_sHKLMUninstall & "\" & $sRegKey, "Publisher"), 3)
        $sUninstallString = StringStripWS(RegRead($_sHKLMUninstall & "\" & $sRegKey, "UninstallString"), 3)
        _ArrayAdd($aSoftwareInfo, "|" & $sDisplayName & "|" & $sDisplayVersion & "|" & $sPublisher & "|" & $sUninstallString)
        $i += 1
    WEnd
    _ArraySort($aSoftwareInfo,0,1)
    For $i = 0 To UBound($aSoftwareInfo) - 1
        $aSoftwareInfo[$i][0] = $i
    Next
EndFunc
;
Func _Expand()
    _GUICtrlListView_SetColumnWidth($idListView, 1, $LVSCW_AUTOSIZE)
    _GUICtrlListView_SetColumnWidth($idListView, 2, $LVSCW_AUTOSIZE)
    _GUICtrlListView_SetColumnWidth($idListView, 3, $LVSCW_AUTOSIZE)
    _GUICtrlListView_SetColumnWidth($idListView, 4, $LVSCW_AUTOSIZE)
EndFunc

 

  • Like 1
  • Thanks 2

Share this post


Link to post
Share on other sites
VIP
Posted (edited)

"HKEY_LOCAL_MACHINE64\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"

 

AutoItScript List installed programs and system information:

#include <GuiListView.au3>
Opt("TrayAutoPause", 0)
Opt('GUIOnEventMode', 1)
Opt('GUICloseOnEsc', 1)
;Opt("MustDeclareVars", 1)
;
Global $SoftwList = 'ALL', $iAskSoftName = 0, $sSft[1][0]
Global $sGui = GUICreate('Currently Installed Software', 810, 650, -1, -1)
Global $sLvw = GUICtrlCreateListView('#|Installed Software|Display Version|Publisher|Uninstall String', 5, 5, 800, 600)
_ComputerGetSoftware($sSft)
For $i = 1 To UBound($sSft) - 1
    GUICtrlCreateListViewItem($i & '|' & $sSft[$i][0] & '|' & $sSft[$i][1] & '|' & $sSft[$i][2] & '|' & $sSft[$i][3], $sLvw)
Next
GUICtrlSendMsg($sLvw, 0x101E, 1, 175)
GUICtrlSendMsg($sLvw, 0x101E, 2, 65)
GUICtrlSendMsg($sLvw, 0x101E, 3, 150)
GUICtrlSendMsg($sLvw, 0x101E, 4, 350)
Global $mMen = GUICtrlCreateContextMenu($sLvw)
Global $CopI = GUICtrlCreateMenuItem('Uninstall Current Selection', $mMen)
GUICtrlSetOnEvent($CopI, '_Uninstall')
Global $exp = GUICtrlCreateButton('  Expand  ', 720, 615)
GUICtrlSetOnEvent($exp, '_Expand')
GUISetOnEvent(-3, '_AllExit')
GUISetState(@SW_SHOW, $sGui)
;
While 1
    Sleep(10)
WEnd
;
Func _AllExit()
    GUIDelete($sGui)
    Exit
EndFunc   ;==>_AllExit
;
Func _Uninstall()
    Local $proc = StringSplit(GUICtrlRead(GUICtrlRead($sLvw)), '|', 1)
    If $proc[1] == 0 Then Return -1
    If $proc[5] Then RunWait($proc[5])
    Exit
EndFunc   ;==>_Uninstall
;
Func _Copy2Clip()
    Local $proc = StringSplit(GUICtrlRead(GUICtrlRead($sLvw)), '|', 1)
    If $proc[1] == 0 Then Return -1
    If $proc[5] Then ClipPut($proc[5])
EndFunc   ;==>_Copy2Clip
;
; Author JSThePatriot - Modified June 20, 2010 by ripdad - Modified 2018/29/05 by Dao Van Trong - Trong.LIVE
Func _ComputerGetSoftware(ByRef $aSoftwareInfo)
    Local Const $UnInstKey = "HKEY_LOCAL_MACHINE64\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
    Local $i = 1, $Reg, $string, $AppKey
    ReDim $aSoftwareInfo[1][4]
    If ($iAskSoftName) Then $SoftwList = InputBox("Which Software", "You are running " & @OSVersion & " " & @OSArch & @CRLF & @CRLF & "Which Software would you like to view?", 'ALL')
    If @error = 1 Then Exit
    If $SoftwList = 'ALL' Then
        For $j = 1 To 500
            $AppKey = RegEnumKey($UnInstKey, $j)
            If @error <> 0 Then ExitLoop
            If RegRead($UnInstKey & "\" & $AppKey, "DisplayName") = '' Then ContinueLoop
            ReDim $aSoftwareInfo[UBound($aSoftwareInfo) + 1][4]
            $aSoftwareInfo[$i][0] = StringStripWS(StringReplace(RegRead($UnInstKey & "\" & $AppKey, "DisplayName"), " (remove only)", ""), 3)
            $aSoftwareInfo[$i][1] = StringStripWS(RegRead($UnInstKey & "\" & $AppKey, "DisplayVersion"), 3)
            $aSoftwareInfo[$i][2] = StringStripWS(RegRead($UnInstKey & "\" & $AppKey, "Publisher"), 3)
            $aSoftwareInfo[$i][3] = StringStripWS(RegRead($UnInstKey & "\" & $AppKey, "UninstallString"), 3)
            $i = $i + 1
        Next
        $aSoftwareInfo[0][0] = UBound($aSoftwareInfo, 1) - 1
        If $aSoftwareInfo[0][0] < 1 Then SetError(1, 1, 0)
        Return _ArraySort($aSoftwareInfo, 0, 1)
    Else
        For $j = 1 To 500
            $AppKey = RegEnumKey($UnInstKey, $j)
            If @error <> 0 Then ExitLoop
            Local $Reg = RegRead($UnInstKey & "\" & $AppKey, "DisplayName")
            $string = StringInStr($Reg, $SoftwList)
            If $string = 0 Then ContinueLoop
            ReDim $aSoftwareInfo[UBound($aSoftwareInfo) + 1][4]
            $aSoftwareInfo[$i][0] = StringStripWS(StringReplace(RegRead($UnInstKey & "\" & $AppKey, "DisplayName"), " (remove only)", ""), 3)
            $aSoftwareInfo[$i][1] = StringStripWS(RegRead($UnInstKey & "\" & $AppKey, "DisplayVersion"), 3)
            $aSoftwareInfo[$i][2] = StringStripWS(RegRead($UnInstKey & "\" & $AppKey, "Publisher"), 3)
            $aSoftwareInfo[$i][3] = StringStripWS(RegRead($UnInstKey & "\" & $AppKey, "UninstallString"), 3)
            $i = $i + 1
        Next
        $aSoftwareInfo[0][0] = UBound($aSoftwareInfo, 1) - 1
        If $aSoftwareInfo[0][0] < 1 Then SetError(1, 1, 0)
        Return _ArraySort($aSoftwareInfo, 0, 1)
    EndIf
EndFunc   ;==>_ComputerGetSoftware
;
Func _Expand()
    _GUICtrlListView_SetColumnWidth($sLvw, 1, $LVSCW_AUTOSIZE)
    _GUICtrlListView_SetColumnWidth($sLvw, 2, $LVSCW_AUTOSIZE)
    _GUICtrlListView_SetColumnWidth($sLvw, 3, $LVSCW_AUTOSIZE)
    _GUICtrlListView_SetColumnWidth($sLvw, 4, $LVSCW_AUTOSIZE)
EndFunc   ;==>_Expand

 

Edited by VIP
;
  • Haha 1

Regards,
 

Share this post


Link to post
Share on other sites
Earthshine

look at subz example

  • Thanks 1

My resources are limited. You must ask the right questions

 

Share this post


Link to post
Share on other sites
31290
Posted (edited)

@VIP > Thanks for your input but I was talking about combining HKLM64 & HKLM ;) 

@Subz > Your example is just what I've expected! thanks a lot. Now I can figure out how to achieve that!

@Earthshine > Thanks again for your help!

Edited by 31290

~~~ Doom Shall Never Die, Only The Players ~~~

Share this post


Link to post
Share on other sites
VIP

You can not combine it! You need to read or write it 2 times!
For examples (List installed programs) just add "64" is enough!


Regards,
 

Share this post


Link to post
Share on other sites
31290
1 minute ago, VIP said:

You can not combine it! You need to read or write it 2 times!
For examples (List installed programs) just add "64" is enough!

Here I meant combining the 2 reg. keys in the same array :P 
But no worries, question has been answered by subz and I can go on with the tool I'm writing :) 


~~~ Doom Shall Never Die, Only The Players ~~~

Share this post


Link to post
Share on other sites
31290

@Subz and others

Sorry to bother again but I need you help again.

I'm now facing another thing which is that I cannot retrieve the uninstall key string.

I just don't understand why my _Uninstall() function is not working:
 

Func _Uninstall()
   Local $proc = StringSplit(GUICtrlRead(GUICtrlRead($idListView)), '|', 1)
   If $proc[1] == 0 Then Return -1
   Msgbox (0, "", $proc[5])
EndFunc

Nothing simply happens.
When displaying the $proc array, I just have two values, 0 & 1 :/

Then main goal here is to retrieve the uninstall sting displayed in the ListView.

Full code so far:

 

Spoiler
#include <GuiListView.au3>
Opt("TrayAutoPause", 0)
Opt('GUIOnEventMode', 1)
Opt('GUICloseOnEsc' , 1)

Global $aSoftwareInfo[0][5]
    _SoftwareInfo("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall")
    _SoftwareInfo("HKLM64\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall")

Global $hGui = GUICreate('Currently Installed Software', 810, 650, -1, -1)
Global $idListView = GUICtrlCreateListView('#|Installed Software|Display Version|Publisher|Uninstall String', 5, 5, 800, 600)
_GUICtrlListView_AddArray($idListView, $aSoftwareInfo)

GUICtrlSendMsg($idListView, 0x101E, 1, 175)
GUICtrlSendMsg($idListView, 0x101E, 2, 65)
GUICtrlSendMsg($idListView, 0x101E, 3, 150)
GUICtrlSendMsg($idListView, 0x101E, 4, 350)
Local $mMen = GUICtrlCreateContextMenu($idListView)
Local $Uninstall = GUICtrlCreateMenuItem('Proceed to Software uninstallation', $mMen)
GUICtrlSetOnEvent($Uninstall, '_Uninstall')
Local $exp = GUICtrlCreateButton('  Expand  ', 720, 615)
GUICtrlSetOnEvent($exp, '_Expand')
GUISetOnEvent(-3, '_AllExit')
GUISetState(@SW_SHOW, $hGui)

While 1
    Sleep(10)
WEnd
;
Func _AllExit()
    GUIDelete($hGui)
    Exit
EndFunc

Func _Uninstall()
   Local $proc = StringSplit((GUICtrlRead($aSoftwareInfo)), '|', 1)
   _arraydisplay ($proc)
   ; Msgbox (0, "", $proc[5])
EndFunc

Func _SoftwareInfo($_sHKLMUninstall)
    Local $i = 1
    While 1
        $sRegKey = RegEnumKey($_sHKLMUninstall, $i)
        If @error Then Exitloop
        If RegRead($_sHKLMUninstall & "\" & $sRegKey, "DisplayName") = '' Then
            $i += 1
            ContinueLoop
        EndIf
        $sDisplayName = StringStripWS(StringReplace(RegRead($_sHKLMUninstall & "\" & $sRegKey, "DisplayName"), " (remove only)", ""), 3)
        $sDisplayVersion = StringStripWS(RegRead($_sHKLMUninstall & "\" & $sRegKey, "DisplayVersion"), 3)
        $sPublisher = StringStripWS(RegRead($_sHKLMUninstall & "\" & $sRegKey, "Publisher"), 3)
        $sUninstallString = StringStripWS(RegRead($_sHKLMUninstall & "\" & $sRegKey, "UninstallString"), 3)
        _ArrayAdd($aSoftwareInfo, "|" & $sDisplayName & "|" & $sDisplayVersion & "|" & $sPublisher & "|" & $sUninstallString)
        $i += 1
    WEnd
    _ArraySort($aSoftwareInfo,0,1)
    For $i = 0 To UBound($aSoftwareInfo) - 1
        $aSoftwareInfo[$i][0] = $i
    Next
EndFunc
;
Func _Expand()
    _GUICtrlListView_SetColumnWidth($idListView, 1, $LVSCW_AUTOSIZE)
    _GUICtrlListView_SetColumnWidth($idListView, 2, $LVSCW_AUTOSIZE)
    _GUICtrlListView_SetColumnWidth($idListView, 3, $LVSCW_AUTOSIZE)
    _GUICtrlListView_SetColumnWidth($idListView, 4, $LVSCW_AUTOSIZE)
EndFunc

 

Thanks in advance :)

-31290-


~~~ Doom Shall Never Die, Only The Players ~~~

Share this post


Link to post
Share on other sites
31290

Well, thanks again Subz.

I was beginning playing around with _GUICtrlListView_XXX functions.

But yours is faster and efficient.

You have a good day Sir :) 


~~~ Doom Shall Never Die, Only The Players ~~~

Share this post


Link to post
Share on other sites

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

  • Similar Content

    • HardXOR
      By HardXOR
      Hello AutoIt community
      I run into speed problem in my script wich i cant solve myself, problem is with decoding texture loop - for better explanation, you need extract from file pallete (16x 16 RGB color) and picture data (224 * 128 byte), then use correct color for your picture data.... nothing extra hard and also texture is quite small 224*256
      it is for my car model viewer/later maybe editor GranTurismo 2 from Playstation 1, so its old dataformat and i cant understand why AutoIt take so long to decode texture when good old Playstation almost 2,5 decades old can do that nearly immediately (when you list through cars in shop or garage)
      My first atempt was create all trought dllstructure, because its easier approach, but it was soooo slow (40-50s for create textures) then i upgrade my routine via arrays, first 3D arrays later only 1D, next i put decoding colors outside loop but it is still not enough, my last version took cca 15s wich is still unacceptable for car model viewer when you click on one carmodel from listview (1100 cars for whole game) and you must wait 15-16s for model to load....  oh and i forgot mention some cars have more then 1 color (much more... 8-9-10 etc) soloading take 8-9-10 times more time
      in attachment i post texture file from GranTurismo 2 for one car (contain only 1 color) and also my dll struct version and array version code
      dll struct version - ± 40 sec (33 without saving)
      #include <FileConstants.au3> Global $IMDT[256][256][4] LoadTexture("ufs9r.cdp") Func LoadTexture($file) $fileHandle = FileOpen($file, $FO_BINARY) $header = FileRead($fileHandle, 0x20) ConsoleWrite("header> " & $header & @CRLF) $PAL = FileRead($fileHandle, 0x200) ConsoleWrite("PAL> " & $PAL & @CRLF) FileSetPos($fileHandle, 0x43A0, $FILE_BEGIN) $IMD = FileRead($fileHandle, 0x7000) ConsoleWrite("IMD> " & $IMD & @CRLF) $st = DllStructCreate("BYTE[512]") DllStructSetData($st, 1, $PAL) $struct_PAL = DllStructCreate("WORD[16];WORD[16];WORD[16];WORD[16];WORD[16];WORD[16];WORD[16];WORD[16];WORD[16];WORD[16];WORD[16];WORD[16];WORD[16];WORD[16];WORD[16];WORD[16]", DllStructGetPtr($st)) $struct_IMD = DllStructCreate("BYTE[" & 0x7000 & "]") DllStructSetData($struct_IMD, 1, $IMD) $start = TimerInit() For $i = 0 To 15 For $j = 0 To 223 $cn = 0 For $k = 0 To 127 $bt = DllStructGetData($struct_IMD, 1, $j * 128 + $k + 1) $blue = BitShift(DllStructGetData($struct_PAL, $i + 1, BitAND($bt, 0x0F) + 1), 7) $IMDT[$j][$cn][0] = $blue $green = BitShift(DllStructGetData($struct_PAL, $i + 1, BitAND($bt, 0x0F) + 1), 2) $IMDT[$j][$cn][1] = $green $red = BitShift(DllStructGetData($struct_PAL, $i + 1, BitAND($bt, 0x0F) + 1), - 3) $IMDT[$j][$cn][2] = $red If DllStructGetData($struct_PAL, $i + 1, BitAND($bt, 0x0F) + 1) = 0 Then $IMDT[$j][$cn][3] = 0x00 Else $IMDT[$j][$cn][3] = 0xFF EndIf $cn += 1 $blue = BitShift(DllStructGetData($struct_PAL, $i + 1, BitShift($bt, 4) + 1), 7) $IMDT[$j][$cn][0] = $blue $green = BitShift(DllStructGetData($struct_PAL, $i + 1, BitShift($bt, 4) + 1), 2) $IMDT[$j][$cn][1] = $green $red = BitAND(BitShift(DllStructGetData($struct_PAL, $i + 1, BitShift($bt, 4) + 1), - 3), 0xFF) $IMDT[$j][$cn][2] = $red If DllStructGetData($struct_PAL, $i + 1, BitShift($bt, 4) + 1) = 0 Then $IMDT[$j][$cn][3] = 0x00 Else $IMDT[$j][$cn][3] = 0xFF EndIf $cn += 1 Next Next saveTGA($i) Next ConsoleWrite("t " & TimerDiff($start) & @CRLF) ; +- 40 seconds FileClose($fileHandle) EndFunc Func saveTGA($name) Local $tga[18] = [0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x20, 0x20] Local $data for $i = 0 To 17 $data &= Hex($tga[$i], 2) Next For $i = 0 To 255 For $j = 0 To 255 For $k = 0 To 3 $data &= hex($IMDT[$i][$j][$k], 2) Next Next Next $binary = FileOpen("test\" & $name & ".tga", BitOR($FO_BINARY, $FO_OVERWRITE, $FO_CREATEPATH)) FileWrite($binary, "0x" & $data) FileClose($binary) EndFunc  
      array version - ± 15 sec (under 10s without saving)
      #include <FileConstants.au3> LoadTexture2("ufs9r.cdp") Func LoadTexture2($file) $fileHandle = FileOpen($file, $FO_BINARY) $a = TimerInit() Global $header[0x20] For $i = 0 To UBound($header) - 1 $header[$i] = Int(String(FileRead($fileHandle, 1))) ; read 0x20 bytes Next ConsoleWrite("header " & TimerDiff($a) & @CRLF) $a = TimerInit() Global $PAL[0x100] For $i = 0 To UBound($PAL) - 1 $PAL[$i] = Number(FileRead($fileHandle, 2)) ; read 0x200 (16*16) words Next Global $PALcolor[16 * 16 * 4] For $i = 0 To UBound($PAL) - 1 $PALcolor[$i * 4 + 0] = BitShift($PAL[$i], 7) $PALcolor[$i * 4 + 1] = BitShift($PAL[$i], 2) $PALcolor[$i * 4 + 2] = BitShift($PAL[$i], -3) If $PAL[$i] = 0 Then $PALcolor[$i * 4 + 3] = 0x00 Else $PALcolor[$i * 4 + 3] = 0xFF EndIf Next ConsoleWrite("PAL " & TimerDiff($a) & @CRLF) $a = TimerInit() FileSetPos($fileHandle, 0x43A0, $FILE_BEGIN) Global $IMD[0x7000] For $i = 0 To UBound($IMD) - 1 $IMD[$i] = Int(String(FileRead($fileHandle, 1))) ; read 0x7000 bytes Next ConsoleWrite("IMD " & TimerDiff($a) & @CRLF) Global $IMDT[256*256*4] $a = TimerInit() For $i = 0 To 15 For $j = 0 To 223 $cn = 0 For $k = 0 To 127 $byte = $IMD[$j * 128 + $k] ; byte for decode $index = $j * 1024 + $cn * 4 $index2 = $i * 0x40 + BitAND($byte, 0x0F) * 4 $IMDT[$index + 0] = $PALcolor[$index2 + 0] ; blue $IMDT[$index + 1] = $PALcolor[$index2 + 1] ; green $IMDT[$index + 2] = $PALcolor[$index2 + 2] ; red $IMDT[$index + 3] = $PALcolor[$index2 + 3] ; alpha $cn += 1 $index = $j * 1024 + $cn * 4 $index2 = $i * 0x40 + BitShift($byte, 4) * 4 $IMDT[$index + 0] = $PALcolor[$index2 + 0] ; blue $IMDT[$index + 1] = $PALcolor[$index2 + 1] ; green $IMDT[$index + 2] = $PALcolor[$index2 + 2] ; red $IMDT[$index + 3] = $PALcolor[$index2 + 3] ; alpha $cn += 1 Next Next ;~ $b = TimerInit() saveTGA2($i) ;~ ConsoleWrite("save TGA " & TimerDiff($b) & @CRLF) Next ConsoleWrite("full time " & TimerDiff($a) & @CRLF) ; 16 seconds FileClose($fileHandle) EndFunc Func saveTGA2($name) Local $tga[18] = [0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x20, 0x20] Local $data For $i = 0 To 17 $data &= Hex($tga[$i], 2) Next For $i = 0 To UBound($IMDT) - 1 $data &= Hex($IMDT[$i], 2) Next $binary = FileOpen("test\" & $name & ".tga", BitOR($FO_BINARY, $FO_OVERWRITE, $FO_CREATEPATH)) FileWrite($binary, "0x" & $data) FileClose($binary) EndFunc if anyone can optimize my code I would be very grateful, or pointing me to better solution, thx
      ufs9r.cdp
    • FMS
      By FMS
      Hello,
      Does somebody knows a quick way to split eash word to an array in a text?
      I've a text and want to have each word in that text in an array.

      I tried to get in some way multiple seperators inside stringsplit but couldn't get it to work.
      I hope to get an array like :
      $aArray[0] = "PARIJS"
      $aArray[1] = "AFN"
      $aArray[2] = "Air"
      ....
      sample text: PARIJS (AFN) - Air France-KLM heeft de financieel directeur van het Franse nuts- en vervoersbedrijf Veolia, Philipe Capron, in het vizier om de nieuwe topman van de luchtvaartcombinatie te worden. Volgens de krant La Tribune wordt Capron als favoriet beschouwd om de topfunctie te gaan vervullen. AdChoices Advertentie Volgens bronnen tegen La Tribune is de keuze voor Capron zelfs al gemaakt door Air France-KLM en zal zijn voordracht volgende week worden voorgelegd aan de raad van toezicht bij het bedrijf. Capron zou dan de opvolger worden van de opgestapte topman Jean-Marc Janaillac. In mei trad Janaillac af nadat het hem niet was gelukt buiten de bonden om zaken te doen met het eigen personeel. Sindsdien heeft een interim-bestuur de dagelijkse leiding. De zestigjarige Capron is sinds 2014 financieel directeur bij Veolia. Daarvoor werkte hij onder meer bij mediaconcern Vivendi. Minder macht Overigens zijn er ook geruchten dat de nieuwe topman van Air France-KLM direct een zetel zou krijgen in de raad van commissarissen van KLM. Binnen de Nederlandse divisie, die juist alles op alles zet om minder macht naar Parijs te laten vloeien, is men volgens ingewijden verbolgen over die gang van zaken. ,,Stank voor dank", zo klinkt het in de wandelgangen. Eerder zou Janaillac ook al hebben geprobeerd om een dikkere vinger in de pap te krijgen bij KLM, dat door de bank genomen beter presteert dan haar Franse zustermaatschappij. Dit lukte eerder niet, onder meer door inmenging van het Nederlandse kabinet. AdChoices Advertentie Geruchten Een woordvoerder van Air France-KLM wilde niet reageren op de geruchtenstroom. Het concern gaat er vanuit dat binnen afzienbare tijd een nieuwe bestuursvoorzitter benoemd zal worden. Minister Cora van Nieuwenhuizen (Infrastructuur) wilde evenmin ingaan op geruchten. ,,Ik heb hierover nog geen contact gehad met KLM, dus dat wil ik eerst even afwachten'', zei ze. Tweede Kamerleden spraken deze week tijdens een debat nog maar eens hun zorg uit over de ontwikkelingen bij Air France-KLM. Zij drongen aan op herbevestiging van oude afspraken over de relatief zelfstandige positie van KLM binnen de groep.>Exit code: 0 Time: 28.52  
    • VollachR
      By VollachR
      Hi,
      I'm looking for a way to take a number value from a Row2 of a 2D array and according to this check if files that appear in rows 3-11 in the array exists.
      For example, if the number in Row2 is 5 I need to check for the files in Row 3-6 only, if it is 6 than rows 3-7 and so on.
      I thought on using a FOR loop but I have very little experience with those.
      Can you suggest the best way to do what I need?
      BTW, the files in Rows 3-11 will usually have blank value for any row above the number in Row2 (e.g. Row2 = 5 so Rows3-6 will have values but 8-11 be empty), The values I need are in Column 1 of the array, the name of the key from the INI file that the array was created from is in Column 0.
      Full Example:
      Row2 of Array:
      Col0 = Games# - Col1 = 5
      Rows3-6
      Col0 = Exe2 - Col1 = Path To File
      Col0 = Exe3 - Col1 = Path To File
      Col0 = Exe4 - Col1 = Path To File
      Col0 = Exe5 - Col1 = Path To File
      I need that if Row2 is 5 to check these above for rows if the file exists, if it was 6 then the next row as well and so on up until number 10 in Row2 as it can't go above 10.
      So basically for whatever number in Row2 from 2-10 need to check 1-9 rows from 3-11 to see if the files in Col1 exists and if any of them don't exist it should call a function that shows an error message.
      I'm pretty sure I have the first line of the for look correct:
      For $i = 1 To $aAIO[2][1] Just not sure how to continue from there, also not sure if $i should be equal 1 or 2.
      Help will be appreciated.
    • FMS
      By FMS
      Hello,
      I'm trying to get data from twitter to an array and so far I found an Twitter UDF whish lookes very intresting but couldn't get it to work.
      It lookes not supported any more(2010) and buggy when i read all te replies.
      More around this subject (autoit and twitter) i couldn't find on this forum.
      Is there sombody who know's a good way to get live data from twitter to an array inside autoit?
      (I kinda doubt that this isn't tackled before)
      In the end I was hoping to get all tweets from date to date from an specific subject inside a 2D array to work whit.
    • AndreasNWWWWW
      By AndreasNWWWWW
      I got a question:  i am trying to run different functions based upon what i select in these radio buttons.(code below)
      it needs to check server 1. then run function 1 or function 2 after what i selected in the checkbox.
      once that function is done it moves to the next one, until it has been trough all 5 
       
      iv'e tried using while loops with different while $i equals to something but then i manualy need to go in and edit the script every time.
      #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 615, 437, 192, 124) $Server2 = GUICtrlCreateLabel("Server2", 216, 95, 41, 17) $server1 = GUICtrlCreateLabel("Server1", 216, 72, 41, 17) $server4 = GUICtrlCreateLabel("Server4", 216, 144, 41, 17) $server3 = GUICtrlCreateLabel("Server3", 216, 119, 41, 17) $server5 = GUICtrlCreateLabel("Server5", 216, 170, 41, 17) $Start = GUICtrlCreateButton("Start", 240, 248, 147, 25) $Checkbox1 = GUICtrlCreateCheckbox("function1", 288, 72, 97, 17) $Checkbox2 = GUICtrlCreateCheckbox("function2", 392, 72, 97, 17) $Checkbox3 = GUICtrlCreateCheckbox("function1", 288, 96, 97, 17) $Checkbox4 = GUICtrlCreateCheckbox("function2", 392, 96, 97, 17) $Checkbox5 = GUICtrlCreateCheckbox("function1", 288, 120, 97, 17) $Checkbox6 = GUICtrlCreateCheckbox("function2", 392, 120, 97, 17) $Checkbox7 = GUICtrlCreateCheckbox("function1", 288, 144, 97, 17) $Checkbox8 = GUICtrlCreateCheckbox("function2", 392, 144, 97, 17) $Checkbox9 = GUICtrlCreateCheckbox("function1", 288, 170, 97, 17) $Checkbox10 = GUICtrlCreateCheckbox("function2", 392, 170, 97, 17) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd  
×