Jump to content
Sign in to follow this  
dascondor

Help with Opt(GUISetOnEvent ,1)

Recommended Posts

dascondor

So I having issues with this GUI/Listview. My main GUI works like it needs to but the ListView GUIs don't. The exit buttons do not work on them and om have a hard time getting them to work. And I'm trying to make the  listview GUI resizeable. But I'm not sure how to fix either of these issues any thoughts.

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <File.au3>
#include <ScreenCapture.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>
#include <Array.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <ListviewConstants.au3>
#include 'MultiPing.au3'



Opt("GUIOnEventMode", 1)


#Region ;Declares
; Reads text file for the base list of IP's
Global $aBase_IPlist = _FileReadToArray_mod(".\IP_List.txt")

Global $replace2 = "Second"
Global $replace3 = "Thrid"

;Global $userdata1 = GUICtrlRead($data1)
;Global $userdata2 = GUICtrlRead($data2)

Global $savefolder = "C:\Users\"
Global $paths = "\Desktop\PingChecks"
Global $1stpaths = "\~~~Store"
Global $2ndpaths = "~~~"
Global $results = FileExists($savefolder & @UserName & $paths)
;Global $foldercheck = FileExists($savefolder & @UserName & $paths & $1stpaths & $userdata1 & $userdata2 & $2ndpaths)
;Global $savefile = "C:\Users\" & @UserName & "\Desktop\PingChecks\~~~Store" & $userdata1 & $userdata2 & "~~~\"




#EndRegion ;Declares



#Region ### START Koda GUI section ### Form=
$IPMonkey = GUICreate("IP Monkey", 573, 254, -1, -1)
GUISetIcon("C:\Users\Dlex\Pictures\monkeyicon.ico", -1)
GUISetFont(16, 800, 0, "Arial")
GUISetBkColor(0xFFFFFF)
GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "SpecialEvents")
GUISetOnEvent($GUI_EVENT_MAXIMIZE, "SpecialEvents")
GUISetOnEvent($GUI_EVENT_RESTORE, "SpecialEvents")
$data1 = GUICtrlCreateInput("1", 184, 120, 89, 32, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER))
GUICtrlSetColor(-1, 0x000000)
$data2 = GUICtrlCreateInput("23", 280, 120, 89, 32, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER))
GUICtrlSetColor(-1, 0x000000)
$GOButton = GUICtrlCreateButton("GO", 80, 192, 75, 25)
GUICtrlSetFont(-1, 10, 800, 0, "Arial")
GUICtrlSetColor(-1, 0x000000)
GUICtrlSetBkColor(-1, 0x00FF00)
GUICtrlSetTip(-1, "Runs A Live Continuous Ping" & @CRLF & _
        "Until Told Other Wise")
GUICtrlSetOnEvent(-1, "GOButtonClick")
$quickscan = GUICtrlCreateButton("Quick Scan", 224, 192, 107, 25)
GUICtrlSetFont(-1, 12, 800, 0, "Arial")
GUICtrlSetColor(-1, 0x000000)
GUICtrlSetBkColor(-1, 0xFFFF00)
GUICtrlSetOnEvent(-1, "quickscanClick")
GUICtrlSetTip(-1, "Quickly Scans, Then Saves" & @CRLF & _
        "Results In Your 'PingChecks' " & @CRLF & _
        "Folder Under Your Store Number Folder")
Global $exitbutton = GUICtrlCreateButton("Exit", 416, 192, 75, 25)
GUICtrlSetFont(-1, 12, 800, 0, "Arial")
GUICtrlSetColor(-1, 0x000000)
GUICtrlSetBkColor(-1, 0xFF0000)
GUICtrlSetTip(-1, "What Do You Think This Button Does?")
GUICtrlSetOnEvent(-1, "exitbuttonClick")
$titlebar = GUICtrlCreateLabel("IP Monkey", 16, 120, 107, 28)
GUICtrlSetColor(-1, 0x000000)
$Pic1 = GUICtrlCreatePic("C:\Users\Dlex\Pictures\monkeyicon-0.jpg", 16, 16, 100, 100)
GUICtrlSetOnEvent(-1, "Pic1Click")
$infobutton = GUICtrlCreateButton("?", 536, 8, 27, 25)
GUICtrlSetColor(-1, 0x000000)
GUICtrlSetBkColor(-1, 0xFF8000)
GUICtrlSetTip(-1, "Unsure what to do?" & @CRLF & _
        "This will get give you " & @CRLF & _
        "the help for IP Monkey")
