faustf Posted March 29, 2016 Share Posted March 29, 2016 (edited) hi guy i create a script with toolbar , and i tryed to intercept a pushed button , but not work some one can help me?? thankz Quote expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiToolbar.au3> #include <WindowsConstants.au3> #include <GuiImageList.au3> #include <WinAPIShellEx.au3> Global $ToolBar1, $g_idMemo Global $g_iItem ; Command identifier of the button associated with the notification. Global Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $e_idHelp Global $ToolBar1, $g_idMemo Global $g_iItem ; Command identifier of the button associated with the notification. ;Global Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $e_idHelp Global $MAG_Group1 _magazzino() Func _magazzino() $hMainGUI = GUICreate("GesT", 1692, 808, 192, 114, BitOR($GUI_SS_DEFAULT_GUI, $WS_SYSMENU, $WS_SIZEBOX, $WS_THICKFRAME)) ; Local $hGUI, $ToolBar1, $bStyle ;Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $idHelp ; _Boom() ; cancella tutto quello che trova su la gui $MAG_Group1 = GUICtrlCreateGroup("de made", 0, 12, 1692, 757); Configurazione Azienda e Documenti $Group2 = GUICtrlCreateGroup("Inserimento Prodotti o Servizi", 6, 36, 705, 177) $Input1 = GUICtrlCreateInput("", 13, 84, 145, 21) $Label1 = GUICtrlCreateLabel("Codice Prodotto", 15, 66, 80, 17) $Label2 = GUICtrlCreateLabel("Q.tita", 168, 67, 29, 17) $Input2 = GUICtrlCreateInput("", 237, 84, 121, 21) $Label3 = GUICtrlCreateLabel("N.° Fattura Acquisto", 237, 68, 99, 17) $Input3 = GUICtrlCreateInput("", 366, 84, 337, 21) $Label4 = GUICtrlCreateLabel("Nome Prodotto e Servizio", 366, 68, 124, 17) $Input4 = GUICtrlCreateInput("", 14, 132, 121, 21) $Label5 = GUICtrlCreateLabel("Nome distributore", 14, 116, 86, 17) $Input5 = GUICtrlCreateInput("", 142, 132, 73, 21) $Label6 = GUICtrlCreateLabel("Spesa Incasso", 142, 116, 74, 17) $Input6 = GUICtrlCreateInput("", 222, 132, 73, 21) $Input7 = GUICtrlCreateInput("", 302, 132, 73, 21) $Input8 = GUICtrlCreateInput("", 383, 132, 73, 21) $Input9 = GUICtrlCreateInput("", 14, 180, 97, 21) $Label7 = GUICtrlCreateLabel("Prezzo a me unitario", 14, 164, 99, 17) $Input10 = GUICtrlCreateInput("", 118, 180, 65, 21) $Label8 = GUICtrlCreateLabel("% Ricarico", 122, 164, 54, 17) $Input11 = GUICtrlCreateInput("", 190, 180, 97, 21) $Label9 = GUICtrlCreateLabel("Prezzo + Iva", 194, 164, 63, 17) $Input12 = GUICtrlCreateInput("", 295, 180, 121, 21) $Label10 = GUICtrlCreateLabel("Codice a Barre", 297, 164, 74, 17) $Input13 = GUICtrlCreateInput("", 165, 84, 65, 21) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group3 = GUICtrlCreateGroup("Importazione Ocr", 715, 36, 972, 289) $Label11 = GUICtrlCreateLabel("", 720, 64, 852, 28) ; label per toolbar $Edit1 = GUICtrlCreateEdit("", 720, 96, 857, 225) GUICtrlSetData(-1, "Edit1") $Button1 = GUICtrlCreateButton("Scansione", 1600, 264, 75, 21) $Button2 = GUICtrlCreateButton("Importa ", 1601, 293, 75, 21) GUICtrlCreateGroup("", -99, -99, 1, 1) $List1 = GUICtrlCreateList("", 4, 327, 1683, 435) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY") $ToolBar1 = _GUICtrlToolbar_Create(GUICtrlGetHandle($Label11), 0) _GUICtrlToolbar_SetStyle($ToolBar1, BitOR($TBSTYLE_FLAT, $CCS_TOP)) ;_GUICtrlToolbar_AddBitmap ($ToolBar1, 1, -1, $IDB_STD_SMALL_COLOR) ; _GUICtrlToolbar_LoadBitmap($ToolBar1, "E:\_GESTIONALE_NEW\icon\Eraser-icon2.bmp") ;_GUICtrlToolbar_AddButton($ToolBar1, $e_idOpen, 0) ;_GUICtrlToolbar_AddButton($ToolBar1, $e_idSave, $STD_FILEOPEN,"de ma de") ;_GUICtrlToolbar_AddButton($ToolBar1, $idHelp, $STD_FILEOPEN) ;$bStyle = _GUICtrlToolbar_GetStyleFlat($ToolBar1) $hImageList = _GUIImageList_Create(24, 24, 5, 1, 5) Dim $Icon[5] = [303, 85, 298, 300, 304] For $i = 0 To 4 $hIcon = _WinAPI_ShellExtractIcon(@ScriptDir & '\include\shell32.dll', $Icon[$i], 48, 48) _GUIImageList_ReplaceIcon($hImageList, -1, $hIcon) _WinAPI_DestroyIcon($hIcon) Next _GUICtrlToolbar_SetImageList($ToolBar1, $hImageList) ;_GUICtrlToolbar_AddString($ToolBar1, 'Button 1') ;_GUICtrlToolbar_AddString($ToolBar1, 'Button 2') ;_GUICtrlToolbar_AddString($ToolBar1, 'Button 3') ;_GUICtrlToolbar_AddString($ToolBar1, 'Button 4') ;_GUICtrlToolbar_AddString($ToolBar1, 'Button 5') _GUICtrlToolbar_AddButton($ToolBar1, 10000, 0, 0) _GUICtrlToolbar_AddButton($ToolBar1, 10001, 1, 1) _GUICtrlToolbar_AddButtonSep($ToolBar1, 5) ;_GUICtrlToolbar_AddButton($ToolBar1, 10002, 2, 2) ;_GUICtrlToolbar_AddButton($ToolBar1, 10003, 3, 3) ;_GUICtrlToolbar_AddButton($ToolBar1, 10004, 4, 4) ; _GUICtrlToolbar_SetButtonSize($ToolBar1, 24, 24) ; _GUICtrlToolbar_SetMetrics($ToolBar1, 0, 0, 1, 0) ; _GUICtrlToolbar_SetIndent($ToolBar1, 1) ; _SendMessage($ToolBar1, $TB_AUTOSIZE) ;GUICtrlSetOnEvent($MagazinoItem, "_magazzino") ; magazzino prodotti reali Do Until GUIGetMsg() = $GUI_EVENT_CLOSE EndFunc ;==>_magazzino Func _WM_NOTIFY($hWndGUI, $iMsgID, $wParam, $lParam) #forceref $hWndGUI, $iMsgID, $wParam Local $tNMHDR, $hWndFrom, $iCode, $iNew, $iFlags, $iOld Local $tNMTBHOTITEM $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = DllStructGetData($tNMHDR, "hWndFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $ToolBar1 Switch $iCode Case $NM_LDOWN ;---------------------------------------------------------------------------------------------- If _GUICtrlToolbar_CommandToIndex($ToolBar1, $g_iItem) = 0 Then MsgBox(0, '', 'demade ') EndIf ;---------------------------------------------------------------------------------------------- Case $TBN_HOTITEMCHANGE $tNMTBHOTITEM = DllStructCreate($tagNMTBHOTITEM, $lParam) $iOld = DllStructGetData($tNMTBHOTITEM, "idOld") $iNew = DllStructGetData($tNMTBHOTITEM, "idNew") $g_iItem = $iNew $iFlags = DllStructGetData($tNMTBHOTITEM, "dwFlags") EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>_WM_NOTIFY Edited March 29, 2016 by faustf Link to comment Share on other sites More sharing options...
AutoBert Posted March 29, 2016 Share Posted March 29, 2016 Same procedure as last time: your script isn't runable please make a runable reproducer including issues why should anybody invest more time as you did with your op? Link to comment Share on other sites More sharing options...
faustf Posted March 29, 2016 Author Share Posted March 29, 2016 sorry , the buttton is without icon over the word Edit1 Link to comment Share on other sites More sharing options...
BrewManNH Posted March 29, 2016 Share Posted March 29, 2016 Can you please explain what it is that isn't working in your script? If you're trying to read the pushed toolbar button, you don't have any code in it that is supposed to do that, so that might be why it doesn't work. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
faustf Posted March 29, 2016 Author Share Posted March 29, 2016 i dont understand how can intercept it , and i tryed to do sample but not go , some can explain me how can intercept it ?? , with example is perfect thankz at all Link to comment Share on other sites More sharing options...
BrewManNH Posted March 29, 2016 Share Posted March 29, 2016 (edited) The script you're using is using the label as the basis for the toolbar to connect to. The WM_Notify is looking at the GUI not at the label so no events are fired when you're over the label. In fact, when you create the toolbar using the label as the parent, the WM_NOTIFY doesn't ever fire, at all. Not sure why it doesn't, but that's why you can't see the button pushes. Edited March 29, 2016 by BrewManNH stupid assumption fixed. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
faustf Posted March 29, 2016 Author Share Posted March 29, 2016 i theory $iID Command ID but i dont know how must use Link to comment Share on other sites More sharing options...
faustf Posted March 29, 2016 Author Share Posted March 29, 2016 but why in this mode work and in before script no ?? expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiToolbar.au3> #include <WindowsConstants.au3> #include <GuiImageList.au3> #include <WinAPIShellEx.au3> Global $ToolBar1, $g_idMemo Global $g_iItem ; Command identifier of the button associated with the notification. Global Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $e_idHelp Example() Func Example() Local $hGUI, $aSize;, $aStrings[4] ; Create GUI $hMainGUI = GUICreate("GesT", 1692, 808, 192, 114, BitOR($GUI_SS_DEFAULT_GUI, $WS_SYSMENU, $WS_SIZEBOX, $WS_THICKFRAME)) $ToolBar1 = _GUICtrlToolbar_Create($hMainGUI) $aSize = _GUICtrlToolbar_GetMaxSize($ToolBar1) $g_idMemo = GUICtrlCreateEdit("", 2, $aSize[1] + 30, 596, 396 - ($aSize[1] + 30), $WS_VSCROLL) GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New") GUISetState(@SW_SHOW) GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY") $hImageList = _GUIImageList_Create(24, 24, 5, 1, 5) Dim $Icon[5] = [303, 85, 298, 300, 304] For $i = 0 To 4 $hIcon = _WinAPI_ShellExtractIcon(@ScriptDir & '\include\shell32.dll', $Icon[$i], 48, 48) _GUIImageList_ReplaceIcon($hImageList, -1, $hIcon) _WinAPI_DestroyIcon($hIcon) Next _GUICtrlToolbar_SetImageList($ToolBar1, $hImageList) _GUICtrlToolbar_AddButton($ToolBar1, 10000, 0, 0) _GUICtrlToolbar_AddButton($ToolBar1, 10001, 1, 1) _GUICtrlToolbar_AddButtonSep($ToolBar1, 5) ; Loop until the user exits. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE EndFunc ;==>Example ; WM_NOTIFY event handler Func _WM_NOTIFY($hWndGUI, $iMsgID, $wParam, $lParam) #forceref $hWndGUI, $iMsgID, $wParam Local $tNMHDR, $hWndFrom, $iCode, $iNew, $iFlags, $iOld Local $tNMTBHOTITEM $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = DllStructGetData($tNMHDR, "hWndFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $ToolBar1 Switch $iCode Case $NM_LDOWN ;---------------------------------------------------------------------------------------------- ;MemoWrite("$NM_LDOWN: Clicked Item: " & $g_iItem & " at index: " & _GUICtrlToolbar_CommandToIndex($ToolBar1, $g_iItem)) ;---------------------------------------------------------------------------------------------- If _GUICtrlToolbar_CommandToIndex($ToolBar1, $g_iItem)= 1 Then MsgBox (0,'','pigiato aperto') EndIf Case $TBN_HOTITEMCHANGE $tNMTBHOTITEM = DllStructCreate($tagNMTBHOTITEM, $lParam) $iOld = DllStructGetData($tNMTBHOTITEM, "idOld") $iNew = DllStructGetData($tNMTBHOTITEM, "idNew") $g_iItem = $iNew $iFlags = DllStructGetData($tNMTBHOTITEM, "dwFlags") EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>_WM_NOTIFY Link to comment Share on other sites More sharing options...
faustf Posted March 29, 2016 Author Share Posted March 29, 2016 (edited) in first script if i change this ;$ToolBar1 = _GUICtrlToolbar_Create(GUICtrlGetHandle($Label11), 0) in this $ToolBar1 = _GUICtrlToolbar_Create($hMainGUI) it work , someone know how work?? can explain me ?? thnakz Edited March 29, 2016 by faustf Link to comment Share on other sites More sharing options...
LarsJ Posted March 30, 2016 Share Posted March 30, 2016 The help file for _GUICtrlToolbar_Create states that the $hWnd parameter must be the handle to parent or owner window. This means a window created with GUICreate and not a control created with one of the GUICtrlCreate-commands. A window and a control are two different things. A window handle and a control handle are two different things even though they are both handles. Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now