Page 1 sur 1

[R] Action sur listview - récupération d'item  

Posté : lun. 18 févr. 2019 22:39
par franco
Bonjour.

Je cherche à récupérer - consolewrite / msgbox / variable - un item et son sous-item lors d'un clic sur le dit item d'une listview...

Le problème : Je sais le faire, quand il n'y a qu'une seule listview, comme ceci : https://www.autoitscript.com/forum/topi ... ent=586083
Avec WM_NOTIFY($hWnd, $Msg, $wParam, $lParam)

Le véritable problème : je souhaite récupérer donc l'item et sous item de n'importe quel listview...
Je pensais donc créer plusieurs WM_NOTIFY, un pour chaque listview.

Je pense m'être bercé d'illusion :mrgreen:

J'ai volontairement réduit le script, afin de se baser sur le "phénomène"
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <File.au3>
#include <GuiListView.au3>





Global $Form1 = GUICreate("Form1", 1215, 765, (@DesktopWidth - 1215) / 2, (@DesktopHeight - 765) / 2 - 30)
GUISetFont(9, 500, 0, 'comic sans ms')


$lv_32x = GUICtrlCreateListView("Choix #1|Choix #2", 0, 0, 300, 250)
GUICtrlSendMsg(-1, 4126, 0, 100)
GUICtrlSendMsg(-1, 4126, 1, 100)

$lv_gg = GUICtrlCreateListView("Choix #1|Choix #2", 305, 0, 300, 250)
GUICtrlSendMsg(-1, 4126, 0, 100)
GUICtrlSendMsg(-1, 4126, 1, 100)

$lv_gb = GUICtrlCreateListView("Choix #1|Choix #2", 610, 0, 300, 250)
GUICtrlSendMsg(-1, 4126, 0, 100)
GUICtrlSendMsg(-1, 4126, 1, 100)

$lv_gba = GUICtrlCreateListView("Choix #1|Choix #2", 915, 0, 300, 250)
GUICtrlSendMsg(-1, 4126, 0, 100)
GUICtrlSendMsg(-1, 4126, 1, 100)

$lv_gbc = GUICtrlCreateListView("Choix #1|Choix #2", 0, 255, 300, 250)
GUICtrlSendMsg(-1, 4126, 0, 100)
GUICtrlSendMsg(-1, 4126, 1, 100)

$lv_ms = GUICtrlCreateListView("Choix #1|Choix #2", 305, 255, 300, 250)
GUICtrlSendMsg(-1, 4126, 0, 100)
GUICtrlSendMsg(-1, 4126, 1, 100)

$lv_mgd = GUICtrlCreateListView("Choix #1|Choix #2", 610, 255, 300, 250)
GUICtrlSendMsg(-1, 4126, 0, 100)
GUICtrlSendMsg(-1, 4126, 1, 100)

$lv_nes = GUICtrlCreateListView("Choix #1|Choix #2", 915, 255, 300, 250)
GUICtrlSendMsg(-1, 4126, 0, 100)
GUICtrlSendMsg(-1, 4126, 1, 100)

$lv_psx1 = GUICtrlCreateListView("Choix #1|Choix #2", 0, 510, 300, 250)
GUICtrlSendMsg(-1, 4126, 0, 100)
GUICtrlSendMsg(-1, 4126, 1, 100)

$lv_psx2 = GUICtrlCreateListView("Choix #1|Choix #2", 305, 510, 300, 250)
GUICtrlSendMsg(-1, 4126, 0, 100)
GUICtrlSendMsg(-1, 4126, 1, 100)

$lv_snes = GUICtrlCreateListView("Choix #1|Choix #2", 610, 510, 300, 250)
GUICtrlSendMsg(-1, 4126, 0, 100)
GUICtrlSendMsg(-1, 4126, 1, 100)



GUICtrlCreateLabel('input #1', 925, 550, 110, 20)
GUICtrlSetFont(-1, 10)
$cs_em = GUICtrlCreateInput('', 1050, 550, 140, 20)
GUICtrlSetFont(-1, 10)
GUICtrlCreateLabel('input #2', 925, 590, 110, 20)
GUICtrlSetFont(-1, 10)
$jx_sl = GUICtrlCreateInput('', 1050, 590, 140, 20)
GUICtrlSetFont(-1, 10)

$Go = GUICtrlCreateButton("Go !", 925, 700, 280, 40)
GUICtrlSetFont(-1, 12)



_lslv()






GUICtrlSendMsg($lv_32x, $lvm_setcolumnwidth, 1, $lvscw_autosize)
GUICtrlSendMsg($lv_gg, $lvm_setcolumnwidth, 1, $lvscw_autosize)