GUICtrlSetOnEvent(-1, "infobuttonClick")
$Whatstorelabel = GUICtrlCreateLabel("What Store?", 208, 56, 130, 28)
GUICtrlSetColor(-1, 0x000000)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

#Region ;ping gui

; ------ pinger GUI -------------------
Global $StopPing = 0
Local $Win_X = 1200, $Win_Y = 880 ; dimension of window
Global $PingGui = GUICreate("IP Monkey", $Win_X, $Win_Y, -1, -1)
GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")
Global $listview = GUICtrlCreateListView("", 10, 10, $Win_X - 20, $Win_Y - 40)
GUICtrlSetFont(-1, 8)
$button1 = GUICtrlCreateLabel("Hit Exit To Quit", 10, $Win_Y - 25, $Win_X - 20, 20, -1,$ES_CENTER)
GUICtrlSetFont(-1, 10, 800)
GUICtrlSetTip(-1, "exit")
GUICtrlSetOnEvent(-1, 'SpecialEvents')
GUICtrlSetStyle($listview, $LVS_ICON) ; + $LVS_NOLABELWRAP)
GUISetState(@SW_HIDE) ; hidden at startup
; --------- end of pinger gui -------------
#EndRegion ;ping gui


; Generate colored square images
$hImage = _GUIImageList_Create(30, 30)
_GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($listview, 0xFFFF00, 30, 30)) ; yellow
_GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($listview, 0xFF0000, 30, 30)) ; red
_GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($listview, 0x00FF00, 30, 30)) ; green

_GUICtrlListView_SetImageList($listview, $hImage, 0)






While 1
    Sleep(100)
WEnd


Func exitbuttonClick()
    MsgBox(0,'0','0')
    Exit

EndFunc   ;==>exitbuttonClick
Func GOButtonClick()
    $userdata1 = GUICtrlRead($data1)
    $userdata2 = GUICtrlRead($data2)
    ; pass the wanted new octet
    replace_And_Go($userdata1, $userdata2) ; generate a list of new IP and Go

EndFunc   ;==>GOButtonClick
Func infobuttonClick()

EndFunc   ;==>infobuttonClick


Func Pic1Click()

EndFunc   ;==>Pic1Click
Func quickscanClick()
    $userdata1 = GUICtrlRead($data1)
    $userdata2 = GUICtrlRead($data2)
    replace_And_Go2($userdata1, $userdata2)

EndFunc   ;==>quickscanClick




Func SpecialEvents()
    Select
        Case @GUI_CtrlId = $GUI_EVENT_CLOSE
            _button1()

        Case @GUI_CtrlId = $GUI_EVENT_MINIMIZE

        Case @GUI_CtrlId = $GUI_EVENT_RESTORE

        Case @GUI_CtrlId = $GUI_EVENT_MAXIMIZE

    EndSelect
EndFunc   ;==>SpecialEvents

#Region ; Main_GO/Replace_and_GO


#cs
    ##############################  second script  #############################################

    ; this is to ping continuously a list of IP addresses, get and display ping result "live"
    ; it simulates the dos "ping -t" command but performed simultaneously on many IP
    ; presenting the results in a ListView highlighting not responding devices with a red box
#ce


Func replace_And_Go($s_2, $s_3)

    ; Create a new array wit a new list of IP according to passed second and third octet
    Local $aNew_IPlist = $aBase_IPlist
    For $i = 0 To UBound($aNew_IPlist) - 1
        $aNew_IPlist[$i][1] = StringReplace(StringReplace($aBase_IPlist[$i][1], $replace2, $s_2), $replace3, $s_3)
    Next

    GUISetState(@SW_HIDE, $IPMonkey)
    GUISetState(@SW_SHOW, $PingGui)

    ; pass the new list to the pinger
    Main_GO($aNew_IPlist)

    GUISetState(@SW_HIDE, $PingGui)
    GUISetState(@SW_SHOW, $IPMonkey)

EndFunc   ;==>replace_And_Go



