Jump to content

Allow copying data from a list in GUI


Recommended Posts

You have to do it your own if you want to use the usal keys (ctrl-a to mark everything or ctrl-c to copy). I use (not a complete script - just stripped down code to give you an idea)

; GUI
Global $hButtonStrgA        = GUICtrlCreateDummy()
Global $hButtonStrgC        = GUICtrlCreateDummy()

; Set accelerators for Strg+a and Strg+c
Global $asAccelKeys[2][2]=[["^a", $hButtonStrgA],["^c", $hButtonStrgC]]
GUISetAccelerators($asAccelKeys)

While 1
    $vMsg = GUIGetMsg(1)
    Select
        Case $vMsg[0] = $hButtonStrgA
            _SelectAll()
        Case $vMsg[0] = $hButtonStrgC
            _Clipboard()
WEnd

Func _SelectAll()
    _GUICtrlListView_SetItemSelected($hGUIGroupList, -1, True)
EndFunc

Func _Clipboard()
    $vZf = _GetSelectedItems()
    If $vZf = "" Then
        MsgBox(16, $sFormTitle, "No Records selected!")
        Return
    EndIf
    ClipPut(StringStripWS($vZf, 2))
EndFunc

Func _GetSelectedItems()
    Local $aTxtSel, $sTmp
    $aTxtSel = _GUICtrlListView_GetSelectededices($hGUIGroupList, True)
    If $aTxtSel[0] Then
        For $i = 1 To $aTxtSel[0]
            $sTmp &= _GUICtrlListView_GetItemText($hGUIGroupList, $aTxtSel[$i], 0) & @Tab & _
                _GUICtrlListView_GetItemText($hGUIGroupList, $aTxtSel[$i], 1) & @TAB & _
                _GUICtrlListView_GetItemText($hGUIGroupList, $aTxtSel[$i], 2) & @TAB & _
                _GUICtrlListView_GetItemText($hGUIGroupList, $aTxtSel[$i], 3) & @CRLF
        Next
    EndIf
    Return $sTmp
EndFunc

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

WATER - Thanks that got me going in the right direction -- I think... haha

I have three different boxes, two of which I need to copy the data out of. The problem is I cant seem to figure out how to get it select all from just one box let alone both of them... I think I set it up correctly.. can someone take a look at this and see what Im doing wrong...

#include <Array.au3>
#include <File.au3>
#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <Misc.au3>
#include <GuiButton.au3>
#include <ListBoxConstants.au3>
#include <WindowsConstants.au3>

_Singleton("FileChecker")

; #########################################################################################
; # Create GUI
; #########################################################################################

GUICreate("File Checker", 650, 400)
GUISetIcon("C:\Windows\explorer.exe", 0)
;GUISetBkColor(0x00FF6600)

; PROGRESS
$progress = 0

$progressbar = GuiCtrlCreateProgress(60, 10, 580, 20)
GuiCtrlSetData($progressbar, $progress)
$label = GuiCtrlCreateLabel("Progress:", 5, 15)
$label1 = GuiCtrlCreateLabel("Nonexistent file extensions:", 10, 40)
$label2 = GUICtrlCreateLabel("Check 1:", 160, 40)
$label3 = GUICtrlCreateLabel("Check 2:", 390, 40)
$ExtList = GUICtrlCreateList("", 160, 60, 210, 300, BitOR($WS_BORDER, $WS_VSCROLL))
$NonExtList = GUICtrlCreateList("",  10, 60, 130, 300, BitOR($WS_BORDER, $WS_VSCROLL))
$Restricted = GUICtrlCreateList("", 390, 60, 210, 300, BitOR($WS_BORDER, $WS_VSCROLL))
$finishedButton = GUICtrlCreateButton("Finished", 300, 370, 60)
GuiSetState(@SW_SHOW)

; #########################################################################################
; # GUI Events
; #########################################################################################

Opt("GUIOnEventMode",1)
GUISetOnEvent ($GUI_EVENT_CLOSE, "Close")
GUICtrlSetOnEvent ($GUI_EVENT_CLOSE, "Finished")


Func Finished()
    Exit
EndFunc

Func Close()
    Exit
EndFunc

; #########################################################################################
; # Create the copy function for the GUI
; #########################################################################################

Global $hButtonStrgA = GUICtrlCreateDummy()
Global $hButtonStrgC = GUICtrlCreateDummy()

; Set accelerators for Strg+a and Strg+c
Global $asAccelKeys[2][2]=[["^a", $hButtonStrgA],["^c", $hButtonStrgC]]
GUISetAccelerators($asAccelKeys)

GUICtrlSetOnEvent($hButtonStrgA, "_SelectAll")
GUICtrlSetOnEvent($hButtonStrgC, "_Clipboard")

Func _SelectAll()
    _GUICtrlListView_SetItemSelected($ExtList, -1, True)
EndFunc

Func _Clipboard()
    $vZf = _GetSelectedItems()
    If $vZf = "" Then
        MsgBox(16, "Warning", "No Records selected!")
        Return
    EndIf
    ClipPut(StringStripWS($vZf, 2))
EndFunc

Func _GetSelectedItems()
    Local $aTxtSel, $sTmp
    $aTxtSel = _GUICtrlListView_GetSelectedindices($ExtList, True)
    If $aTxtSel[0] Then
        For $i = 1 To $aTxtSel[0]
            $sTmp &= _GUICtrlListView_GetItemText($ExtList, $aTxtSel[$i], 0) & @Tab & _
                _GUICtrlListView_GetItemText($ExtList, $aTxtSel[$i], 1) & @TAB & _
                _GUICtrlListView_GetItemText($ExtList, $aTxtSel[$i], 2) & @TAB & _
                _GUICtrlListView_GetItemText($ExtList, $aTxtSel[$i], 3) & @CRLF
        Next
    EndIf
    Return $sTmp