GUICtrlSendMsg($lv_gb, $lvm_setcolumnwidth, 1, $lvscw_autosize)
GUICtrlSendMsg($lv_gba, $lvm_setcolumnwidth, 1, $lvscw_autosize)
GUICtrlSendMsg($lv_gbc, $lvm_setcolumnwidth, 1, $lvscw_autosize)
GUICtrlSendMsg($lv_ms, $lvm_setcolumnwidth, 1, $lvscw_autosize)
GUICtrlSendMsg($lv_mgd, $lvm_setcolumnwidth, 1, $lvscw_autosize)
GUICtrlSendMsg($lv_nes, $lvm_setcolumnwidth, 1, $lvscw_autosize)
GUICtrlSendMsg($lv_psx1, $lvm_setcolumnwidth, 1, $lvscw_autosize)
GUICtrlSendMsg($lv_psx2, $lvm_setcolumnwidth, 1, $lvscw_autosize)
GUICtrlSendMsg($lv_snes, $lvm_setcolumnwidth, 1, $lvscw_autosize)

GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY_32X")
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY_GG")

GUISetState(@SW_SHOW)


While 1
   $nMsg = GUIGetMsg()
   Switch $nMsg
      Case $GUI_EVENT_CLOSE
         Exit



   EndSwitch
WEnd


Func _lslv()






   For $a = 1 To 10
      GUICtrlCreateListViewItem($a&"|"&$a+1, $lv_32x)
   Next
   For $a = 2 To 11
      GUICtrlCreateListViewItem($a&"|"&$a+1, $lv_gg)
   Next
   For $a = 3 To 12
      GUICtrlCreateListViewItem($a&"|"&$a+1, $lv_gb)
   Next
   For $a = 4 To 13
      GUICtrlCreateListViewItem($a&"|"&$a+1, $lv_gba)
   Next
   For $a = 5 To 14
      GUICtrlCreateListViewItem($a&"|"&$a+1, $lv_gbc)
   Next
   For $a = 6 To 15
      GUICtrlCreateListViewItem($a&"|"&$a+1, $lv_ms)
   Next
   For $a = 7 To 16
      GUICtrlCreateListViewItem($a&"|"&$a+1, $lv_mgd)
   Next
   For $a = 8 To 17
      GUICtrlCreateListViewItem($a&"|"&$a+1,  $lv_nes)
   Next

   For $a = 9 To 18
      GUICtrlCreateListViewItem($a&"|"&$a+1, $lv_psx1)
   Next
   For $a = 10 To 19
      GUICtrlCreateListViewItem($a&"|"&$a+1, $lv_psx1)
   Next

   For $a = 11 To 20
      GUICtrlCreateListViewItem($a&"|"&$a+1, $lv_psx2)
   Next

   For $a = 12 To 21
      GUICtrlCreateListViewItem($a&"|"&$a+1, $lv_snes)
   Next





EndFunc   ;==>_jeux


; EMULATION :
; -----------
; 32X : KegaFusion
; Game Gear : BizHawk
; GameBoy : BizHawk
; GameBoy Advance : BizHawk
; GameBoy Color : BizHawk
; Master System : BizHawk
; Megadrive : BizHawk
; Nintendo Nes : BizHawk
; Playstation :
; Playstation 2 :
; Super Nintendo : BizHawk

Func WM_NOTIFY_32X($hWnd, $Msg, $wParam, $lParam)
   Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView
   $hWndListView = $lv_32x
   If Not IsHWnd($hWndListView) Then $hWndListView = GUICtrlGetHandle($lv_32x)

   $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
   $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
   $iCode = DllStructGetData($tNMHDR, "Code")

   Switch $hWndFrom
      Case $hWndListView
         Switch $iCode
            Case $NM_CLICK
               $indice = _GUICtrlListView_GetSelectedIndices($lv_32x)
               $console = _GUICtrlListView_GetItem($lv_32x, Int($indice), 0)[3]
               $jeu = _GUICtrlListView_GetItem($lv_32x, Int($indice), 1)[3]
               GUICtrlSetData($cs_em, $console)
               GUICtrlSetData($jx_sl, $jeu)

         EndSwitch
   EndSwitch

   Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Func WM_NOTIFY_GG($hWnd, $Msg, $wParam, $lParam)
   Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView
   $hWndListView = $lv_gg
   If Not IsHWnd($hWndListView) Then $hWndListView = GUICtrlGetHandle($lv_gg)

   $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
   $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
   $iCode = DllStructGetData($tNMHDR, "Code")

   Switch $hWndFrom
      Case $hWndListView
         Switch $iCode
            Case $NM_CLICK
               $indice = _GUICtrlListView_GetSelectedIndices($lv_gg)
               $console = _GUICtrlListView_GetItem($lv_gg, Int($indice), 0)[3]
               $jeu = _GUICtrlListView_GetItem($lv_gg, Int($indice), 1)[3]
               GUICtrlSetData($cs_em, $console)
               GUICtrlSetData($jx_sl, $jeu)

         EndSwitch
   EndSwitch

   Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY
 

Je pense avoir compris ceci : dans ce script, il ne peut qu'avoir un seul $WM_NOTIFY. Donc le dernier est uniquement pris en compte...