Func Main_GO($IPlist)
    HotKeySet("{esc}", "exitbuttonClick")
    $StopPing = 0
    ; $IPlist = _FileReadToArray_mod(".\IP_List.txt") ; Reads text file for list of IP's
    ;
    ; the above command, it loads in the $IPlist array the values contained in the file IP_List.txt
    ; values in the file should be separated by a semicolon, something like in the following example:
    ;
    ; hostname1;192.168.0.1
    ; hostname2;192.168.0.5
    ; hostnameX;10.59.7.200
    ; etc....
    ;
    ;  if values in the file are not separated by a semicolon, but another char is used, for example a comma,
    ;  then just pass it as second parameter of the function: $IPlist = _FileReadToArray_mod(".\IP_List.txt", ",")
    ;
    _GUICtrlListView_BeginUpdate($listview)
    _GUICtrlListView_DeleteAllItems($listview)
    _GUICtrlListView_AddArray($listview, $IPlist) ; fill ListView
    _GUICtrlListView_EndUpdate($listview)

    While Not $StopPing ; 1 ; continuously ping addresses of the previously loaded file (IP_List.txt)
        Sleep(10)
        ;
        ;        $IPlist is the array loaded with all the IP to be pinged (a 2d array in this case)
        ;        |
        ;        |      1 means the IP are in the second column of the $IPlist array (first colun is nr. 0)
        ;        |      |
        ;        |      |  +-->  0 means return back an array loaded with results from all pinged addresses (responding and not responding)
        ;        |      |  |     if you use 1 then only responding addresses are loaded in the returned array [default]
        ;        |      |  |     if you use 2 then only NOT responding addresses are loaded in the returned array
        ;        |      |  |     In this case we do not need an  array to be returned, we only need to perform all pings and pass results
        ;        |      |  |     directly (on the fly) to the "_refresh" callback function that will refresh the listview
        ;        |      |  |
        ;        |      |  |  0 means NO lookup name resolution must be performed
        ;        |      |  |  |
        ;        |      |  |  |   +--> this is the callback function to be called for each pinged address each time the ping has finished
        ;        |      |  |  |   |    (see the MultiPing.au3 file for info on all passed params)
        ;        |      |  |  |   |    6 parameters are passed to this function, but only 2 are used by the called function in this case:
        ;        |      |  |  |   |    [4] roundtrip of the responding ping or -1 if IP is down
        ;        |      |  |  |   |    [5] Index (position) of this IP within the caller's passed array
        ;        |      |  |  |   |
        ;        v      v  v  v   v
        _nPing($IPlist, 1, 0, 0, "_refresh")
    WEnd


EndFunc   ;==>Main_GO


#EndRegion ; Main_GO/Replace_and_GO




#Region ; QuickScan/Replace_and_GO2

Func replace_And_Go2($s_2, $s_3)

    ; Create a new array wit a new list of IP according to passed second and third octet
    Local $aNew_IPlist = $aBase_IPlist
    For $i = 0 To UBound($aNew_IPlist) - 1
        $aNew_IPlist[$i][1] = StringReplace(StringReplace($aBase_IPlist[$i][1], $replace2, $s_2), $replace3, $s_3)
    Next

    GUISetState(@SW_HIDE, $IPMonkey)
    GUISetState(@SW_SHOW, $PingGui)

    ; pass the new list to the pinger
    QuickRun($aNew_IPlist)

    GUISetState(@SW_HIDE, $PingGui)
    GUISetState(@SW_SHOW, $IPMonkey)

EndFunc   ;==>replace_And_Go2

Func QuickRun($IPlist)

    $userdata1 = GUICtrlRead($data1)
    $userdata2 = GUICtrlRead($data2)

    HotKeySet("{esc}", "_button1")

    Local $Win_X = 1200, $Win_Y = 880 ; dimension of window
    $PingGui = GUICreate("IP Monkey" & "~~~" & @UserName & "~~~" & "Store" & $userdata1 & $userdata2 & "~~~" & @MON & "." & @MDAY & "." & @YEAR & "~~~" & @HOUR & "." & @MIN, $Win_X, $Win_Y, -1, -1)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_button1", $PingGui)
    $listview = GUICtrlCreateListView("", 10, 10, $Win_X - 20, $Win_Y - 40)
    GUICtrlSetFont(-1, 8)
    GUICtrlSetStyle($listview, $LVS_ICON) ; + $LVS_NOLABELWRAP)

    ; Generate colored square images
    $hImage = _GUIImageList_Create(30, 30)
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($listview, 0xFFFF00, 30, 30)) ; yellow
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($listview, 0xFF0000, 30, 30)) ; red
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($listview, 0x00FF00, 30, 30)) ; green

    _GUICtrlListView_SetImageList($listview, $hImage, 0)

    $button1 = GUICtrlCreateButton("Exit", 10, $Win_Y - 25, $Win_X - 20, 20)
    GUICtrlSetTip(-1, "End of program")
    GUICtrlSetOnEvent(-1, "exitbuttonClick")
    GUISetState(@SW_SHOW)