EndFunc

; ########################################################################################
; # Check 1
; ########################################################################################

$checker1 = ""
$checker2 = ""
$checker0 = ""
$listOfFails = ""
$y = 0
$z = 0
$a = 0

;set keys to check
$EditFlags = "EditFlags"
$AlwaysShowExt = "AlwaysShowExt"

;set path
$RegPath = "HKEY_LOCAL_MACHINE\Software\Classes\"

Local $keyExtArray[7]
Local $keyArray[7]
Local $ExtArray[7]

;set rest of path
$keyExtArray[0] = ".pdf"
$keyArray[0] = "AcroExch.Document"
$ExtArray[0] = "PDF"
$keyExtArray[1] = ".ppt"
$keyArray[1] = "PowerPoint.Show.8"
$ExtArray[1] = "PPT"
$keyExtArray[2] = ".fdf"
$keyArray[2] = "AcroExch.FDFDoc"
$ExtArray[2] = "FDF"
$keyExtArray[3] = ".xfdf"
$keyArray[3] = "AcroExch.XFDFDoc"
$ExtArray[3] = "XFDF"
$keyExtArray[4] = ".pps"
$keyArray[4] = "PowerPoint.SlideShow.8"
$ExtArray[4] = "PPS"
$keyExtArray[5] = ".lsl"
$keyArray[5] = "lslfile"
$ExtArray[5] = "LSL"
$keyExtArray[6] = ".pot"
$keyArray[6] = "PowerPoint.Template.8"
$ExtArray[6] = "POT"



For $x = 0 To $keyExtArray
    
    $checker0 = RegRead($RegPath & $keyExtArray[$z], "")

    If $checker0 = "" Then
        $a = $a+1
        $listOfFails = $a & " -- " & $keyExtArray[$z]
        GUICtrlSetData($NonExtList, $listOfFails)
        
    Else
    
        $checker1 = RegRead($RegPath & $keyArray[$z], $EditFlags)
        
        If @error Or $checker1 <> 0 Then
            $y = $y+1
            $listOfFails = $y & " -- " & $ExtArray[$z] & " : " & $EditFlags
            $progress = $progress + 2
            GUICtrlSetData($ExtList, $listOfFails)
            GuiCtrlSetData($progressbar, $progress)
        EndIf
        
        $checker2 = RegRead($RegPath & $keyArray[$z], $AlwaysShowExt)
        
        If @error Or $checker2 <> "" Then
            $y = $y+1
            $listOfFails = $y & " -- " & $ExtArray[$z] & " : " & $AlwaysShowExt
            $progress = $progress + 2
            GUICtrlSetData($ExtList, $listOfFails)
            GuiCtrlSetData($progressbar, $progress)
        EndIf
        
    EndIf
    
    $z = $z+1
Next


; #########################################################################################
; # Another check
; #########################################################################################

$DefaultPath = "\Shell"     ; list what is the default for that extension
$OpenPath = "\Shell\Open\command"; list what app is used to Open
$EditPath = "\Shell\Edit\command"; list what app is used to Edit

Local $RegKey[5]
Local $RegKeyPath[5]

$RegKey[0] = "JSE"
$RegKeyPath[0] = "JSEfile"
$RegKey[1] = "JS"
$RegKeyPath[1] = "JSfile"
$RegKey[2] = "HTA"
$RegKeyPath[2] = "htafile"
$RegKey[3] = "SHS"
$RegKeyPath[3] = "ShellScrap"
$RegKey[4] = "SHB"
$RegKeyPath[4]= "DocShortcut"


$checker3 = ""
$checker4 = ""
$checker5 = ""
$d = 0
$e = 0



For $b = 0 To $RegKey
    
    $checker3 = RegRead($RegPath & $RegKeyPath[$e] & $DefaultPath, "")

    If $checker3 = "" Or $checker3 = "Open" Then

        $checker4 = RegRead($RegPath & $RegKeyPath[$e] & $OpenPath, "")
        
        If @error Or $checker4 <> 'C:\WINDOWS\notepad.exe "%1"' Then
            $d = $d+1
            $listOfFails = $d & " -- " & $RegKey[$e] & " : " & "Open"
            $progress = $progress + 2
            GUICtrlSetData($Restricted, $listOfFails)
            GuiCtrlSetData($progressbar, $progress)
        Else
            
        EndIf
    Else
        
        $checker5 = RegRead($RegPath &$RegKeyPath[$e] & $EditPath, "")
        
        If @error Or $checker5 <> 'C:\WINDOWS\notepad.exe "%1"' Or $checker5 <> '"C:\WINDOWS\notepad.exe" "%1"' Then
            $d = $d+1
            $listOfFails = $d & " -- " & $RegKey[$e] & " : " & "Open"
            $progress = $progress + 2
            GUICtrlSetData($Restricted, $listOfFails)
            GuiCtrlSetData($progressbar, $progress)
        EndIf
    EndIf
    $e = $e+1
Next

; #########################################################################################

;$progress = 100

GuiCtrlSetData($progressbar, $progress)

; ########################################################################################
; # Keep GUI Alive
; ########################################################################################

 While 1
    sleep(50)
 Wend
Edited by HumperHard
Link to comment
Share on other sites

I use GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") to handle the input. Please have a look at FSQG. The variable $sArea contains "Left" or "Right" to show which of the Controls has been selected.

If you have further questions just drop me a note

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...