Pouvez-vous m'aiguiller ? Merci 8)


@++

Re: [..] Action sur listview - récupération d'item

Posté : mar. 19 févr. 2019 10:43
par franco
Salut.

J'ai créé un énième bouton permettant de récupérer l'item / sous-item choisit, selon la listview.

Ce bouton a cette fonction :
Func _AddInfo()

   Local $console, $jeu

   Dim $var[12]
   $var[1] = $lv_32x
   $var[2] = $lv_gg
   $var[3] = $lv_gb
   $var[4] = $lv_gba
   $var[5] = $lv_gbc
   $var[6] = $lv_ms
   $var[7] = $lv_mgd
   $var[8] = $lv_nes
   $var[9] = $lv_psx1
   $var[10] = $lv_psx2
   $var[11] = $lv_snes

   For $a = 1 To 11

      $indice = _GUICtrlListView_GetSelectedIndices($var[$a])

      If $indice <> "" Then
         $console = _GUICtrlListView_GetItem($var[$a], Int($indice), 0)[3]
         $jeu = _GUICtrlListView_GetItem($var[$a], Int($indice), 1)[3]
      EndIf

   Next

   If $console <> "" And $jeu <> "" Then
      GUICtrlSetData($cns_em, $console)
      GUICtrlSetData($jeu_sl, $jeu)
   EndIf

EndFunc   ;==>_AddInfo
Donc en listant les différentes listview, et en détectant l'indice sélectionné, je peux par la suite récupérer le bon item avec son sous-item...


Si, à chaque clic d'une item, quelque soit la listview choisit, ça me lance cette fonction, mon problème serait résolu...
Encore faut-il que j'y arrive :mrgreen:


Le code complet :
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <File.au3>
#include <GuiListView.au3>





Global $Form1 = GUICreate("Form1", 1215, 765, (@DesktopWidth - 1215) / 2, (@DesktopHeight - 765) / 2 - 30)
GUISetFont(9, 500, 0, 'comic sans ms')


$lv_32x = GUICtrlCreateListView("Choix #1|Choix #2", 0, 0, 300, 250)
GUICtrlSendMsg(-1, 4126, 0, 100)
GUICtrlSendMsg(-1, 4126, 1, 100)

$lv_gg = GUICtrlCreateListView("Choix #1|Choix #2", 305, 0, 300, 250)
GUICtrlSendMsg(-1, 4126, 0, 100)
GUICtrlSendMsg(-1, 4126, 1, 100)

$lv_gb = GUICtrlCreateListView("Choix #1|Choix #2", 610, 0, 300, 250)
GUICtrlSendMsg(-1, 4126, 0, 100)
GUICtrlSendMsg(-1, 4126, 1, 100)

$lv_gba = GUICtrlCreateListView("Choix #1|Choix #2", 915, 0, 300, 250)
GUICtrlSendMsg(-1, 4126, 0, 100)
GUICtrlSendMsg(-1, 4126, 1, 100)

$lv_gbc = GUICtrlCreateListView("Choix #1|Choix #2", 0, 255, 300, 250)
GUICtrlSendMsg(-1, 4126, 0, 100)
GUICtrlSendMsg(-1, 4126, 1, 100)

$lv_ms = GUICtrlCreateListView("Choix #1|Choix #2", 305, 255, 300, 250)
GUICtrlSendMsg(-1, 4126, 0, 100)
GUICtrlSendMsg(-1, 4126, 1, 100)

$lv_mgd = GUICtrlCreateListView("Choix #1|Choix #2", 610, 255, 300, 250)
GUICtrlSendMsg(-1, 4126, 0, 100)
GUICtrlSendMsg(-1, 4126, 1, 100)

$lv_nes = GUICtrlCreateListView("Choix #1|Choix #2", 915, 255, 300, 250)
GUICtrlSendMsg(-1, 4126, 0, 100)
GUICtrlSendMsg(-1, 4126, 1, 100)

$lv_psx1 = GUICtrlCreateListView("Choix #1|Choix #2", 0, 510, 300, 250)
GUICtrlSendMsg(-1, 4126, 0, 100)
GUICtrlSendMsg(-1, 4126, 1, 100)

$lv_psx2 = GUICtrlCreateListView("Choix #1|Choix #2", 305, 510, 300, 250)
GUICtrlSendMsg(-1, 4126, 0, 100)
GUICtrlSendMsg(-1, 4126, 1, 100)

$lv_snes = GUICtrlCreateListView("Choix #1|Choix #2", 610, 510, 300, 250)
GUICtrlSendMsg(-1, 4126, 0, 100)
GUICtrlSendMsg(-1, 4126, 1, 100)



