Sign in to follow this  
Followers 0
Nlba

Saving

5 posts in this topic

Hi i have a problem with my script.

I want that it saves the list as CSV or something else so i coud print it.

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

Global $i
Local $sSft
Local $strComputer, $strInput

Do
$strComputer = (InputBox("Software","Computername oder IP eingeben"))
If $strComputer <> '' Then
$strInput = 1
EndIf
Until $strInput = 1

Global $sGui = GUICreate(' Installierte Software von ' & $strComputer, 810, 650, -1, -1)
Global $sLvw = GUICtrlCreateListView('#|Installierte Software|Version|Hersteller|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 $CopI = GUICtrlCreateMenuItem('Copy Uninstall String to Clipboard', $mMen)
Local $CopI = GUICtrlCreateMenuItem('Auswahl Deinstallieren', $mMen)
;~ GUICtrlSetOnEvent($CopI, '_Copy2Clip')
GUICtrlSetOnEvent($CopI, '_Uninstall')
Local $exp = GUICtrlCreateButton('  Expand  ', 720, 615)
$Save = GUICtrlCreateButton("Save", 680, 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
    If $proc[5] Then ShellExecuteWait ($proc[5])
        exit
EndFunc
;
Func _Copy2Clip()
    Local $proc = StringSplit(GUICtrlRead(GUICtrlRead($sLvw)), '|', 1)
    If $proc[1] == 0 Then Return -1
    If $proc[5] Then ClipPut($proc[5])
EndFunc
;

Func _ComputerGetSoftware(ByRef $aSoftwareInfo,$computer = $strComputer)
   If $computer <> '' Then $computer = '\\' & StringReplace($computer, '\', '') & '\'

    Local Const $UnInstKey = $computer & "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
    Local $i = 1
    Dim $aSoftwareInfo[1][4]
    $input = inputbox ("Software suche" , "Name der Software", 'Alle Programme')
    If @Error = 1 Then Exit
    If $input = 'Alle Programme' 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)

Else

    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)

    Endif
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

Share this post


Link to post
Share on other sites



Well i am really new to this so i dont have alot of knowledge about. I have no i idea what i have to do to save it.

Share this post


Link to post
Share on other sites

I can see you are new member, I'm trying to help you to help yourself.

If you explain, when asking a question, what your code is meant to do, and exactly what you expect, and what is going wrong. Then people do not have to trawl right through it and figure it out for themselves.

You'll get the same level of answer as you put into your question, you'll find.

It's your code, you must know at least something about it.


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

Commands that might help you.

_FileCreate

_FileWriteLine

_StringReplace

etc

Did you write your code or someone else?

I ask this, as it seems passing strange that you can do that level of sophistication and yet fail to determine a simple file writing procedure.

The Help file is your friend.

Failing that, we help you to help yourself, and as JohnOne said, it helps us immensely if we don't need to do a fishing expedition first. It also helps if we know your real level of skill.


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

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
Sign in to follow this  
Followers 0