
Adams100
Members-
Posts
10 -
Joined
-
Last visited
Everything posted by Adams100
-
Converting a Month to a number using autoit...
Adams100 replied to tommytx's topic in AutoIt General Help and Support
Something like this should work: Global $example1 = '2014/May/26' Global $example2 = '2014/Jan/15' Global $example3 = '2014/Apr/03' MsgBox(0, "message", $example1 & ' -> ' & _ConvertMonth($example1)) MsgBox(0, "message", $example2 & ' -> ' & _ConvertMonth($example2)) MsgBox(0, "message", $example3 & ' -> ' & _ConvertMonth($example3)) Func _ConvertMonth($date) $date = StringReplace($date, '/Jan/', '/01/') $date = StringReplace($date, '/Feb/', '/02/') $date = StringReplace($date, '/Mar/', '/03/') $date = StringReplace($date, '/Apr/', '/04/') $date = StringReplace($date, '/May/', '/05/') $date = StringReplace($date, '/Jun/', '/06/') $date = StringReplace($date, '/Jul/', '/07/') $date = StringReplace($date, '/Aug/', '/08/') $date = StringReplace($date, '/Sep/', '/09/') $date = StringReplace($date, '/Oct/', '/10/') $date = StringReplace($date, '/Nov/', '/11/') $date = StringReplace($date, '/Dec/', '/12/') Return $date EndFunc -
An example I whipped up: #include <GUIConstantsEx.au3> #include <GUIListView.au3> #include <GuiImageList.au3> GUICreate("gui", 679, 343, 192, 124) Global $list = GUICtrlCreateListView("column1|column2|colum3", 8, 8, 610, 259) _GUICtrlListView_SetExtendedListViewStyle($list, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES)) Global $hImage = _GUIImageList_Create(16, 16, 5, 1) _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 22) _GUICtrlListView_SetImageList($list, $hImage, 1) GUICtrlCreateListViewItem("text|icon|more text", $list) GUICtrlSetBkColor(-1, 0xC3A3FC) _GUICtrlListView_SetColumnWidth($list, 0, 200) _GUICtrlListView_SetColumnWidth($list, 1, 200) _GUICtrlListView_SetColumnWidth($list, 2, 200) _GUICtrlListView_SetItemImage($list, 0, 0, 1) GUISetState(@SW_SHOW) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE It just doesn't look right. Is there any way to make the Icon have a transparent (see-through) background? That way it would blend in with the background color of the row. I hope there's a simple solution. I couldn't find a way to do this.
-
If I'm adding icons into an image list from .exe files, how can I check if a certain exe file is already in the list? Example: #include <GuiImageList.au3> Global $hImage = _GUIImageList_Create(16, 16, 5) _GUIImageList_AddIcon($hImage, "C:\path\to\somefile1.exe", 0) _GUIImageList_AddIcon($hImage, "C:\path\to\somefile2.exe", 0) _GUIImageList_AddIcon($hImage, "C:\path\to\somefile3.exe", 0) _GUIImageList_AddIcon($hImage, "C:\path\to\somefile2.exe", 0) ; how to check if this icon is already in the ImageList instead of having it there twice? I'd like to be able to avoid adding icons to the list that have already been added to list. And possibly even tell me the index of the exisiting image in the ImageList.
-
BrewManNH, thanks for the tip about GUICtrlGetHandle() because I was using the control id. And Zedna, thanks for that info. Now the choice is clear. Native is what I want, mainly for the speed. The 65535 limit is more than enough for my current needs. Previously I thought I had to use the UDF _GUICtrlListView_Create() in order to be able to use the other useful _GUICtrlListView_ UDF's. But now that I know those UDF's will work with the Native ListView then I'm all good. Thanks.
-
Thanks for these examples although I couldn't get it to achieve the results I need which is to change the background color of the actual row. But that's pretty massive code to simply change the font color though. With GUICtrlCreateListView() I'd be able to do that with one line of code. Does that mean there's no "easy" way to do this with _GUICtrlListView_Create()? Is it a good idea to use GUICtrlCreateListView() and then still use some of the _GUICtrlListView_ UDF's on a listview that was created with GUICtrlCreateListView()? Or is it recommended to use _GUICtrlListView_ for everything? Because then I could have the best of both worlds guess.
-
With GUICtrlCreateListView() I can create a listview with different colors for different rows: Global $GUI = GUICreate("gui", 250, 250) Global $hListView = GUICtrlCreateListView("column1|column2|column3", 5, 5, 200, 200) GUICtrlCreateListViewItem("row1|row1|row1", $hListView) GUICtrlSetBkColor(-1, 0xFFFF00) GUICtrlCreateListViewItem("row2|row2|row2", $hListView) GUICtrlSetBkColor(-1, 0xFF0000) GUICtrlCreateListViewItem("row3|row3|row3", $hListView) GUICtrlSetBkColor(-1, 0x00FF00) GUISetState(@SW_SHOW) Do Until GUIGetMsg() = -3 But how do we achieve the same result with _GUICtrlListView_Create() ? #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <GuiImageList.au3> #include <WindowsConstants.au3> Global $GUI = GUICreate("gui", 250, 250) Global $hListView = _GUICtrlListView_Create($GUI, "", 5, 5, 200, 200) _GUICtrlListView_InsertColumn($hListView, 0, "column1", 60) _GUICtrlListView_InsertColumn($hListView, 1, "column2", 60) _GUICtrlListView_InsertColumn($hListView, 2, "column3", 60) _GUICtrlListView_AddItem($hListView, "row1", 0) _GUICtrlListView_AddSubItem($hListView, 0, "row1", 1) _GUICtrlListView_AddSubItem($hListView, 0, "row1", 2) _GUICtrlListView_AddItem($hListView, "row2", 1) _GUICtrlListView_AddSubItem($hListView, 1, "row2", 1) _GUICtrlListView_AddSubItem($hListView, 1, "row2", 2) _GUICtrlListView_AddItem($hListView, "row3", 2) _GUICtrlListView_AddSubItem($hListView, 2, "row3", 1) _GUICtrlListView_AddSubItem($hListView, 2, "row3", 2) GUISetState(@SW_SHOW) Do Until GUIGetMsg() = -3 Is it possible? I found this function _GUICtrlListView_SetTextBkColor() but it only sets the same color for all items in the list. So no multi-colored lines like in the first example.
-
Cool. Thanks guys. For my current needs I would have to wait for the process to end in order to get the output I want. So I figured if there was no other benefit in using the While loop besides being able read it during the execution, then I'd be better off using the ProcessWaitClose method because doing StdoutRead() in a While loop causes CPU usage to go through the roof on my PC when the process needs to run for more then a few seconds, and sometimes even minutes/hours depending on the situation so it's not really ideal. But this is a pretty weird problem with ProcessWaitClose that Chimp pointed out. I wonder what causes it. And has this occurred in any other cases or was it just with PowerCfg? Ahh, this makes me want to go back to the While loop now hehe.
-
Hi. Can somebody help me understand the benefit of one over the other regarding these two ways of getting the StdoutRead() #include <Constants.au3> #include <MsgBoxConstants.au3> #include <Array.au3> ; display a list of files in C:\ Local $iPID = Run(@ComSpec & ' /C DIR C:\ /B', 'C:\', @SW_HIDE, $STDOUT_CHILD) ProcessWaitClose($iPID) Local $sOutput = StdoutRead($iPID) Local $aArray = StringSplit(StringTrimRight(StringStripCR($sOutput), StringLen(@CRLF)), @CRLF) _ArrayDisplay($aArray) - #include <Constants.au3> #include <MsgBoxConstants.au3> #include <Array.au3> ; display a list of files in C:\ Local $iPID = Run(@ComSpec & ' /C DIR C:\ /B', 'C:\', @SW_HIDE, $STDOUT_CHILD) Local $sOutput = "" While 1 $sOutput &= StdoutRead($iPID) If @error Then ExitLoop EndIf WEnd Local $aArray = StringSplit(StringTrimRight(StringStripCR($sOutput), StringLen(@CRLF)), @CRLF) _ArrayDisplay($aArray) The first one gets the StdoutRead after the process closes. The second one gets the StdoutRead in a while loop while the process is running. But is there a benefit to either one or is the end result the same every time? Thanks.