GUICtrlCreateLabel('input #1', 925, 550, 110, 20)
GUICtrlSetFont(-1, 10)
$cns_em = GUICtrlCreateInput('', 1050, 550, 140, 20)
GUICtrlSetFont(-1, 10)
GUICtrlCreateLabel('input #2', 925, 590, 110, 20)
GUICtrlSetFont(-1, 10)
$jeu_sl = GUICtrlCreateInput('', 1050, 590, 140, 20)
GUICtrlSetFont(-1, 10)

$Go = GUICtrlCreateButton("Go !", 925, 700, 280, 40)
GUICtrlSetFont(-1, 12)



_lslv()


$aj_info = GUICtrlCreateButton("Ajouter", 925, 630, 120, 20)



GUICtrlSendMsg($lv_32x, $lvm_setcolumnwidth, 1, $lvscw_autosize)
GUICtrlSendMsg($lv_gg, $lvm_setcolumnwidth, 1, $lvscw_autosize)


GUICtrlSendMsg($lv_gb, $lvm_setcolumnwidth, 1, $lvscw_autosize)
GUICtrlSendMsg($lv_gba, $lvm_setcolumnwidth, 1, $lvscw_autosize)
GUICtrlSendMsg($lv_gbc, $lvm_setcolumnwidth, 1, $lvscw_autosize)
GUICtrlSendMsg($lv_ms, $lvm_setcolumnwidth, 1, $lvscw_autosize)
GUICtrlSendMsg($lv_mgd, $lvm_setcolumnwidth, 1, $lvscw_autosize)
GUICtrlSendMsg($lv_nes, $lvm_setcolumnwidth, 1, $lvscw_autosize)
GUICtrlSendMsg($lv_psx1, $lvm_setcolumnwidth, 1, $lvscw_autosize)
GUICtrlSendMsg($lv_psx2, $lvm_setcolumnwidth, 1, $lvscw_autosize)
GUICtrlSendMsg($lv_snes, $lvm_setcolumnwidth, 1, $lvscw_autosize)


GUISetState(@SW_SHOW)


While 1
   $nMsg = GUIGetMsg()
   Switch $nMsg
      Case $GUI_EVENT_CLOSE
         Exit

      Case $aj_info
         _AddInfo()


   EndSwitch
WEnd


Func _lslv()


   For $a = 1 To 10
      GUICtrlCreateListViewItem($a & "|" & $a + 1, $lv_32x)
   Next
   For $a = 2 To 11
      GUICtrlCreateListViewItem($a & "|" & $a + 1, $lv_gg)
   Next
   For $a = 3 To 12
      GUICtrlCreateListViewItem($a & "|" & $a + 1, $lv_gb)
   Next
   For $a = 4 To 13
      GUICtrlCreateListViewItem($a & "|" & $a + 1, $lv_gba)
   Next
   For $a = 5 To 14
      GUICtrlCreateListViewItem($a & "|" & $a + 1, $lv_gbc)
   Next
   For $a = 6 To 15
      GUICtrlCreateListViewItem($a & "|" & $a + 1, $lv_ms)
   Next
   For $a = 7 To 16
      GUICtrlCreateListViewItem($a & "|" & $a + 1, $lv_mgd)
   Next
   For $a = 8 To 17
      GUICtrlCreateListViewItem($a & "|" & $a + 1, $lv_nes)
   Next

   For $a = 9 To 18
      GUICtrlCreateListViewItem($a & "|" & $a + 1, $lv_psx1)
   Next
   For $a = 10 To 19
      GUICtrlCreateListViewItem($a & "|" & $a + 1, $lv_psx1)
   Next

   For $a = 11 To 20
      GUICtrlCreateListViewItem($a & "|" & $a + 1, $lv_psx2)
   Next

   For $a = 12 To 21
      GUICtrlCreateListViewItem($a & "|" & $a + 1, $lv_snes)
   Next





EndFunc   ;==>_lslv


; EMULATION :
; -----------
; 32X : KegaFusion
; Game Gear : BizHawk
; GameBoy : BizHawk
; GameBoy Advance : BizHawk
; GameBoy Color : BizHawk
; Master System : BizHawk
; Megadrive : BizHawk
; Nintendo Nes : BizHawk
; Playstation :
; Playstation 2 :
; Super Nintendo : BizHawk

Func _AddInfo()

   Local $console, $jeu

   Dim $var[12]
   $var[1] = $lv_32x
   $var[2] = $lv_gg
   $var[3] = $lv_gb
   $var[4] = $lv_gba
   $var[5] = $lv_gbc
   $var[6] = $lv_ms
   $var[7] = $lv_mgd
   $var[8] = $lv_nes
   $var[9] = $lv_psx1
   $var[10] = $lv_psx2
   $var[11] = $lv_snes

   For $a = 1 To 11

      $indice = _GUICtrlListView_GetSelectedIndices($var[$a])

      If $indice <> "" Then
         $console = _GUICtrlListView_GetItem($var[$a], Int($indice), 0)[3]
         $jeu = _GUICtrlListView_GetItem($var[$a], Int($indice), 1)[3]
      EndIf

   Next

   If $console <> "" And $jeu <> "" Then
      GUICtrlSetData($cns_em, $console)
      GUICtrlSetData($jeu_sl, $jeu)
   EndIf

