Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/07/2022 in all areas

  1. pixelsearch

    CSV file editor

    Hi everybody The script below (901f) allows to wander easily through a listview, selecting any item or subitem by using the 4 direction keys. The Enter key is also managed and allows to fire an event (as double-click does) With the help of mikell (many thanks !) and after several tests based on 1000 rows & 6 columns, we succeeded to code a clear WM_NOTIFY function, which is simple (though solid) and should be reusable without any modification in other scripts dealing with basic listviews (we didn't use or check any particular style for the listview) Trapping the Enter key has been done by using a dummy control + Accelerators, though we spent the whole last week trapping it in another way, using Yashied's Wsp.dll (without any problem) . Finally we choosed the dummy control option... to have a smaller code. Version 901f (Nov 11, 2019) : the pic below shows how the selected subitem appears, with its specific background colour (light blue) Version 901f code : #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <WindowsConstants.au3> #include <WinAPIvkeysConstants.au3> Global $hGUI = GUICreate("Wandering through ListView (901f)", 460, 500) Global $idListView = GUICtrlCreateListView _ (" Col 0 | Col 1| Col 2| Col 3", 15, 60, 430, 400) Global $hListView = GuiCtrlGetHandle($idListView) For $iRow = 0 To 99 $sRow = StringFormat("%2s", $iRow) GUICtrlCreateListViewItem( _ "Row " & $sRow & " / Col 0 |" & _ "Row " & $sRow & " / Col 1 |" & _ "Row " & $sRow & " / Col 2 |" & _ "Row " & $sRow & " / Col 3", $idListView) Next Global $g_iColumnCount = _GUICtrlListView_GetColumnCount($idListView) -1 Global $g_iItem = -1, $g_iSubItem = -1 ; item/subitem selected in ListView control Global $idDummy_Dbl_Click = GUICtrlCreateDummy() Global $idDummy_Enter = GUICtrlCreateDummy() Global $aAccelKeys[1][2] = [["{ENTER}", $idDummy_Enter]] GUISetAccelerators($aAccelKeys) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE GUIDelete($hGUI) Exit Case $idDummy_Dbl_Click MsgBox($MB_TOPMOST, "Double-click activated cell", _ "Row " & $g_iItem & " / Col " & $g_iSubItem) Case $idDummy_Enter If _WinAPI_GetFocus() = $hListView And $g_iItem > -1 Then MsgBox($MB_TOPMOST, "Enter activated cell", _ "Row " & $g_iItem & " / Col " & $g_iSubItem) EndIf EndSwitch WEnd ;============================================ Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $tNMHDR, $hWndFrom, $iIDFrom, $iCode $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = DllStructGetData($tNMHDR, "hWndFrom") $iCode = DllStructGetData($tNMHDR, "Code") Static $bMouseDown = False, $bNotXP = Not (@OSVersion = "WIN_XP") Switch $hWndFrom Case $hListView Switch $iCode Case $NM_CUSTOMDRAW Local $tCustDraw = DllStructCreate($tagNMLVCUSTOMDRAW, $lParam) Local $iDrawStage = DllStructGetData($tCustDraw, "dwDrawStage") If $iDrawStage = $CDDS_PREPAINT Then Return $CDRF_NOTIFYITEMDRAW If $iDrawStage = $CDDS_ITEMPREPAINT Then Return $CDRF_NOTIFYSUBITEMDRAW Local $iItem = DllStructGetData($tCustDraw, "dwItemSpec") Local $iSubItem = DllStructGetData($tCustDraw, "iSubItem") Local $iColor = 0xFF000000 ; this is $CLR_DEFAULT in ColorConstants.au3 If $iItem = $g_iItem And $iSubItem = $g_iSubItem Then $iColor = 0xFFFFC0 ; light blue for 1 subitem (BGR) EndIf DllStructSetData($tCustDraw, "clrTextBk", $iColor) Return $CDRF_NEWFONT Case $LVN_KEYDOWN If $bMouseDown Or $g_iItem = -1 Then Return 1 ; don't process Local $tInfo = DllStructCreate($tagNMLVKEYDOWN, $lParam) Local $iVK = DllStructGetData($tInfo, "VKey") Switch $iVK Case $VK_RIGHT If $g_iSubItem < $g_iColumnCount Then $g_iSubItem += 1 If $bNotXP Then _GUICtrlListView_RedrawItems($hListview, $g_iItem, $g_iItem) EndIf Case $VK_LEFT If $g_iSubItem > 0 Then $g_iSubItem -= 1 If $bNotXP Then _GUICtrlListView_RedrawItems($hListview, $g_iItem, $g_iItem) EndIf Case $VK_SPACE ; spacebar would select the whole row Return 1 EndSwitch Case $NM_RELEASEDCAPTURE $bMouseDown = True Local $iItemSave = $g_iItem Local $aHit = _GUICtrlListView_SubItemHitTest($hListView) $g_iItem = $aHit[0] $g_iSubItem = $aHit[1] If $g_iItem = -1 And $iItemSave > -1 Then _GUICtrlListView_RedrawItems($hListview, $iItemSave, $iItemSave) EndIf Case $LVN_ITEMCHANGED Local $tInfo = DllStructCreate($tagNMLISTVIEW, $lParam) Local $iNewState = DllStructGetData($tInfo, "NewState") Switch $iNewState Case BitOr($LVIS_FOCUSED, $LVIS_SELECTED) $g_iItem = DllStructGetData($tInfo, "Item") _GUICtrlListView_SetItemSelected($hListview, $g_iItem, False) EndSwitch Case $NM_CLICK, $NM_RCLICK $bMouseDown = False Case $NM_DBLCLK $bMouseDown = False If $g_iItem > -1 Then GUICtrlSendToDummy($idDummy_Dbl_Click) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Version 901k (Dec 16, 2019) What started with a simple "wander through listview" has turned now to a functional CSV file editor, which can be useful to modify your CSV files with AutoIt : Here are the instructions to use the script, based on a CSV file starting like this : street,city,zip,state,beds,baths,sq__ft,type,sale_date,price,latitude,longitude 3526 HIGH ST,SACRAMENTO,95838,CA,2,1,836,Residential,Wed May 21 00:00:00 EDT 2008,59222,38.631913,-121.434879 51 OMAHA CT,SACRAMENTO,95823,CA,3,1,1167,Residential,Wed May 21 00:00:00 EDT 2008,68212,38.478902,-121.431028 ... 1) Import options : comma delimited (default) No need to change anything if your CSV is comma delimited (other options are Semicolon delimited, Tab delimited) 2) Import options : First row = headers (default = checked) * Keep it checked if the 1st row of your imported file contains headers (that's the case in our example) * UNcheck it if the 1st row contains data, making listview headers appear like this : Col 0 | Col 1 | Col 2 ... 3) Import your CSV file : Only now the listview will be created dynamically. As soon as it is populated, GUI becomes resizable/maximizable, which can be helpful during modifications of a listview containing many columns. 4) Selection color : light blue (default) You can change the selected cell background color by clicking the "Selection color" button : this will open Windows color picker. 5) Editing a listview cell : done by Enter key (or double-click), this is how the edited cell will appear : * Please note that the edited background color (green in the pic) depends on each computer theme. It is not related to the selected background we discussed in 4) * Validate your modification with Enter key, or cancel the modification (revert) with Escape Key 6) Edit Font size : 15 (default) 15 was good in the precedent pic, the edited cell had its content "RIO LINDA" perfectly aligned with all other cells (on my computer). Here again, the font height required depends on each computer : if you want the edited font to be bigger (or smaller), just use the updown control. 7) Chained Edit ? (default = No) * "No" => when you finish editing a cell (Enter key), the same cell stays selected. * "Horizontally" => If checked, edition will automatically continue with the cell on its right. * "Vertically" => If checked, edition will automatically continue with the cell below. This feature can be very useful when you modify cells of a whole colum (vertically) or cells by row (horizontally) 8 ) Inserting a blank line (not in Gui) : press the "Ins" key : 9) Deleting a line (not in Gui) : press the "Del" key : 10) Export CSV file : Filename automatically suggested for export will be : Filename import & actual date & actual time, for example : Import name = "Sales Results.csv" => suggested Export name = "Sales Results_2019-12-16 16:00:59.csv" Version 901m (Dec 18, 2019) Yesterday, mikell suggested to import the csv file by dropping it directly into the GUI, good idea This new version 901m allows it. Now there are 2 ways to import the csv file : * Import button * Drag and drop into the large droppable zone, as shown in the pic below (this zone will be reused to create the listview at same coords) Version 901n (Dec 20, 2019) As t0nZ got tons of csv files, pipe "|" separated, here is a new version allowing this 4th separator Version 901p (Dec 25, 2019) New functionality : now you can drag headers to reorder columns. It may help some users who need it while editing their file. Exported CSV file will be saved according to the new columns order. Version 901r (Dec 29, 2019) New functionality : Numeric sort on any column (right click on column header) It is recommended to backup (export) your file before sorting, just in case you need a copy of it, unsorted. Version 901s (Dec 30, 2019) 1 functionality added : String sort (right click on column header) Numeric sort is alright in most cases, but sometimes we also need a String sort like shown in the following picture. Both ways of sorting (numeric and string) are found in this new release. Version 901t (Jan 3, 2020) 3 functionalities added Rename Header , Insert Column , Delete Column (right click on column header to display its context menu) Version 901u (Jan 6, 2020) 1 functionality added : Natural sort. Thanks to jchd for the idea and Melba23 for his function ArrayMultiColSort() included in the script. Though this natural sort isn't fully implemented, it should work when numbers precede letters (see pic below or better, try it on the "street" column found in the downloadable csv test file below) Natural sort duration + listview update are fast, maybe because of the new function _BufferCreate() described here and now added to the script. Version 901w (Jan 10, 2020) Two functionalities added : 1) Close File button, which allows to import other csv file(s) during the same session 2) Import speed has been improved because the listview control is now populated directly by an Array and not anymore by GUICtrlCreateListViewItem() This explains why, in this version, there are no more Control id's for listview items, allowing to empty the listview content in a snap with this line of code : _SendMessage($g_hListView, $LVM_DELETEALLITEMS) That's what it took to add the Close File button and import several csv files during the same session, avoiding id leaks. Please report if any issue is encountered. Version 901x (Jan 14, 2020) One minor functionality added : number of rows is now displayed just under the listview, it may be handy sometimes. Other minor changes included (natural sort speed improved) Credits : Many thanks to Czardas for his function _CSVSplit() and guinness for his function _SaveCSV(), guys you did a great job. Thanks to Musashi : your suggestions and time passed on testing beta versions of the script, that was really helpful and challenging. Not sure I would have ended this script without your detailed reports. Mikell : the 1st step above (901f) that we wrote together, it all started from here. Your knowledge and kindness are legendary ! Not forgetting all other persons who were inspiring : LarsJ, Melba23, jpm, that list could be endless... Download link : version 901x - Jan 14, 2020 (minor update on Jan 15) 901x - CSV file editor.au3 Test csv file (986 rows/12cols) : Sacramento real estate transactions.csv
    1 point
  2. TheXman

    Websockets and AutoIt

    Awesome! You're welcome. I was doing a little research and saw this Mozilla ticket about Webdriver websocket connections and how they added validation of the Origin & Host request headers. I then did a quick sniff of a non-secure sgcWebSocketClient open message to see if the Host & Origin headers were set correctly, and they were. GET / HTTP/1.1 Host: echo.websocket.events Upgrade: websocket Connection: Upgrade Sec-WebSocket-Key: bqpkyi65bouSV8Kqun8pNg== Origin: echo.websocket.events Sec-WebSocket-Version: 13 HTTP/1.1 101 Switching Protocols Connection: Upgrade Upgrade: websocket Sec-Websocket-Accept: HOcE1/MjyW+5fE7PkLD6AbUS3Bs= Via: 1.1 vegur It would be interesting to see what the connection conversation with the Firefox Webdriver websocket server looks like and how it differs from the Chrome conversation.
    1 point
  3. TheXman

    Websockets and AutoIt

    Yes, I communicate with the sgcWebSocket client through its, optional, internal TCP server. I needed to look back at some of my old scripts to refresh my memory as to why. I recalled that trying to either read from stdout or write to stdin caused AutoIt to crash, I can't remember which. I don't think that the console apps were designed to have external processes share stdout or stdin. That's probably why the developers of the console apps added an optional, internal TCP server to each their console apps. The basic framework that my scripts use: Open the sgcWebSocket console client using the optional TCP server, on localhost, listening on a specified port. Open a TCP socket to the client's console app Send websocket commands to a server, through the TCP socket, to the websocket client Listen for websocket responses, sent back to the client, using the TCP socket Enqueue those websocket responses using an internal response queue Process the one or more responses from my internal response queue Rinse and repeat the send/listen/enqueue/process loop as needed When finished send a close message to the websocket server close & shut down the tcp session That is the basic framework for both my send/receive and subscription models. Below is a current log from sample WebSocket client subscription script that I wrote last year. It's nice to know that it still works. The script was indirectly inspired by a link in this post by @jugador. The topic was related to decoding protobuf packets that were coming from a Yahoo Finance WebSocket server. As you can see, the script could handle decoding and parsing multiple protobuf messages per second from the WebSocket server. Sample Log: 2022-11-10 12:17:11 Websocket client console window opened 2022-11-10 12:17:11 TCP connection to Websocket client established 2022-11-10 12:17:11 Connecting to WebSocket server (wss://streamer.finance.yahoo.com) 2022-11-10 12:17:12 Event = connected 2022-11-10 12:17:12 Subscribing to tickers (AMZN DOW WMT) 2022-11-10 12:17:12 Ticker message format: Ticker|Price|Change% 2022-11-10 12:17:13 Event = message Message = DOW|49.4541|1.77410126 2022-11-10 12:17:14 Event = message Message = WMT|141.16|1.69000244 2022-11-10 12:17:14 Event = message Message = AMZN|96.46|10.32 2022-11-10 12:17:15 Event = message Message = DOW|49.4541|1.77410126 2022-11-10 12:17:16 Event = message Message = AMZN|96.44|10.3000031 2022-11-10 12:17:17 Event = message Message = WMT|141.16|1.69000244 2022-11-10 12:17:17 Event = message Message = DOW|49.4541|1.77410126 2022-11-10 12:17:17 Event = message Message = AMZN|96.44|10.3000031 2022-11-10 12:17:18 Event = message Message = WMT|141.16|1.69000244 2022-11-10 12:17:18 Event = message Message = AMZN|96.41|10.2700043 2022-11-10 12:17:19 Event = message Message = WMT|141.169403|1.69940186 2022-11-10 12:17:19 Event = message Message = AMZN|96.415|10.2750015 2022-11-10 12:17:20 Event = message Message = AMZN|96.41|10.2700043 2022-11-10 12:17:21 Event = message Message = WMT|141.165|1.69499207 2022-11-10 12:17:21 Event = message Message = DOW|49.4541|1.77410126 2022-11-10 12:17:22 Event = message Message = DOW|49.4541|1.77410126 2022-11-10 12:17:22 Event = message Message = WMT|141.165|1.69499207 2022-11-10 12:17:22 Event = message Message = AMZN|96.44|10.3000031 2022-11-10 12:17:23 Event = message Message = WMT|141.165|1.69499207 2022-11-10 12:17:24 Event = message Message = DOW|49.4541|1.77410126 2022-11-10 12:17:24 Event = message Message = AMZN|96.4299|10.2899017 2022-11-10 12:17:24 Event = message Message = WMT|141.18|1.70999146 2022-11-10 12:17:25 Event = message Message = AMZN|96.4114|10.2714 2022-11-10 12:17:27 Event = message Message = AMZN|96.4225|10.2825012 2022-11-10 12:17:27 Event = message Message = WMT|141.18|1.70999146 2022-11-10 12:17:28 Event = message Message = DOW|49.445|1.76499939 2022-11-10 12:17:29 Event = message Message = AMZN|96.39|10.25 2022-11-10 12:17:29 Event = message Message = WMT|141.18|1.70999146 2022-11-10 12:17:29 Event = message Message = AMZN|96.3889|10.2489014 2022-11-10 12:17:30 Event = message Message = WMT|141.18|1.70999146 2022-11-10 12:17:30 Event = message Message = DOW|49.445|1.76499939 2022-11-10 12:17:31 Event = message Message = DOW|49.445|1.76499939 2022-11-10 12:17:31 Event = message Message = WMT|141.18|1.70999146 2022-11-10 12:17:32 Event = message Message = AMZN|96.39|10.25 2022-11-10 12:17:32 Event = message Message = WMT|141.16|1.69000244 2022-11-10 12:17:32 Stop monitoring requested by user 2022-11-10 12:17:32 Event = message Message = AMZN|96.39|10.25 2022-11-10 12:17:33 Event = message Message = AMZN|96.38|10.2399979 2022-11-10 12:17:33 Event = message Message = WMT|141.16|1.69000244 2022-11-10 12:17:33 Event = disconnected (Code: 0) 2022-11-10 12:17:33 TCPShutdown requested 2022-11-10 12:18:14 Websocket client window closed
    1 point
  4. Come on.. that can't be your best try seeing the original working one, so try again and this time think a little about it. Post your code when it doesn't work, but it has to be a bit more serious that the last.
    1 point
  5. argumentum

    Websockets and AutoIt

    To know that is disconnected, pong/ping is needed. And if ping/pong is there, automatic reconnect is just an extra line of code ( or 20 )
    1 point
  6. Then add an ExitLoop at the point you want to break the loop...
    1 point
  7. Try adding the following at the top of your script -- #AutoIt3Wrapper_UseX64=y If that doesn't work, then I suggest that you provide a way for us to replicate the issue.
    1 point
  8. It is because you are reading time outside the loop. And Not only applies to $hour (see operator precedence in help file). Try this instead : #include <Date.au3> Local $tTime While True $tTime = _Date_Time_GetLocalTime() If $tTime.hour = 7 And $tTime.minute = 59 And $tTime.second = 30 And $tTime.mseconds > 599 And $tTime.mseconds < 999 Then ; do what you need to do here ConsoleWrite("Time achieved" & @CRLF) Sleep(500) ; make sure you only run it once EndIf Sleep(100) ; so as not overload CPU WEnd
    1 point
  9. Why? That won't be that accurate anyway and can't really see why that would be needed.
    1 point
  10. In your first example code, Not applies to $hour = 13. Leave msec out, you don't need that and make it simple: While _NowTime() < "13:19:30" Sleep(100) WEnd
    1 point
  11. Local $aValues = [10.5, 0.0, -1.0, -3.001, 5.00000001] For $n In $aValues ConsoleWrite(StringFormat((IsInt($n) ? "%05i\n" : "%05.1f\n"), $n)) Next Sorry for that, I was typing my answer but got diverted elsewhere while @abberration posted.
    1 point
  12. Local $double = 10.5, $fDouble $fDouble = StringFormat(IsFloat ($double)?"%05.1f":"%05i", $double) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $fDouble = ' & $fDouble & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console Ternary operators
    1 point
  13. @TimRude try to subclass the listview, it should intercept the right-click before it reaches it : #include <GUIConstantsEx.au3> #include <GuiImageList.au3> #include <GuiListView.au3> #include <WindowsConstants.au3> #include <WinAPIShellEx.au3> OnAutoItExitRegister('OnAutoItExit') Global $g_hListView ; Register DLL callback that will be used as window subclass procedure Global $g_hDll = DllCallbackRegister('_SubclassProc', 'lresult', 'hwnd;uint;wparam;lparam;uint_ptr;dword_ptr') Global $g_pDll = DllCallbackGetPtr($g_hDll) Example() Func Example() Local $hGUI, $hImage $hGUI = GUICreate("ListView Create (v" & @AutoItVersion & ")", 400, 300) $g_hListView = _GUICtrlListView_Create($hGUI, "", 2, 2, 394, 268) _GUICtrlListView_SetExtendedListViewStyle($g_hListView, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES)) ; Install window subclass callback _WinAPI_SetWindowSubclass($g_hListView, $g_pDll, 1000, 0) GUISetState(@SW_SHOW) ; Load images $hImage = _GUIImageList_Create() _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($g_hListView, 0xFF0000, 16, 16)) _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($g_hListView, 0x00FF00, 16, 16)) _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($g_hListView, 0x0000FF, 16, 16)) _GUICtrlListView_SetImageList($g_hListView, $hImage, 1) ; Add columns _GUICtrlListView_InsertColumn($g_hListView, 0, "Column 1", 100) _GUICtrlListView_InsertColumn($g_hListView, 1, "Column 2", 100) _GUICtrlListView_InsertColumn($g_hListView, 2, "Column 3", 100) ; Add items _GUICtrlListView_AddItem($g_hListView, "Row 1: Col 1", 0) _GUICtrlListView_AddSubItem($g_hListView, 0, "Row 1: Col 2", 1) _GUICtrlListView_AddSubItem($g_hListView, 0, "Row 1: Col 3", 2) _GUICtrlListView_AddItem($g_hListView, "Row 2: Col 1", 1) _GUICtrlListView_AddSubItem($g_hListView, 1, "Row 2: Col 2", 1) _GUICtrlListView_AddItem($g_hListView, "Row 3: Col 1", 2) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>Example Func _SubclassProc($hWnd, $iMsg, $wParam, $lParam, $iID, $pData) #forceref $iID, $pData If $iMsg = $WM_RBUTTONDOWN Then Return 0 Return _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam) EndFunc ;==>_SubclassProc Func OnAutoItExit() _WinAPI_RemoveWindowSubclass($g_hListView, $g_pDll, 1000) DllCallbackFree($g_hDll) EndFunc ;==>OnAutoItExit
    1 point
  14. mike2003, For the first of your cryptic messages, I presume you are complaining that the $iHeight value is forced to an even number within the function which means that the function fails as $iMaxWidth is now more than 10 times the original odd value of $iHeight. I chose to force the height parameter of this function to an even number to simplify the later drawing of the Notification - both lines will be the same size when the height is even. By setting the values for min/max width of the Notification to the absolute limit you have found an edge case which I will look into to see if it can be resolved - although the final solution may be as simple as adding a warning that odd $iHeight values will be rounded up. As to the second, the _Notify_Show function returns an @error/@extended pair to tell you that the required string will not fit in the Notification. I disagree that the current behaviour should be altered - the user can easily change the function behaviour by using the $bProc parameter in a _Notify_Set call and the function failure is quite clearly shown by the return value. M23
    1 point
  15. TheXman

    Websockets and AutoIt

    Could you provide a little more information regarding what you would consider acceptable? What features are required? I am familiar with the clients you've listed as well as a few others, but I don't want to waste your time by suggesting any clients if they are missing functionality or features that you feel are required. Are you wanting a solution that allows you to maintain Windows 7 compatibility? Or, is a Window 8+ solution acceptable? You've stated that you would prefer a FOSS solution. What about a "Free for non-commercial use" solution? Is a DLL-based solution required? What about another CLI solution? Is full RFC6455 support a requirement or are there some websocket capabilities that are not necessary? The ability to identify disconnected sessions. (Already stated as a requirement or desirable feature) Do you require the ability to automatically restart disconnected sessions? Do you require the ability to send ping/pong "keepalive" messages in order to maintain connections thru aggressive firewalls and NAT. Is your goal to be able to send & receive requests to a websocket server, to be able to subscribe to a websocket server and receive all responses for a given period of time, or both? In the past, I've written some reliable scripts for both send/receive and subscription-based websocket client use cases. But like I said, I don't want to waste your time (or mine) by suggesting anything that doesn't meet your minimum requirements.
    1 point
  16. Subclassing (read and process Windows messages before they reach the destination control or window) is a common way. Here (the example for GUICtrlCreateEdit in the Help file) right click is canceled in the Edit control and no context menu shows up: #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPIShellEx.au3> Example() Func Example() GUICreate("My GUI edit") ; will create a dialog box that when displayed is centered Local $idMyedit = GUICtrlCreateEdit("First line" & @CRLF, 176, 32, 121, 97, $ES_AUTOVSCROLL + $WS_VSCROLL) Local $hMyedit = GUICtrlGetHandle( $idMyedit ) ; Subclassing Edit control Local $pEditCallback = DllCallbackGetPtr( DllCallbackRegister( "EditCallback", "lresult", "hwnd;uint;wparam;lparam;uint_ptr;dword_ptr" ) ) _WinAPI_SetWindowSubclass( $hMyedit, $pEditCallback, 1, 0 ) ; $iSubclassId = 1, $pData = 0 GUISetState(@SW_SHOW) Send("{END}") ; will be append dont' forget 3rd parameter GUICtrlSetData($idMyedit, "Second line", 1) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete() EndFunc ;==>Example Func EditCallback( $hWnd, $iMsg, $wParam, $lParam, $iSubclassId, $pData ) ; If $iMsg <> $WM_RBUTTONUP then call next function in subclass chain (this forwards messages to Edit control) If $iMsg <> $WM_RBUTTONUP Then Return DllCall( "comctl32.dll", "lresult", "DefSubclassProc", "hwnd", $hWnd, "uint", $iMsg, "wparam", $wParam, "lparam", $lParam )[0] Return 0 ; If $iMsg = $WM_RBUTTONUP then cancel the message by returning 0 EndFunc
    1 point
×
×
  • Create New...