;~  $IPlist = _FileReadToArray_mod(".\IP_List.txt") ; Reads text file for list of IP's

    _GUICtrlListView_BeginUpdate($listview)
    _GUICtrlListView_AddArray($listview, $IPlist) ; fill ListView
    _GUICtrlListView_EndUpdate($listview)

    ;While 1
    ; perform Pings and update ListView by the "_refresh" callback function
    $aFinalResult = _nPing($IPlist, 1, 0, 0, "_refresh")
;~  _ArrayDisplay($aFinalResult)

    ;DirCheck()

EndFunc   ;==>QuickRun

#EndRegion ; QuickScan/Replace_and_GO2

#Region ; Misc Funcs (network)

Func _refresh($Params) ; this receive ping results and displays them in the ListView
    _GUICtrlListView_SetItemImage($listview, $Params[5], 0) ; set colour to Yellow
    Sleep(50) ; a little wait
    If $Params[4] = -1 Then ; Device not responding to ping
        _GUICtrlListView_SetItemImage($listview, $Params[5], 1) ; set colour to RED
        _GUICtrlListView_EnsureVisible($listview, $Params[5]) ; Position view to this item
    Else ; Device responds to ping
        _GUICtrlListView_SetItemImage($listview, $Params[5], 2) ; set colour to GREEN
    EndIf
EndFunc   ;==>_refresh




Func _button1() ; Button 1 clicked
;~  $StopPing = 1
    Exit
EndFunc   ;==>_button1

#EndRegion ; Misc Funcs (network)

 

MultiPing.au3