EndFunc   ;==>_AddInfo


En gros, ce que je veux faire, j'y arrive avec le "bouton".
mais j'aimerais par conséquent, faire de même en cliquant sur l'item choisi... de n'importe quel listview...

Est-ce possible ? Ou dois-je garder le système du bouton "remplissage d'input" ? :mrgreen:


Merci pour vos réponses.
++

Re: [..] Action sur listview - récupération d'item

Posté : mar. 19 févr. 2019 14:36
par walkson
Bonjour,
Comme ça ?

Code : Tout sélectionner

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>

Global $Form1 = GUICreate("Form1", 522, 268, 691, 192)
Global $ListView1 = GUICtrlCreateListView("|||", 16, 16, 153, 161)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 50)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 50)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 50)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 3, 50)
Global $ListView1_0 = GUICtrlCreateListViewItem("aa|zz|ww", $ListView1)
Global $ListView1_1 = GUICtrlCreateListViewItem("bb|qq|dd", $ListView1)
Global $ListView2 = GUICtrlCreateListView("|||", 180, 16, 153, 161)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 50)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 50)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 50)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 3, 50)
Global $ListView2_0 = GUICtrlCreateListViewItem("aa1|zz1|ww1", $ListView2)
Global $ListView2_1 = GUICtrlCreateListViewItem("bb1|qq1|dd1", $ListView2)
Global $ListView3 = GUICtrlCreateListView("|||", 346, 18, 153, 161)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 50)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 50)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 50)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 3, 50)
Global $ListView3_0 = GUICtrlCreateListViewItem("aa2|zz2|ww2", $ListView3)
Global $ListView3_1 = GUICtrlCreateListViewItem("bb2|qq2|dd2", $ListView3)
Global $Input1 = GUICtrlCreateInput("", 158, 208, 209, 30)
GUISetState(@SW_SHOW)
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
While 1
 $nMsg = GUIGetMsg()
 Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit

 EndSwitch
WEnd
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    Local $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    Local $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    Local $iCode = DllStructGetData($tNMHDR, "Code")
	Local $List1 = GUICtrlGetHandle($ListView1)
	Local $List2 = GUICtrlGetHandle($ListView2)
	Local $List3 = GUICtrlGetHandle($ListView3)
    Switch $hWndFrom
        Case $List1, $List2, $List3
            Switch $iCode
                Case $NM_CLICK
					$aLV_Click_Info = _GUICtrlListView_SubItemHitTest($hWndFrom)
                    $iIndex = $aLV_Click_Info [0]
					$iSubItem  = $aLV_Click_Info [1]
					GUICtrlSetData($Input1,_GUICtrlListView_GetItemText ( $hWndFrom, $iIndex , $iSubItem ))
					MsgBox(0,"Ma fonction","Action: " & GUICtrlRead($Input1))
			EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY
à noter qu'il est déconseillé de mettre un MsgBox dans un WM_....

Re: [..] Action sur listview - récupération d'item

Posté : mer. 20 févr. 2019 11:07
par franco
Salut.

Je sais que c'est déconseillé de mettre un msgbox dans un WM.
C'était juste pour voir ce que cela me retournait.

Faut dire que j'utilise rarement consolewrite :oops:



Sinon, ton code fonctionne, j'ai donc pu l'adapter.



donc voici le script complet :
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <File.au3>
#include <GuiListView.au3>

#include <EditConstants.au3>

#include <StaticConstants.au3>



Global $Form1 = GUICreate("Form1", 1215, 640, (@DesktopWidth - 1215) / 2, (@DesktopHeight - 640) / 2 - 30)
GUISetFont(9, 500, 0, 'comic sans ms')


$lv_32x = GUICtrlCreateListView("Console|Jeux", 0, 0, 300, 210)
GUICtrlSendMsg(-1, 4126, 0, 100)
GUICtrlSendMsg(-1, 4126, 1, 100)

$lv_gg = GUICtrlCreateListView("Console|Jeux", 305, 0, 300, 210)
GUICtrlSendMsg(-1, 4126, 0, 100)
GUICtrlSendMsg(-1, 4126, 1, 100)

$lv_gb = GUICtrlCreateListView("Console|Jeux", 610, 0, 300, 210)
GUICtrlSendMsg(-1, 4126, 0, 100)
GUICtrlSendMsg(-1, 4126, 1, 100)

$lv_gba = GUICtrlCreateListView("Console|Jeux", 915, 0, 300, 210)
GUICtrlSendMsg(-1, 4126, 0, 100)
GUICtrlSendMsg(-1, 4126, 1, 100)


$lv_gbc = GUICtrlCreateListView("Console|Jeux", 0, 215, 300, 210)
GUICtrlSendMsg(-1, 4126, 0, 100)
GUICtrlSendMsg(-1, 4126, 1, 100)

