Jump to content

Zest

Active Members
  • Posts

    46
  • Joined

  • Last visited

Everything posted by Zest

  1. Hello, Thank you all for your help and replies. I could not get it to work with those methods, because they did not match exactly what I need and I'm not experienced enough to get it to adapt them to my situation. I did find a workaround for my problem though. Since the problem was that GUICtrlSetImage resizes the image to the size of the -previously- set image, I first set the image to a 'dummy' image with the exact correct size as defined in GuiCtrlCreatePic. Then I replace it with the correct image (which can be of different size, but must always be displayed with the same size in the GUI). for example: GUICtrlSetImage($Picture,"dummy_with_correct size.jpg") GUICtrlSetImage($Picture,$CorrectPicture) I think that if I make a new script from scratch I will try to figure out how to use only GDI, but for now this solution is just one extra line of code and works well :-)
  2. Hello, I have a large GUI window, on which I would like to display a smaller image at a certain position. The script used to work with GuiCtrlCreatePic and GUICtrlSetImage to update, but due to changes in AutoIt it no longer works, because the images scale incorrectly. So I've been trying to figure out how to get this done with GDI functions. All examples I have found so far turn an entire GUI into a placeholder for the image with _GDIPlus_GraphicsCreateFromHWND. So does anyone know if it is possible to assign a certain area of a GUI to display a picture, or a workaround to get the same result? My code is a bit messy at the moment, so I can't post my code at the moment, but will de later if necessary. Many thanks in advance!
  3. Hello all, Just wanted to say thank you again to all of you for your help! With your help I got everything working the way I want it :-)
  4. Just an update and to say thank you all!: I already have the check to determine if the .ini setting is a file or dir working and also the generation of a file list in case of a direcetory using the _FileListToArrayRec. Copying of files is also working and I also have a check so using system environment variables (e.g. %windir%) is also taken into account. Now all I have to do is add the check to copy only newer files, as in Rogue5099's example. But that's a job for tomorrow... :-)
  5. Thank you all for your help! I'll give it a try with '_FileListToArray' and try to implement a loop to include subfolders and let you know if it works or if I need more help :-).
  6. Hello, I would like to use dircopy in a script to copy a folder including all files and subfolders to another location, thereby only overwriting older files (to keep copying times to a minimum).The dircopy function unfortunately does not provide this option. Then I searched the forum and stumbled upon a FileCompare function to compare file attributes. So I thought of doing the copying by first getting a file list from each (sub)directory and then comparing each file to determine if the file should be copied or not. However, this seems complicated and I was hoping there is an easier way. I prefer not having to use windows shell commands like xcopy. (Note: The source and target folders are read from an .ini file.) Could anyone please help me out how to get this done or suggest a good approach at this? Many thanks in advance!
  7. Sorry, I didn't mean to hijack anyone's post, just thought the issue was related becasue I wanted to do this myself by comparing each file and dir, which is probably necessary to get what I want (?). Anyway, I'll start a new thread with my specific question.
  8. Hello, I would like to use dircopy in a script to copy a folder including all files and subfolders to another location, thereby only overwriting older files (to keep copying times to a minimum). (The source and target folders are read rom an .ini file) Could anyone please help me out how to get the done? Many thanks in advance!
  9. @Melba23 Thank you very much for the answer! This was starting to drive me mad ... ! Also thank you for the tips: 1) I have been playing with styles on the buttons and forgot to remove the $BS_FLAT. It shows them in '3D' style now, which is actually what I always wanted :-) Nevertheless I didn't know about what you wrote. 2) The '&' On the button is to set accelerator key, so it is correct the way it is. Best regards, Wouter
  10. Hello, I have a really weird problem with creating buttons on a GUI. I want to right align text on the edit buttons ($Editbutton[]), but somehow it's not working and the text is centered. When I create a test button outside of the for/next loop ($Testbutton), the button text is right aligned correctly!? Below is this section of the code. Does anyone have a clue what causes this behaviour? Many thanks in advance! $Testbutton = GUICtrlCreateButton("TEST", 0, 0 , 150, 30, $BS_RIGHT) For $file_count = 1 To $NumOfFiles - 2 Step 1 If $config_file[$file_count] <> "NotFound" Then $Editbutton[$file_count] = GUICtrlCreateButton($config_filevar[$file_count] & $config_file[$file_count], 40, 170 + (44 * ($file_count - 1)), 320, 30, $BS_RIGHT) GUICtrlSetTip(-1,$config_filevar[$file_count] & $config_file[$file_count]) GUICtrlSetBkColor(-1, $DefaultBackgroundColour) GUICtrlSetColor(-1, $DefaultTextColour) $Editbuttonindex[$file_count] = GUICtrlCreateButton("&" & $file_count, 10, 170 + (44 * ($file_count - 1)), 25, 30, $BS_FLAT) GUICtrlSetBkColor(-1, $DefaultBackgroundColour) GUICtrlSetColor(-1, $DefaultTextColour) EndIf Next
  11. @Ultima: That's what I tried but it doesn't work... @LarryDaLooza: I haven't tried the beta but I wil have a look at it.
  12. @Ultima: That would be quite complicated to program, because I want to be able to click any button I wish, but only when I press ENTER in the inputbox it should do the search (which is done by pressing the search button). Setting the focus back to the button after every other action in that GUI seems unnecessarily complicated... I have it like this: ; FUNCTION: Create a list GUI with the currently opened database Func CreateListview() ; Create the listview GUI CreateListViewGUI() ; GUI loop, active while Listview GUI is shown While 1 ; Exit through close button on GUI If $msg2[0] = $CloseListView Then GUIDelete($GUIListview) GUICtrlSetState($DatabaseMenu,$GUI_ENABLE) GUICtrlSetState($filemenu,$GUI_ENABLE) ;WinMove($HandleMain,"",$HandleMainCurrent[0],$HandleMainCurrent[1]) ExitLoop EndIf ; Pressed search button If $msg2[0] = $SearchButton Then GUICtrlSetState($SearchButton,$GUI_DISABLE) GUICtrlSetState($SearchButtonDown,$GUI_DISABLE) GUICtrlSetState($SearchButtonUp,$GUI_DISABLE) ; Clear all checkboxes For $r = 0 to $RowNumber-1 _GUICtrlListView_SetItemChecked($ListView,$r,0) Next ; Store the searchtext to remember the last entered searchtext if the listview has been closed and a new one opened $SearchText = GUICtrlRead($SearchInput) ; Clear all selected cells removeListViewIndexes($Listview) ; Perform the search SearchFunction($SearchText,1) ; Set book counter on main GUI and update it, but only if the search has a result If $FirstSearchResult <> -1 Then GUICtrlSetData($BookCounter,$FirstSearchResult+1) Update() GUICtrlSetState($SearchButtonDown,$GUI_ENABLE) GUICtrlSetState($SearchButtonUp,$GUI_ENABLE) EndIf GUICtrlSetState($SearchButton,$GUI_ENABLE) EndIf ; ; lines removed to keep it short ; ; Check if $SearchInput has focus and set Hotkey if so If ControlGetFocus($ListviewTitle) = "Edit1" Then HotKeySet("{Enter}", "CaptureEnter") Else HotKeySet("{Enter}") EndIf Wend EndFunc The "CaptureEnter" function simply performs the search, just like pressing the search button.
  13. Hello, I still couldn't get it to work with $GUI_DEFBUTTON and $GUI_FOCUS, but I added a check to the GUI loop if the inputbox was active or not. When it is active it sets a hotkey to "catch" the <ENTER> and when it's inactive it unsets the hotkey. Kind of stupid to have it in the loop, but I noticed no delays in the handling of GUI input and at least it works... Thank you all for your help!
  14. @-Ultima- Thank you for your suggestion, but unforatunately that didn't solve the problem. I'll try if I can 'catch pressing the <ENTER> key when the listview has focus and redirect it to the search button to see if that does the trick...
  15. Hello...again I've almost finished the first version of my database script for our book library. One annoying thing I can't get to work is the $BS_DEFPUSHBUTTON. I have a GUI with a listview, an inputbox to enter a text to search for, a search button and some other buttons. I want the search button to be "pressed" when I press <ENTER> in the inputbox, so I have set the search button to be the default push button. When I open the listview GUI window the inputbox is active and the search button is pressed when I press <ENTER>. So far so good. But after the first search, when I press <ENTER> in the inputbox, instead of "pressing" the search button, the characters in the listbox are selected except for the first one!? I just can't find what's wrong. BTW I have the search automatically select the found titles in the listview, the listview might have something to do with it. Since most likely anyone wanting to help out will need my source code I'll attach it for you. You must have Excel and W2K/XP (or Vista?) for the script to work and also the ExcelCOM UDF 1.4. Run the script and press the 'Listenansicht' button to get to the listview GUI with the inputbox and search button. The inputbox and button are $SearchInput and $SearchButton. I'm sorry I can't be more specific, because this time I don't have a clue where to look anymore... Many thanks in advance for any help! Database_TEST_zest.ZIP
  16. Thanks! Works great! Kind of weird though, to have to use such a trick for something so simple... (or is there a another way maybe?)
  17. Hello, In a database viewer I have made inputboxes in a GUI, which are filled out with text from an array (containing the database). The text in the inputbox is changed when selecting different data from the database. The text is often longer than the size of the inputbox What I want is the following : - Single line Inputbox - No scrollbars - Text is always left-aligned, so that the leftmost character is always visible - Text is scrollable, so that when the user has activated the editbox and scrolls to the right beyond the limits of the inputbox, the text scrolls to the left and into view - Text is read-only - Background colour is white I just can't get all of these to work at once Here's a snippet of my current code as example: #include <GuiConstants.au3> $MainGUI = GuiCreate("TEST", 400, 100) GuiSetState() ; Title label and inputbox $TitleInput=GUICtrlCreateInput("", 10, 30, 150, 20,bitor($SS_SUNKEN,$ES_READONLY,$ES_AUTOHSCROLL)) GUICtrlSetBkColor (-1, 0xFFFFFF) ;Example of setting the data in the inputbox which shifts the text to the left GUICtrlSetData($TitleInput,"This is a very long line with more text than fits into the inputbox") While 1 $msg = GUIGetMsg() ; Exit through close button If $msg = $GUI_EVENT_CLOSE Then Exit EndIf WEnd The only thing not working yet is gettting the text to be left-aligned every time the data in the inputbox is updated. How can this be done? Thanks in advance!
  18. Hello again, I found some time to test PsaltyDS' version with the Dutch Excel 2000, and as expected it also works with this version (as with the German Excel 2003 version). So you have my vote for implementing this change in the next version of ExcelCOM UDF (imagine smiley with thumbs up here). Edit: typo to stupid to even mention...
  19. Your version workswith the German version of Excel. I'll test it with the Dutch version as well, but it should work with that one too. Your code is also based on regeular expression replace very simililar to mine, except more sophisticated
  20. Hello, I've found the cause of the error and wrote some code which I think fixes the poroblem. Check it out here: http://www.autoitscript.com/forum/index.ph...mp;#entry491607
  21. Hello, I've changed te _ExcelReadSheetToArray function to make it work for all localized versions of Excel ... I hope ... Maybe the author of the ExcelCOM UDF can fix the function with this suggested code. This code works for me, but it's likely there are people with more knowledge who can code it in a more efficient way. Func _ExcelReadSheetToArray($oExcel, $iStartRow = 1, $iStartColumn = 1, $iRowCnt = 0, $iColCnt = 0) Local $avRET[1][2] = [[0, 0]]; 2D return array ; Test inputs If Not IsObj($oExcel) Then Return SetError(1, 0, 0) If $iStartRow < 1 Then Return SetError(2, 0, 0) If $iStartColumn < 1 Then Return SetError(2, 1, 0) If $iRowCnt < 0 Then Return SetError(3, 0, 0) If $iColCnt < 0 Then Return SetError(3, 1, 0) ; ------------ ; CHANGE START ; ------------ ; Get size of current sheet as R1C1 string ; Note: $xlCellTypeLastCell and $x1R1C1 are constants declared in ExcelCOM_UDF.au3 Local $sLastCell = $oExcel.Application.Selection.SpecialCells($xlCellTypeLastCell).Address(True, True, $xlR1C1) ; Extract integer last row and col ; 1) Determine length of string containing last cell in R1C1 format local $len = StringLen($sLastCell) ; 2) Replace the non-numeric characters with "-", to make it language independent $NumString=StringRegExpReplace($sLastCell,"\D","-") ; Loop to split the string containing last cell in R1C1 format into number for last row and number for last column ; start at 2nd character, because the 1st is always a letter For $iLastCellCount = 2 to $len If StringMid($NumString,$iLastCellCount,1) = "-" Then Local $iLastRow = Number(StringMid($sLastCell, 2, $iLastCellCount -2)) Local $iLastColumn = Number(StringMid($sLastCell, $iLastCellCount+1, $len-$iLastCellCount)) ExitLoop EndIf Next ; Return 0's if the sheet is blank If $iLastRow = 1 And $iLastColumn = 1 And $oExcel.Activesheet.Cells($iLastRow, $iLastColumn).Value = "" Then Return $avRET ; ------------ ; CHANGE END ; ------------ ; Check input range is in bounds If $iStartRow > $iLastRow Then Return SetError(2, 0, 0) If $iStartColumn > $iLastColumn Then Return SetError(2, 1, 0) If $iStartRow + $iRowCnt - 1 > $iLastRow Then Return SetError(3, 0, 0) If $iStartColumn + $iColCnt - 1 > $iLastColumn Then Return SetError(3, 1, 0) ; Check for defaulted counts If $iRowCnt = 0 Then $iRowCnt = $iLastRow - $iStartRow + 1 If $iColCnt = 0 Then $iColCnt = $iLastColumn - $iStartColumn + 1 ; Size the return array ReDim $avRET[$iRowCnt + 1][$iColCnt + 1] $avRET[0][0] = $iRowCnt $avRET[0][1] = $iColCnt ; Read data to array For $r = 1 To $iRowCnt For $c = 1 To $iColCnt $avRET[$r][$c] = $oExcel.Activesheet.Cells($iStartRow + $r - 1, $iStartColumn + $c - 1).Value Next Next ;Return data Return $avRET EndFunc ;==>_ExcelReadSheetToArray
  22. I just found out why the _ExcelReadSheetToArray doesn't work : It searches for "R" and "C" to determine the size of the sheet, but at work I use the German version of Excel, which uses "Z" and "S" for row (Zeile) and column (Spalte). At home I have a Dutch version of Excel, which also uses uses different letters. This is exactly the reason why I think all these kind of names/letters/functions in Office should ALWAYS be in English, regardless of which Language version the program itself is in .... Anyway, This could be solved e.g. by analyzing the String to determine the size of the sheet (e.g. R32C454) character by character for letters and numbers. This will provide the position of the 2 letters (in my example 1 and 4). Then it's easy to split the string into the two numbers between both letters (position 2-3) and after the last letter (position 5-end). That way it would work independent of which letter is used in the localised version of Excel. The check if the last sheet is blank also uses the "R1C1" ands should be changed.
  23. Hello, I'm having trouble with the _ExcelReadSheetToArray function. Somehow it gives me an error. I've posted it here: http://www.autoitscript.com/forum/index.ph...st&p=490035 I'm not sure if there is a bug in this function or in my brain.....? Can anybody help me out with this one please?
  24. First of all, thank you both very much for your help. I didn't notice in the Excel COM UDF there was a function to read the entire sheet. For some weird reason I can't get it to work though... Here is a piece af very simple code I tried to test the reading of the sheet with, but it gives me an Error 2 and Extended 1 with _ExcelReadSheetToArray. I have the Excel COM UDF v1.4 and I'm using Excel 2000. The test.xls file contains nothing but a few rondomly typed letters in the first 4 columns and first 4 rows. I'm sorry if this question is stupid, but what am I doing wrong here? #include <GuiConstants.au3> #include <File.au3> #include <Array.au3> #include <ExcelCOM_UDF.au3> $oExcel = _ExcelBookOpen(@ScriptDir & "\Database\test.xls",0,True) If @error Then MsgBox(0,"ERROR","Failed to open Excel book: " & $oExcel & @LF) EndIf $Database = _ExcelReadSheetToArray($oExcel) If @error Then MsgBox(0,"ERROR","Failed to read Excel sheet to array" & @CRLF & "ERROR: " & @error & @CRLF & "Extended: " & @extended) EndIf ;~ _ArrayDisplay($Database)
  25. Hello, I've made a script to read a book database from an Excel sheet. I have it determine the number of columns and rows in the sheet and read this into a 2D array. The Database has about 450 rows (books). The loop which reads the data row by row into an array is very slow (about 13 seconds on my Athlon 64 3200+). I'd really appreciate any help on how to get this faster. I've posted the relevant part of the code here, where I have marked the slow part: ;Declare global database array with maximum size Global $Database[5000][30] ;Declare global (empty) array to overwrite the database with when it must be emptied Global $DatabaseClean[5000][30] ;Declare global number of books in database Global $NumOfBooks = 0 ;Declare global counters for number of data columns and rows found in the Excel sheet Global $ColNumber = 1 Global $RowNumber = 1 Func OpenDatabase() SplashTextOn("Öffnen der Datenbank", @CRLF & "Die Datenbank wird geöffnet." & @CRLF & "Der Ladevorgang kann einige Zeit in Anspruch nehmen...",500,70,-1,-1,0,"",10,400) ;reset book counter GUICtrlSetData($BookCounter,1) ;reset database $Database=$DatabaseClean ;reset number of books $NumOfBooks = 0 $oExcel = _ExcelBookOpen(@ScriptDir & "\Database\Literaturkatalog.xls",0,True) If @error Then ConsoleWrite("Debug: Failed to open Excel book: " & $oExcel & @LF) EndIf ;Activate selected sheet for opening (=selected database) _ExcelSheetActivate($oExcel, $DBCounter) ;--------------------------------------- ;read in database array from first sheet ;--------------------------------------- ;determine number of columns $ColNotEmpty = 1 $ColNumber = 1 While $ColNotEmpty = 1 $ExcelColArray = _ExcelReadArray($oExcel,1,$ColNumber,1,0,0) ;_ArrayDisplay($ExcelColArray, "TEST") If $ExcelColArray[0] = "" Then $ColNotEmpty = 0 EndIf $ColNumber = $ColNumber + 1 WEnd $ColNumber = $ColNumber - 1 ;Number of columns with data is $ColNumber-1, because the first columns is empty! ;MsgBox(0,"Number of columns", "Number of columns: "& $ColNumber & @CRLF & "Number of columns with data: " & $ColNumber-1) ;Read in rows until first cell is empty $RowNotEmpty = 1 $RowNumber = 1 ; -------------------------------- ; THIS PART IS VERY SLOW ; -------------------------------- While $RowNotEmpty = 1 $ExcelArray = _ExcelReadArray($oExcel,$RowNumber,1,$ColNumber-1,0,1) For $n = 1 to $ColNumber-1 $Database[$RowNumber][$n] = $ExcelArray[$n] Next If $Database[$RowNumber][1] = "" Then $RowNotEmpty = 0 EndIf $RowNumber = $RowNumber + 1 WEnd ; -------------------------------- ; THIS IS THE END OF THE VERY SLOW PART ; -------------------------------- $RowNumber = $RowNumber - 1 ReDim $Database[$RowNumber][$ColNumber] $NumOfBooks = $RowNumber-2 ;MsgBox(0,"$NumOfBooks", $NumOfBooks) _ExcelBookClose($oExcel) ;_ArrayDisplay($Database, "Read Array from Excel sheet") StripDatabase() Update() SplashOff() EndFunc
×
×
  • Create New...