Leaderboard
Popular Content
Showing content with the highest reputation on 05/16/2016 in all areas
-
[New VERSION] - 11 Dec 24 Added: New function _GUIListViewEx_EditProcessActive which returns the handle of the ListView concerned if an element is being edited. Usage scenario: prevent HotKeys from working when editing is underway. Fixed: A couple of bugs with columns: added columns were automatically sortable; dragging columns meant editing pop-up could appear in wrong place. Thanks to ValentinM for the reports. New UDF in the zip below. -------------------------------------------------------------------------------------- Note: This is a new recoded and expanded version of my earlier UDF of the same name. If you move to this new version there might well be several script-breaking changes, particularly when setting which columns are to be editable. Please read the "Beginner's Guide" and look at the included example scripts to see where things have changed. -------------------------------------------------------------------------------------- This UDF allows you to do much more with ListView controls (either native or UDF created): Edit the content with plain text, combos or date-time pickers - and edit the headers too Move rows within the ListView Drag rows both within the ListView and to other ListViews in the same GUI (or not as required) Insert and delete columns and rows Sort columns by simply clicking the header Colour individual ListView items and headers Only select a single cell rather then the entire row Save and load entire ListViews For the advanced user: If you use certain Windows message handlers (In particular WM_NOTIFY) in your script, please read the function headers for the equivalent handlers within the UDF. Here is the UDF, with 6 examples and the guide, in zip format: GUIListViewEx.zip Credit to: martin (basic drag code), Array.au3 authors (array functions), KaFu and ProgAndy (font function), LarsJ (colouring code) Happy to take compliments or criticism - preferably the former! M231 point
-
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
-
The array returned by _AccountEnum returns a 1-based array with the item count in 0 element. For $i = 1 to $aNames[0] If $aNames[$i] <> "(desired name)" Then _AccountDelete($aNames[$i]) EndIf Next Also, by using _AccountEnum, it returns all local accounts admin or not. Just look through the members of the local Administrators group to get Admin accounts. $aNames = _GroupEnumMembers("Administrators") Adam1 point
-
What is the next doing at that spot? Is this better?: For $i = 0 to UBound($aNames) - 1 If $aNames[$i] <> "(desired name)" Then _AccountDelete($aNames[$i]) EndIf Next Jos1 point
-
Thats an array. he declared it with [3] elements, and then specified those elements on the same line.1 point
-
For the example you posted: Global $aANINumbers[1] = ["5551234567"]1 point
-
x6tr2, Welcome to the AutoIt forums. _FileListToArray is what you want - or _FileListToArrayRec if you want to list the content of subfolders as well. The Help file explains the details. M231 point
-
Your welcome. I thought you were talking about renaming multiple Admins accounts, and you wanted to rename a specific one. Are you just talking about just the "Administrator" account only? If so, change Global $sAdminAcct = InputBox($sBoxTitle, 'Enter Admin Username to Search: ', '', '*', -1, -1, 0, 0, 10000) If @error Then Exit to #include <Security.au3> Global $aUsers = _AccountEnum() Global $sSIDUser = "" Global $iAdminIndex = 0 For $i = 1 To $aUsers[0] $sSIDAUser = _Security__SidToStringSid(_Security__GetAccountSid($aUsers[$i])) If StringRegExp($sSIDUser, "^S-1-5-21-.*-500$") Then $iAdminIndex = $i EndIf Next Global $sAdminAcct = $aUsers[$iAdminIndex] Adam1 point
-
If you just want 'the' built-in administrator account #include<array.au3> #requireadmin $sCommand = "wmic /NODE:localhost useraccount get name,sid" $iPID = run($sCommand , "" , @SW_HIDE , $stdout_child) $sOutput = "" While 1 $sOutput &= StdoutRead($iPID) If @error Then ExitLoop WEnd ProcessClose($iPID) $aOut = stringsplit($sOutput , @LF , 2) for $i = 0 to ubound($aOut) - 1 If stringright(stringstripWS($aOut[$i] , 2) , 3) = "500" AND stringinstr($aOut[$i] , "S-1-5-21-") Then $sName = stringleft($aOut[$i] , stringinstr($aOut[$i] , "S-1-5-21-") - 1) EndIf next msgbox(0,'',StringStripWS($sName , 8))1 point
-
Using AutoIT to pull specific numbers from spreadsheet
JadeRae reacted to JLogan3o13 for a topic
Hi, @JadeRae, welcome to the forum. The short answer to your question is yes, what you're looking to do can be done with the Excel functions that come with AutoIt. Judging by your question, I would guess you'll be needing the functions below as a start (plenty more help and examples to be found in the help file): _Excel_Open _Excel_BookOpen _Excel_RangeRead I would start with the example under _Excel_Open, and try to modify that to your needs. If you get stuck, don't hesitate to post what you have here (even if it isn't doing what you would like it to), and we will do our best to assist1 point -
That should work fine, but you could try to simplify it and take out a few lines. IsArray returns 1 if the check is succesful or a 0 if not. So you could use that bool condition in your If statement instead of the whole function. Not too much different, but it would get rid of the need for an else statement. $bCheck = IsArray($box) If $bCheck = 0 Then SoundPlay(@WindowsDir & '\media\tada.wav', 1)1 point
-
As I said above, if you're searching in an area for a certain color using PixelSearch, you will always get that color using the array returned by the PixelSearch because that is how the script is written, it will NEVER be anything other than the color you searched for AT THAT LOCATION.1 point
-
Trong, try to kill all iexplore.exe processes and then run your code again. If you still get an error try to reboot.1 point
-
MetroGUI UDF v5.1 - Windows 10 style buttons, toggles, radios, menu etc.
Trong reacted to LFCavalcanti for a topic
Great! I did these modifications to suit my needs and shared them, maybe someone wants to use as I did, maybe not. Time is a limited resource... haha I'm using the UDF in this: https://github.com/LFCavalcanti/intermix1 point -
Hi, u can do something like that ; #NoTrayIcon #include <ie.au3> #include <Inet.au3> Local $link2 = "" Local $oIE = _IECreate("https://www.hyundaiusa.com/",0,0,1,0) Local $link = _IETagNameGetCollection ($oIE, 'a') For $links in $link $link2 = $link2 & @CRLF & $links.href $aa=ConsoleWrite('+Your something is: ' & $link &@CRLF) Next _IEQuit($oIE) MsgBox($MB_SYSTEMMODAL, "Results","Link:" & $link2 & @CRLF)1 point
-
In case the context makes it valuable to have the data stored in a database, say with SQLite or some other engine, inside a table created like this: create table T as (col1, col2, ..., col11, COL12 char); then the wanted result is essentially a one-liner: Local $aRows, $iRows, $iCols _SQLiteGetTable2d(-1, "select COL12, count(*) C from T group by COL12 order by C desc;", $aRows, $iRows, $iCols) The database approach is quickly beneficial when several different queries are needed over a significant amount of data, even more when the queries are complex.1 point
-
Thank @dmob and @AdamUL by IrfanView's tip because he solved my problem! @Chimp I chose to use IrfanView because he did not need to create a PDF of the images but thank you very much for the tips you gave me!1 point
-
I was looking for a way to find out how long my PC had been running a few weeks ago and had trouble finding something that satisfied my needs, I found a Visual Basic Script that worked but found it too long. But searching trough AutoIt WINAPI help found that it really was as simple as the following little script. #include <WinAPISys.au3> #include <WinAPIMisc.au3> Local $Uptime = _WinAPI_StrFromTimeInterval(_WinAPI_GetTickCount()) MsgBox(0, '', "PC Uptime ==> " & $UpTime) Hope it helps...1 point
-
How to Get AppPool name and status using WMI
shilpa reacted to JLogan3o13 for a topic
Hi, @shilpa something like this should get you the App Pool name: Const $wbemFlagReturnImmediately = "&h10" Const $wbemFlagForwardOnly = "&h20" Local $sPC = "" ;Name of IIS Server Local $oWMI = ObjGet("winmgmts:\\" & $sPC & "\root\WebAdministration") Local $oItems = $oWMI.ExecQuery("SELECT * FROM ApplicationPool", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($oItems) Then If $oItems.Count <> 0 Then For $sApp In $oItems ConsoleWrite("Application: " & $oItems.Name & @CRLF & "Start Mode: " & $oItems.StartMode & @CRLF) Next EndIf EndIf1 point -
The DllNotFoundException is caused by screwed up assembly dependencies when the dll package was built. Nuget installer for AutoitX is not working for the same reason (more details here). Bottom line - Visual Studio doesn't know it needs to copy AutoItX3.dll to the output directory. It only copies AutoItX3.Assembly.dll, and forgets about the other one. The easiest solution is ensuring AutoItX3.dll is in your output bin/Debug or bin/Release directory, when you run your program (basically the same directory as your exe). You can do that by simply placing AutoItX3.dll in the root of your project in visual studio, and then setting its properties to: Copy to Output Directory: 'Copy if newer'1 point