$lv_ms = GUICtrlCreateListView("Console|Jeux", 305, 215, 300, 210)
GUICtrlSendMsg(-1, 4126, 0, 100)
GUICtrlSendMsg(-1, 4126, 1, 100)

$lv_mgd = GUICtrlCreateListView("Console|Jeux", 610, 215, 300, 210)
GUICtrlSendMsg(-1, 4126, 0, 100)
GUICtrlSendMsg(-1, 4126, 1, 100)

$lv_nes = GUICtrlCreateListView("Console|Jeux", 915, 215, 300, 210)
GUICtrlSendMsg(-1, 4126, 0, 100)
GUICtrlSendMsg(-1, 4126, 1, 100)






$lv_psx1 = GUICtrlCreateListView("Console|Jeux", 0, 430, 300, 210)
GUICtrlSendMsg(-1, 4126, 0, 100)
GUICtrlSendMsg(-1, 4126, 1, 100)

$lv_psx2 = GUICtrlCreateListView("Console|Jeux", 305, 430, 300, 210)
GUICtrlSendMsg(-1, 4126, 0, 100)
GUICtrlSendMsg(-1, 4126, 1, 100)

$lv_snes = GUICtrlCreateListView("Console|Jeux", 610, 430, 300, 210)
GUICtrlSendMsg(-1, 4126, 0, 100)
GUICtrlSendMsg(-1, 4126, 1, 100)

_jeux()


$suppr_info = GUICtrlCreateButton("Supprimer les zones", 1070, 430, 135, 40)
GUICtrlSetFont(-1, 10)

GUICtrlCreateLabel('Console émulée', 925, 500, 110, 20)
GUICtrlSetFont(-1, 10)
$cns_em = GUICtrlCreateInput('', 1050, 500, 140, 20)
GUICtrlSetStyle(-1, $WS_VISIBLE + $WS_CHILD, $WS_EX_CLIENTEDGE)
GUICtrlSetFont(-1, 10)

GUICtrlCreateLabel('Jeu sélectionné', 925, 540, 110, 20)
GUICtrlSetFont(-1, 10)
$jeu_sl = GUICtrlCreateInput('', 1050, 540, 140, 20)
GUICtrlSetFont(-1, 10)


$playgame = GUICtrlCreateButton("Lancez ce jeu", 925, 595, 120, 40)
GUICtrlSetFont(-1, 12)


GUICtrlCreateLabel("",1080,595,120,1,$SS_SUNKEN+$ws_border)
GUICtrlCreateLabel("",1200,595,1,40,$SS_SUNKEN+$ws_border)
GUICtrlCreateLabel("",1080,635,120,1,$SS_SUNKEN+$ws_border)
GUICtrlCreateLabel("",1080,595,1,40,$SS_SUNKEN+$ws_border)

$raz_ent =  GUICtrlCreateButton("🔄",1100,599.5,22,22)
$red = GUICtrlCreateButton("-",1130,600,20,20,$ws_border)
$quit =  GUICtrlCreateButton("X",1160,600,20,20,$ws_border)

$progressbar = GUICtrlCreateProgress(1080, 625, 120, 10,$ws_border)


GUICtrlSendMsg($lv_32x, $lvm_setcolumnwidth, 1, $lvscw_autosize)
GUICtrlSendMsg($lv_gg, $lvm_setcolumnwidth, 1, $lvscw_autosize)
GUICtrlSendMsg($lv_gb, $lvm_setcolumnwidth, 1, $lvscw_autosize)
GUICtrlSendMsg($lv_gba, $lvm_setcolumnwidth, 1, $lvscw_autosize)
GUICtrlSendMsg($lv_gbc, $lvm_setcolumnwidth, 1, $lvscw_autosize)
GUICtrlSendMsg($lv_ms, $lvm_setcolumnwidth, 1, $lvscw_autosize)
GUICtrlSendMsg($lv_mgd, $lvm_setcolumnwidth, 1, $lvscw_autosize)
GUICtrlSendMsg($lv_nes, $lvm_setcolumnwidth, 1, $lvscw_autosize)
GUICtrlSendMsg($lv_psx1, $lvm_setcolumnwidth, 1, $lvscw_autosize)
GUICtrlSendMsg($lv_psx2, $lvm_setcolumnwidth, 1, $lvscw_autosize)
GUICtrlSendMsg($lv_snes, $lvm_setcolumnwidth, 1, $lvscw_autosize)


GUISetState(@SW_SHOW)

GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