IP_List.txt

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  

  • Similar Content

    • WoodGrain
      By WoodGrain
      Hi guys,
      I'm learning about GUI's, I'm trying the below code, the idea being if I press the letter "e" while I have the GUI open I want the label color to change to green (I'm using a UDF for label colors). But every time I press "e" on my keyboard I just get a "ding" sound from my speakers and nothing changes with the label.
      I've looked at using something like "While GUIGetMsg() <> $GUI_EVENT_CLOSE" as I've seen it in other code instead of "While 1", but I don't think it's relevant.
      #include <GUIConstantsEx.au3>; for GUI... #include <GUIRichLabel.au3>; UDF for rich text label fonts #include <Misc.au3>; for _IsPressed $myLetter = "e" $hGUI = GUICreate("test", 700, 60) $lbl2 = _GUICtrlRichLabel_Create($hGUI, '<font color="purple">' & $myLetter & '</font>', 10, 10); , 260, 25 GUISetState(@SW_SHOW) Local $hDLL = DllOpen("user32.dll") While 1 if _IsPressed(Hex($myLetter), $hDLL) Then While _IsPressed(Hex($myLetter), $hDLL) Sleep(250) WEnd _GUICtrlRichLabel_SetData($lbl2, '<font color="green">' & $myLetter & '</font>') Sleep(2000) DllClose($hDLL) Exit EndIf Sleep(50) WEnd DllClose($hDLL) I am using an array of letters that I'm wanting to do this for, but as I can't get it to work I've stripped it down to the simplest code I can think of to try and get this working first. Appreciate any help.
      Thanks!
    • nacerbaaziz
      By nacerbaaziz
      hi dears, i have an question please if you can help me.
      i maked an program to do some functions
      and this program works with the global hot keys
      i added an option to the users to change the hot keys
      when i searched about how to do that i found this UDF
      GUIHotkey.au3
      http://www.autoitscript.com/forum/index.php?showtopic=107965
      but the problem here that this UDF cant be detect the win key.
      can you help me to add it, or if there are any others UDFSS wich do that work please give me some.
      i hope that my question is clear for you.
      thanks in advance
    • Silas
      By Silas
      Hello everyone,
      I have a radio button ($Radio1), which I want to disable as soon as another one get's checked (Radio5). (The system fails if the radio button i'm troubling with also gets checked).
      I know how to disable him:
      If GUICtrlRead($Radio1)=1 And Not BitAND(GUICtrlGetState($Radio5), $GUI_DISABLE) Then GUICtrlSetState($Radio5, 128) But if i try to enable $Radio5 again, after $Radio1 isn't checked anymore, it fails:
      If GUICtrlRead($Radio1)=Not 1 And Not BitAND(GUICtrlGetState($Radio5), $GUI_ENABLE) Then GUICtrlSetState($Radio5, 64)  
      Anyone knows why?
    • Broihon
      By Broihon
      Hey guys,

      I ran into a problem when I wanted to delete items of a listview using the delete key. My approach is to register my own WndProc for the listview and then filter the $WM_GETDLGCODE msg and then call the original WndProc.
      That works like a charm. The problem is that when the listview gets redrawn it somehow ends up in an infinite loop. The listview is suddenly emtpy and I can't interact with any controls of the GUI at all. Here's the code:
       
      #include <GUIConstantsEx.au3> #include <GUIListView.au3> #include <WinAPI.au3> $h_GUI = GUICreate("Test", 200, 200, 350, 350) $h_LV = GUICtrlCreateListView("Col 1|Col 2|Col 3", 0, 0, 200, 200) _GUICtrlListView_AddItem($h_LV, "") _GUICtrlListView_AddSubItem($h_LV, 0, "bla0", 0) _GUICtrlListView_AddSubItem($h_LV, 0, "bla0", 1) _GUICtrlListView_AddSubItem($h_LV, 0, "bla0", 2) _GUICtrlListView_AddItem($h_LV, "") _GUICtrlListView_AddSubItem($h_LV, 1, "bla1", 0) _GUICtrlListView_AddSubItem($h_LV, 1, "bla1", 1) _GUICtrlListView_AddSubItem($h_LV, 1, "bla1", 2) _GUICtrlListView_AddItem($h_LV, "") _GUICtrlListView_AddSubItem($h_LV, 2, "bla2", 0) _GUICtrlListView_AddSubItem($h_LV, 2, "bla2", 1) _GUICtrlListView_AddSubItem($h_LV, 2, "bla2", 2) _GUICtrlListView_AddItem($h_LV, "") _GUICtrlListView_AddSubItem($h_LV, 3, "bla3", 0) _GUICtrlListView_AddSubItem($h_LV, 3, "bla3", 1) _GUICtrlListView_AddSubItem($h_LV, 3, "bla3", 2) $h_LV_NewWndProc = DllCallbackRegister("WndProc_LV", "int", "hwnd;uint;wparam;lparam") $g_LV_OldWndProc = _WinAPI_SetWindowLong(GUICtrlGetHandle($h_LV), $GWL_WNDPROC, DllCallbackGetPtr($h_LV_NewWndProc)) GUISetState(@SW_SHOW) Func WndProc_LV($hWnd, $uMsg, $wParam, $lParam) Return _WinAPI_CallWindowProc($g_LV_OldWndProc, $hWnd, $uMsg, $wParam, $lParam) EndFunc ;==>WndProc_GUI Do Until GUIGetMsg() = $GUI_EVENT_CLOSE DllCallbackFree($h_LV_NewWndProc) As you can see I'm doing nothing in the WndProc of the listview. I'm simply calling the original WndProc. This still "freezes" when I mess with the width of the columns or in the original project when I add more items that they don't fit in the listview and I have to scroll. If I don't do that it's working fine.
    • Bllee
      By Bllee
      every time i press "delete button" delete a line, but i can't add new line with info. the id line write normally but i can't change or add new info
      obs: looking at the "includes" one realizes that already tried of everything that knew
      my code
      #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <GuiImageList.au3> #include <GuiListView.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <MsgBoxConstants.au3> #include <WinAPI.au3> #include <StringConstants.au3> #include <Array.au3> #include <GuiListBox.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 612, 480, 192, 154) $MenuItem1 = GUICtrlCreateMenu("&Arquivo") $MenuItem2 = GUICtrlCreateMenuItem("Salvar Ctrl+S", $MenuItem1, $SS_CENTER) $MenuItem4 = GUICtrlCreateMenuItem("Carregar Ctrl+O", $MenuItem1, $SS_CENTER) $MenuItem3 = GUICtrlCreateMenuItem("Salvar Como Shitft+Ctrl+S", $MenuItem1, $SS_CENTER) $Group1 = GUICtrlCreateGroup("", 21, 8, 569, 97, $SS_CENTER) $Input1 = GUICtrlCreateInput("ID COR", 122, 32, 97, 21, $SS_CENTER) $Input2 = GUICtrlCreateInput("REGIÃO", 138, 64, 249, 21, $SS_CENTER) $Input3 = GUICtrlCreateInput("Label", 264, 30, 121, 21, $SS_CENTER) $Label1 = GUICtrlCreateLabel("Label", 232, 32, 30, 17, $SS_CENTER) $Button1 = GUICtrlCreateButton("Capturar Cor", 42, 30, 75, 25, $SS_CENTER) $Button2 = GUICtrlCreateButton("Capturar Região", 42, 62, 91, 25, $SS_CENTER) $Button3 = GUICtrlCreateButton("ADD", 442, 24, 113, 33) $Button5 = GUICtrlCreateButton("Delet", 442, 64, 113, 33) $Group2 = GUICtrlCreateGroup("Editar ID selecionado", 8, 384, 601, 57, $SS_CENTER) $Input7 = GUICtrlCreateInput("ID", 10, 402, 40,21, $SS_CENTER) $Input4 = GUICtrlCreateInput("COR", 51, 402, 121, 21, $SS_CENTER) $Input5 = GUICtrlCreateInput("REGIÃO", 173, 402, 249, 21, $SS_CENTER) $Input6 = GUICtrlCreateInput("LABEL", 423, 402, 121, 21, $SS_CENTER) $Button4 = GUICtrlCreateButton("\/", 544, 400, 30, 25, $SS_CENTER) $Button6 = GUICtrlCreateButton("/\", 574, 400, 30, 25, $SS_CENTER) ; Add column Global $id = Int(0) $List1 = GUICtrlCreateListView("",5, 120, 601, 253, $SS_CENTER) _GUICtrlListView_AddColumn($List1, "ID",40) _GUICtrlListView_AddColumn($List1, "COR",100) _GUICtrlListView_AddColumn($List1, "COORDENADA",305) _GUICtrlListView_AddColumn($List1, "LABEL",150) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $MenuItem2 MsgBox($MB_SYSTEMMODAL, "ctrl + s", "Nothing Here",1) Case $MenuItem3 MsgBox($MB_SYSTEMMODAL, "shift+ctrl s", "Nothing Here",1) Case $MenuItem4 MsgBox($MB_SYSTEMMODAL, "ctrl + o", "Nothing Here",1) Case $Button1 MsgBox($MB_SYSTEMMODAL, "Capturar cor", "Aperte espaço para capturar a cor") GUICtrlSetData($Input1,MouseColor()) Case $Button2 MsgBox($MB_SYSTEMMODAL, "capturar região", "Aperte espaço para capturar a posição inicial") local $mouse = MouseGetPos() $x_init = $mouse[0] $y_init = $mouse[1] MsgBox($MB_SYSTEMMODAL, "capturar região", "Aperte espaço para capturar a posição final") local $mouse = MouseGetPos() $x_end = $mouse[0] $y_end = $mouse[1] GUICtrlSetData($Input2,$x_init&','&$y_init&' ; '&$x_end&','&$y_end) Case $Button3 _GUICtrlListView_AddItem($List1, $id, 1) ; id _GUICtrlListView_AddSubItem($List1, $id, GUICtrlRead($Input1), 1, 1) ;cor _GUICtrlListView_AddSubItem($List1, $id, GUICtrlRead($Input2), 2, 1) ;coordenada _GUICtrlListView_AddSubItem($List1, $id, GUICtrlRead($Input3), 3, 1) ;label $id= $id + 1 Case $Button4 $Item = _GUICtrlListView_GetSelectedIndices($List1) $Sid = _GUICtrlListView_GetItem($List1, Number($Item),0) $Scor = _GUICtrlListView_GetItem($List1, Number($Item),1) $Scord = _GUICtrlListView_GetItem($List1, Number($Item),2) $Slabel = _GUICtrlListView_GetItem($List1, Number($Item),3) ; get info GUICtrlSetData($Input7,$Sid[3]) GUICtrlSetData($Input4,$Scor[3]) GUICtrlSetData($Input5,$Scord[3]) GUICtrlSetData($Input6,$Slabel[3]) Case $Button5 _GUICtrlListView_DeleteItemsSelected($List1) Case $Button6 ; give back inf if GUICtrlRead($Input7) <> "ID" Then _GUICtrlListView_SetItem($List1, GUICtrlRead($Input4), GUICtrlRead($Input7),1) ;cor _GUICtrlListView_SetItem($List1, GUICtrlRead($Input5), GUICtrlRead($Input7),2) ;coordenada _GUICtrlListView_SetItem($List1, GUICtrlRead($Input6), GUICtrlRead($Input7),3) ;coordenada EndIf EndSwitch WEnd Func MouseColor() local $mouse = MouseGetPos() Return Hex(PixelGetColor($mouse[0],$mouse[1]), 6) EndFunc  
×