Leaderboard
Popular Content
Showing content with the highest reputation on 11/06/2019 in all areas
-
In the forums you can find several questions about how to edit the text in a ListView cell with a standard control eg. an Edit control or a ComboBox. The zip below contains three examples with an Edit control, a ComboBox and a DateTimePicker. How? A description from MicroSoft of how to edit a ListView cell with a ComboBox can be found here. When you click a cell the position and size is calculated, and the ComboBox is created on top of the cell. The text is shown in the Edit box. You can edit the text or select a value in the Listbox. Press Enter to save the text in the ListView cell and close the ComboBox. The ComboBox exists only while the text is edited. Code issues Especially because the control to edit the ListView cell is created on top of the ListView and is not part of the ListView, there are some issues you should be aware of. To get everything to look as good as possible most actions should be carried out when a mouse button is pressed and not when it's released. You should also be aware that the new code you add, does not conflict with existing functionality for example multiple selections. The examples consists of small but fairly many pieces of code to respond to events and messages. Keyboard support To edit a text value you are more or less forced to use the keyboard to type in the text. It would be nice if you could also select the current cell in the ListView with the keyboard. Cell selection with the keyboard is not too hard to implement with custom draw code. The current cell is drawn with a specific background color. It looks like this. You can select the current cell with the arrow keys. Open the control There must be a way to initiate the creation of the control. This is typically done with a single or double click in the ListView. Or with Enter or Space key in the examples with keyboard support. Default in the examples is double click and Enter key. You can change this in global variables in top of the scripts. A WM_NOTIFY message handler created with GUIRegisterMsg is used to watch for single and double click in the ListView. This message handler is also used to handle custom draw messages for keyboard support. Because the control is created on top of the ListView cell, it's very important that the ListView is set as the parent window. This ensures that mouse clicks and key presses are captured by the control and not by the ListView. Events in the control In a ComboBox and a DateTimePicker an additional control (Listbox and MonthCal, respectively) is opened if you click the Dropdown arrow (or press <Alt+Down arrow> on the keyboard). Click the Dropdown arrow again to close the control (or press <Alt+Up arrow> on the keyboard). The interesting messages (DROPDOWN, SELECTION, CLOSEUP) from such an additional control are usually contained in WM_COMMAND or WM_NOTIFY messages which are sent to the parent window. The parent window is the ListView. To catch the messages the ListView must be subclassed. Messages from the Edit control, the Edit box of the ComboBox, or the client area of the DateTimePicker are catched by subclassing the controls (Edit control, Edit box and DateTimePicker) directly. The interesting information here is dialog codes to accept (Enter) or cancel (Esc) the value and close the control. Dialog codes are sent as $WM_GETDLGCODE messages. In all examples the value in the control can also be accepted and saved with a double click. Close the control A mouse click in the ListView outside the control should close the control and cancel editing of the current cell. Because the control is not part of the ListView in particular mouse clicks on the Scrollbars should close the control immediately. The control will not be repainted properly on scrolling. Mouse clicks in the ListView and on Scrollbars can be identified by WM_LBUTTONDOWN and WM_NCLBUTTONDOWN messages. The area which is filled by Scrollbars in a ListView is non-client area. Mouse clicks in non-client area generates WM_NCLBUTTONDOWN messages. To catch the messages you have to subclass the ListView. A mouse click in the GUI outside the ListView and in non-client GUI area (eg. the Titlebar) should also close the control. Mouse clicks in GUI are catched through GUI_EVENT_PRIMARYDOWN messages. Mouse clicks in non-client GUI area are catched through WM_NCLBUTTONDOWN messages by subclassing the GUI. Finish the code A great part of the code is running in message handlers created with GUIRegisterMsg or created by subclassing a window. Lengthy code to open or close the control should not be executed in these message handlers. Instead of a message is sent to the AutoIt main loop where the control is opened or closed. Some of the message handlers are only needed while the control is open. They are created and deleted as part of the control open and close code. In the context of the updates May 26 the $LVS_EX_HEADERDRAGDROP extended style (rearranging columns by dragging Header items with the mouse) is added to all ListViews. See post 20 and 21. A few lines of code are added to better support usage of the keyboard. See image above. The code provides for horizontal scrolling of the ListView to make sure that a subitem (or column) is fully visible when it's selected with left or right arrow. Among other things, the code takes into account rearranging and resizing of columns as well as resizing of the GUI and ListView. A new example EditControlKeyboardTenCols.au3 demonstrates the features. See post 22. A few lines of code is added to handle multiple selections. Multiple selections is enabled in all examples. Pressing the Tab key in the control closes the control. The image shows a DateTimePicker control. Zip file The zip contains three examples with an Edit control, a ComboBox and a DateTimePicker. For each control there are two scripts with and without keyboard support. In the script with keyboard support you can select the current cell in the ListView with the arrow keys and open the control with the Enter (default) or the Space key. You need AutoIt 3.3.10 or later. Tested on Windows 7 32/64 bit and Windows XP 32 bit. Comments are welcome. Let me know if there are any issues. (Set tab width = 2 in SciTE to line up comments by column.) ListViewEditingCells.7z1 point
-
OutlookEX UDF - Help & Support (IV)
seadoggie01 reacted to water for a topic
Will be part of the next release Added you to the contributors of this UDF1 point -
Hello, this should help you out of your Problem: #include <AutoItConstants.au3> $Bat="C:\temp\test.bat" $hBat=FileOpen($Bat,2+8) FileWriteLine($hBat,'@echo off') FileWriteLine($hBat,'echo this is the first echo line') FileWriteLine($hBat,':RESTART') FileWriteLine($hBat,'echo this is the second line') FileWriteLine($hBat,'choice /c YN /m "do you want to restart?"') FileWriteLine($hBat,'if errorlevel 2 goto EXIT') FileWriteLine($hBat,'if errorlevel 1 goto RESTART') FileWriteLine($hBat,':EXIT') FileWriteLine($hBat,'echo this is the END...') FileClose($hBat) $pid=Run(@ComSpec & ' /C "' & $Bat & '"',@TempDir, @SW_HIDE, $STDIN_CHILD + $STDERR_MERGED) $StrOutput="" $StrMatch="restart" $Found=0 ToolTip($StrOutput,100,100,$Found) while ProcessExists($pid) $StrOutput &= StdoutRead($pid) ToolTip($StrOutput,100,100,$Found) if StringInStr($StrOutput,$StrMatch) Then if $Found > 2 Then $Char="n" Else $Char="y" EndIf $Found+=1 StdinWrite($pid,$Char) EndIf Sleep(100) ; waiting for BAT file to vanish WEnd MsgBox(0,"Process vanished","number of matches found: " & $Found & @CRLF & $StrOutput) Explanation: You have to add $STDIN_CHILD for your run command You have to use StdinWrite(), not "send()" to write to the console of your BAT file. cu, Rudi. PS: I guess that BAT file is maintained by some other Person or department, and so it's a "take it or leave it Option" to you. Nevertheless it's worth a try, that +YOU+ encourage this other Person or dept to natively use autoit for These Tasks, as several other answers here mentioned before.1 point
-
OutlookEX UDF - Help & Support (IV)
seadoggie01 reacted to water for a topic
Fixed. You are talking about _OL_ItemSave or _OL_AttachmentSave? As _OL_ItemSave and _OL_AttachmentSave provide the functionality to save attachments I'm thinking about moving all relevant lines of code to _OL_AttachmentSave and just call this function from _OL_ItemSave. So we have only a single function to modify if needed. What do you think?1 point -
@Blue0 : In your place I would really try to follow the advice of @jchd (if possible). Most installers can be controlled via command line parameters, such as /SILENT , /NORESTART and so on. This is more reliable than processing CMD console streams. Here e.g. a list of command line arguments for MSIEXEC : https://www.robvanderwoude.com/msiexec.php1 point
-
@Blue0 Please check if this is what you're trying to achieve: Run this: #include <AutoItConstants.au3> #include <MsgBoxConstants.au3> $iPID = Run(@ComSpec & " /C " & @DesktopDir & "\Test.bat", @DesktopDir, @SW_HIDE, $STDERR_MERGED) $sTmp = "" While ProcessExists($iPID) $sTmp = StdoutRead($iPID) If StringLen($sTmp) > 0 Then ConsoleWrite($sTmp) WEnd Test.bat's content: @echo off echo restart bat to test restart word search echo would you like to restart echo press y to restart echo press n to not restart pause This is the output running on my computer: +>13:19:48 Starting AutoIt3Wrapper v.19.102.1901.0 SciTE v.4.1.2.0 Keyboard:00000409 OS:WIN_7/Service Pack 1 CPU:X64 OS:X64 Environment(Language:0409) CodePage: utf8.auto.check: +>Setting Hotkeys...--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop restart bat to test restart word search would you like to restart press y to restart press n to not restart Press any key to continue . . . +>13:19:48 AutoIt3.exe ended.rc:0 +>13:19:48 AutoIt3Wrapper Finished. Process exited with code 01 point
-
StdoutRead() can't find text in cmd console?
Blue0 reacted to seadoggie01 for a topic
Gripe: So you're trying to run a broken batch file with AutoIt and execute a second command in case the batch file doesn't execute it? Do you see the irony here? Anyways, try something more like this: ; Run your batch ; Wait for it to quit ProcessWaitClose() ;<-- Look at the this function ; Get ALL the output from the process ; If the output contains your special word ; Do other stuff Also, ignore my comment about #AutoIt3Wrapper_Change2CUI ... that's for getting ConsoleWrite() to output to the command line.1 point -
@Blue0 AFAIK, console window (cmd.exe - to be specific) generates output using GDI (it's kinda graphic generating tool). So what you see running in the cmd.exe window (text, for example) is actually generated graphic. That's the reason why AutoIT Window Info, WinSpy or other tools can not read console command's text. For your issue, StdoutRead just read from STDOUT stream, so you need to modify the .bat to pipe your desired information to STDOUT.1 point
-
Help with group's regex
FrancescoDiMuro reacted to Nine for a topic
Ya so sorry. Mine has 2 lines. That's 100% more. Terrible. So sorry.1 point -
StdoutRead() can't find text in cmd console?
Blue0 reacted to seadoggie01 for a topic
I think you're talking about executing via the command line. If so, include this at the top of your script: #AutoIt3Wrapper_Change2CUI=y Also, take a look at the Documentation, especially RunWait.1 point -
I want to click the ok button f the message box
seadoggie01 reacted to Musashi for a topic
Since you provided a non-runable fragment, here just some remarks : 1. The default API-generated MsgBox from AutoIt pauses the script. It is not possible to continue, unless you response to the MsgBox or use a timeout. The rest of the script ( WinWait("Error") ... ) will not be executed until the MsgBox was closed. - a possible solution could be (untested) : https://www.autoitscript.com/forum/topic/121609-notifybox-udf/ - also have a look at (untested) : https://www.autoitscript.com/forum/topic/136149-notify-new-version-26-apr-19/ Question : "If you want to click away the message box instantly, why are you displaying it at all?" 2. If StringRegExp($string, $p) Then ;MsgBox(0, "Error", "µC programming passed") If Not StringRegExp($string, $p) Then ;MsgBox(0, "Error", "µC programming failed") Should better be written like this : ; Example : Local $sString = "This is a String" Local $p = "This" ; pattern (just for demo) If StringRegExp($sString, $p) Then MsgBox(0, "Error", "µC programming passed") Else MsgBox(0, "Error", "µC programming failed") EndIf Sorry, but without more details, it's hard to help you.1 point -
1 point
-
This script: ;https://autoit.de/index.php?thread/86082-treeview-root-verbergen/&postID=691139#post691139 #include <File.au3> #include <WindowsConstants.au3> Global $sPath = @ScriptDir Global $hGui = GUICreate('TreeView-Example', 400, 600) Global $idTreeView = GUICtrlCreateTreeView(10, 10, 380, 580, Default, $WS_EX_CLIENTEDGE) GUISetState() _CreatePath($sPath, $idTreeView) Do Until GUIGetMsg() = -3 Func _CreatePath($sPath, $idParent) Local $aFolder, $aFiles, $idItem If StringRight($sPath, 1) <> '\' Then $sPath &= '\' $aFolder = _FileListToArray($sPath, '*', $FLTA_FOLDERS) If Not @error Then For $i = 1 To $aFolder[0] $idItem = GUICtrlCreateTreeViewItem($aFolder[$i], $idParent) _CreatePath($sPath & $aFolder[$i], $idItem) Next EndIf $aFiles = _FileListToArray($sPath, '*', $FLTA_FILES) If @error Then Return For $i = 1 To $aFiles[0] $idItem = GUICtrlCreateTreeViewItem($aFiles[$i], $idParent) Next EndFunc does same as yours with native GUICtrlCreateTreeViewItem and _FileListToArray.1 point
-
Eg for IE11 installed (no UDF version): #include <IE.au3> #include <Process.au3> Local $regValue = "0x2AF8" ; IE11 edge mode: 11001 (0x2AF9) ; IE11: 11000 (0x2AF8) ; IE10: 10001 (0x2711) ; IE10: 10000 (0x02710) ; IE 9: 9999 (0x270F) ; IE 9: 9000 (0x2328) ; IE 8: 8888 (0x22B8) ; IE 8: 8000 (0x1F40) ; IE 7: 7000 (0x1B58) RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION", _ProcessGetName(@AutoItPID), "REG_DWORD", $regValue) RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION", _ProcessGetName(@AutoItPID), "REG_DWORD", $regValue) ;~ RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION", @ScriptName, "REG_DWORD", $regValue) ;~ RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION",@ScriptName, "REG_DWORD", $regValue) Global $mainwin = GUICreate("IE test", 968, 688) Global $OBJECT = ObjCreate("Shell.Explorer.2") Global $OBJECT_CTRL = GUICtrlCreateObj($OBJECT, 0, 0, 968, 688) GUISetState() _IENavigate($OBJECT, "http://www.whatsmyuseragent.com/") ;~ _IENavigate($object, "http://www.pinterest.com/") While 1 Sleep(10) If GUIGetMsg() = -3 Then ExitLoop WEnd1 point
-
Please stop the quoting, just reply, quotes are meant for parts you want to refer to. Even weirder is including your answer inside the quote. Anyway, here's my thought on the way to solve it. Opt("WinTitleMatchMode", 2) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase $hCmd = InputBox("Input", "Input title of CMD window"&@crlf&"(doesn't have to be complete)") If @error Or $hCmd = '' Then Exit WinActivate($hCmd) SendKeepActive($hCmd) $cmdtext2 = ClipGet() Send( "! es{Enter}" ) $cmdtext = ClipGet() ClipPut($cmdtext2) MsgBox(64, '', $cmdtext) This keeps your copy/paste text, because it copies to variable does it's thing and copies stuff back again, so it won't mess up copy paste.1 point
-
_GUICtrlEdit_Create font size
pixelsearch reacted to Andreik for a topic
#include <GUIConstantsEx.au3> #include <GuiEdit.au3> #include <FontConstants.au3> #include <WinAPI.au3> Opt('MustDeclareVars', 1) Example() Func Example() Local $szIPADDRESS = @IPAddress1 Local $nPORT = 33891 Local $MainSocket, $Gui, $edit, $ConnectedSocket, $szIP_Accepted, $ConnectedSocket2 Local $msg, $recv, $btn, $input, $input2, $nic Local $font, $hFont TCPStartup() $MainSocket = TCPListen($szIPADDRESS, $nPORT) If $MainSocket = -1 Then Exit $font = "Comic Sans MS" $Gui = GUICreate("Now Serving... [" & $szIPADDRESS & "]", 380, 123) GUICtrlCreateLabel("Serving Ticket #:", 10, 5, 150, 15) ;~ ############################################################################################ $edit = _GUICtrlEdit_Create($Gui, "", 10, 25, 380, 80) $hFont = _WinAPI_CreateFont(20, 0, 0, 0, 400, False, False, False, $DEFAULT_CHARSET, _ ; Change size as you like $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, 0, 'Tahoma') _WinAPI_SetFont($edit,$hFont,True) ;~ ############################################################################################ GUISetFont (60, 10, 1, $font) $edit = GUICtrlCreateLabel("", 100, 15) ;GUICtrlSetFont(-1, 9, 400, -1, "Tahoma") GUISetState() $ConnectedSocket = -1 While 1 $msg = GUIGetMsg() $ConnectedSocket = TCPAccept($MainSocket) If $msg = $GUI_EVENT_CLOSE Then ExitLoop $recv = TCPRecv($ConnectedSocket, 2048) If $recv <> "" Then If _GUICtrlEdit_GetText ($edit) <> "" Then _GUICtrlEdit_SetText($edit, _GUICtrlEdit_GetText($edit) & @CRLF & $recv) Else _GUICtrlEdit_SetText($edit, _GUICtrlEdit_GetText($edit) & $recv) EndIf If Not WinActive($Gui) Then WinFlash($Gui) SoundPlay(@WindowsDir & "MediaDing.wav") _GUICtrlEdit_LineScroll ($edit,_GUICtrlEdit_GetLineCount ($edit)+1,_GUICtrlEdit_GetLineCount ($edit)+1) EndIf WEnd If $ConnectedSocket <> -1 Then TCPCloseSocket($ConnectedSocket) TCPShutdown() _WinAPI_DeleteObject($hFont) ;<<-------------------- DON'T FORGET THIS LINE Exit EndFunc ;==>Example1 point -
_IsPressed is good solution i think , google is your friend0 points