While 1
   $nMsg = GUIGetMsg()
   Switch $nMsg

      Case $GUI_EVENT_CLOSE,$quit
         Exit
      case $red
         GUISetState(@SW_MINIMIZE)

      case $raz_ent

         GUICtrlSetStyle($progressbar, 0x040A)
         GUICtrlSendMsg($progressbar, 0x0400 + 10, 1, Number(30))

         _jeux()
         GUICtrlSetData($cns_em,"")
         GUICtrlSetData($jeu_sl,"")

         GUICtrlSetStyle($progressbar, 0)
         Local $aResult = DllCall("user32.dll", "lresult", "SendMessageW", "hwnd", GUICtrlGetHandle($progressbar), "uint", 0x040A, "wparam", False, "lparam", 0)

      Case $playgame

         Local $emul

         $console = GUICtrlRead($cns_em)
         $jeu = GUICtrlRead($jeu_sl)

         If $console <> "" And $jeu <> "" Then
            MsgBox(0, '', $console)
            If $console = "32X" Then $emul = @ScriptDir & "\Emulation\KegaFusion\Fusion.exe"
            If $console = "GG" Then $emul = @ScriptDir & "\Emulation\BizHawk\EmuHawk.exe"
            If $console = "GB" Then $emul = @ScriptDir & "\Emulation\BizHawk\EmuHawk.exe"
            If $console = "GBA" Then $emul = @ScriptDir & "\Emulation\BizHawk\EmuHawk.exe"
            If $console = "GBC" Then $emul = @ScriptDir & "\Emulation\BizHawk\EmuHawk.exe"
            If $console = "MS" Then $emul = @ScriptDir & "\Emulation\BizHawk\EmuHawk.exe"
            If $console = "MGD" Then $emul = @ScriptDir & "\Emulation\BizHawk\EmuHawk.exe"
            If $console = "NES" Then $emul = @ScriptDir & "\Emulation\BizHawk\EmuHawk.exe"
            If $console = "PSX1" Then $emul = @ScriptDir & "\Emulation\"
            If $console = "PSX2" Then $emul = @ScriptDir & "\Emulation\"
            If $console = "SNES" Then $emul = @ScriptDir & "\Emulation\BizHawk\EmuHawk.exe"
         EndIf

         If FileExists($emul) And StringRight($emul, 4) = '.exe' Then MsgBox(0, '', $emul)

      Case $suppr_info
         GUICtrlSetData($cns_em, '')
         GUICtrlSetData($jeu_sl, '')

   EndSwitch
WEnd


Func _jeux()

   $jeux_32x = @ScriptDir & "\Jeux\32x"
   $jeux_gg = @ScriptDir & "\Jeux\Game Gear"
   $jeux_gb = @ScriptDir & "\Jeux\GameBoy"
   $jeux_gba = @ScriptDir & "\Jeux\GameBoy Advance"
   $jeux_gbc = @ScriptDir & "\Jeux\GameBoy Color"
   $jeux_ms = @ScriptDir & "\Jeux\Master System"
   $jeux_mgd = @ScriptDir & "\Jeux\Megadrive"
   $jeux_nes = @ScriptDir & "\Jeux\Nintendo Nes"
   $jeux_psx1 = @ScriptDir & "\Jeux\Playstation"
   $jeux_psx2 = @ScriptDir & "\Jeux\Playstation 2"
   $jeux_snes = @ScriptDir & "\Jeux\Super Nintendo"

   _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($lv_32x))
   _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($lv_gg))
   _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($lv_gb))
   _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($lv_gba))
   _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($lv_gbc))
   _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($lv_ms))
   _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($lv_mgd))
   _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($lv_nes))
   _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($lv_psx1))
   _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($lv_psx2))
   _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($lv_snes))

   $32x_f = _FileListToArray($jeux_32x, "*.32x", 1, False)
   $gg_f = _FileListToArray($jeux_gg, "*.gg", 1, False)
   $gb_f = _FileListToArray($jeux_gb, "*.gb", 1, False)
   $gba_f = _FileListToArray($jeux_gba, "*.gba", 1, False)
   $gbc_f = _FileListToArray($jeux_gbc, "*.gbc", 1, False)
   $ms_f = _FileListToArray($jeux_ms, "*.sms", 1, False)
   $mgd_f = _FileListToArray($jeux_mgd, "*.bin", 1, False)
   $nes_f = _FileListToArray($jeux_nes, "*.nes", 1, False)
   $psx1_f = _FileListToArray($jeux_psx1, "*.bin", 1, False)
   $psx11_f = _FileListToArray($jeux_psx1, "*.iso", 1, False)
   $psx2_f = _FileListToArray($jeux_psx2, "*.iso", 1, False)
   $snes_f = _FileListToArray($jeux_snes, "*.smc", 1, False)


   For $a = 1 To $32x_f[0]
      GUICtrlCreateListViewItem("32X|" & $32x_f[$a], $lv_32x)
   Next
   For $a = 1 To $gg_f[0]
      GUICtrlCreateListViewItem("GG|" & $gg_f[$a], $lv_gg)
   Next
   For $a = 1 To $gb_f[0]
      GUICtrlCreateListViewItem("GB|" & $gb_f[$a], $lv_gb)
   Next
   For $a = 1 To $gba_f[0]
      GUICtrlCreateListViewItem("GBA|" & $gba_f[$a], $lv_gba)
   Next
   For $a = 1 To $gbc_f[0]
      GUICtrlCreateListViewItem("GBC|" & $gbc_f[$a], $lv_gbc)
   Next
   For $a = 1 To $ms_f[0]
      GUICtrlCreateListViewItem("MS|" & $ms_f[$a], $lv_ms)
   Next
   For $a = 1 To $mgd_f[0]
      GUICtrlCreateListViewItem("MGD|" & $mgd_f[$a], $lv_mgd)
   Next
   For $a = 1 To $nes_f[0]
      GUICtrlCreateListViewItem("NES|" & $nes_f[$a], $lv_nes)
   Next

   For $a = 1 To $psx1_f[0]
      GUICtrlCreateListViewItem("PSX1|" & $psx1_f[$a], $lv_psx1)
   Next
   For $a = 1 To $psx11_f[0]
      GUICtrlCreateListViewItem("PSX1|" & $psx11_f[$a], $lv_psx1)
   Next

   For $a = 1 To $psx2_f[0]
      GUICtrlCreateListViewItem("PSX2|" & $psx2_f[$a], $lv_psx2)
   Next

   For $a = 1 To $snes_f[0]
      GUICtrlCreateListViewItem("SNES|" & $snes_f[$a], $lv_snes)
   Next





EndFunc   ;==>_jeux


Func _AddGame()


   Local $indice_32x, $indice_gg
   GUICtrlSetData($cns_em, '')
   GUICtrlSetData($jeu_sl, '')
   $indice_32x = _GUICtrlListView_GetSelectedIndices($lv_32x)
   If $indice_32x <> "" Then
      $console_32x = _GUICtrlListView_GetItem($lv_32x, Int($indice_32x), 0)[3]
      $jeu_32x = _GUICtrlListView_GetItem($lv_32x, Int($indice_32x), 1)[3]
      GUICtrlSetData($cns_em, $console_32x)
      GUICtrlSetData($jeu_sl, $jeu_32x)
   EndIf

;~          Local $indice
   GUICtrlSetData($cns_em, '')
   GUICtrlSetData($jeu_sl, '')

   $indice_gg = _GUICtrlListView_GetSelectedIndices($lv_gg)
   If $indice_gg <> "" Then
      $console_gg = _GUICtrlListView_GetItem($lv_gg, Int($indice_gg), 0)[3]
      $jeu_gg = _GUICtrlListView_GetItem($lv_gg, Int($indice_gg), 1)[3]
      GUICtrlSetData($cns_em, $console_gg)
      GUICtrlSetData($jeu_sl, $jeu_gg)
   EndIf



EndFunc   ;==>_AddGame


; EMULATION :
; -----------
; 32X : KegaFusion
; Game Gear : BizHawk
; GameBoy : BizHawk
; GameBoy Advance : BizHawk
; GameBoy Color : BizHawk
; Master System : BizHawk
; Megadrive : BizHawk
; Nintendo Nes : BizHawk
; Playstation :
; Playstation 2 :
; Super Nintendo : BizHawk

Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
   Local $console, $jeu
   Local $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
   Local $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
   Local $iCode = DllStructGetData($tNMHDR, "Code")
   Local $List1 = GUICtrlGetHandle($lv_32x)
   Local $List2 = GUICtrlGetHandle($lv_gg)
   Local $List3 = GUICtrlGetHandle($lv_gb)
   Local $List4 = GUICtrlGetHandle($lv_gba)
   Local $List5 = GUICtrlGetHandle($lv_gbc)
   Local $List6 = GUICtrlGetHandle($lv_ms)
   Local $List7 = GUICtrlGetHandle($lv_mgd)
   Local $List8 = GUICtrlGetHandle($lv_nes)
   Local $List9 = GUICtrlGetHandle($lv_psx1)
   Local $List10 = GUICtrlGetHandle($lv_psx2)
   Local $List11 = GUICtrlGetHandle($lv_snes)







   Switch $hWndFrom
      Case $List1, $List2, $List3, $List4, $List5, $List6, $List7, $List8, $List9, $List10, $List11
         Switch $iCode
            Case $NM_CLICK
               $indice = _GUICtrlListView_GetSelectedIndices($hWndFrom)
               If $indice <> "" Then
                  $console = _GUICtrlListView_GetItem($hWndFrom, Int($indice), 0)[3]
                  $jeu = _GUICtrlListView_GetItem($hWndFrom, Int($indice), 1)[3]
                  GUICtrlSetData($cns_em, $console)
                  GUICtrlSetData($jeu_sl, $jeu)
               Else
                  GUICtrlSetData($cns_em, "")
                  GUICtrlSetData($jeu_sl, "")
               EndIf

         EndSwitch
   EndSwitch
   Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Je passe donc en résolu, merci à toi :)


++