Jump to content

footswitch

Active Members
  • Posts

    203
  • Joined

  • Last visited

Everything posted by footswitch

  1. No, not the main loop! I meant the SQLite Query that I need to call when I click a row takes some time to return its result It's a fairly big database with tens of thousands of rows. Loads of compound queries, table joins and conditions. But that's a whole 'nother matter Got it, as fast as possible. Thanks a lot, you guys are the best [place "praise" emoticon here]
  2. Oh! I believe you guys have a point there. Didn't remember to take a look at GUIRegisterMsg() in the helpfile. My bad. Nevertheless, I was actually using _ArrayDisplay() for debugging So, you'd say it's best (a.k.a. safest) to use flags and look for them in the main loop, rather thank including the control update functions and SQLite Queries inside the callback function, right? Because at times that could take a second or two. Thank you kindly for your advice. footswitch
  3. Hi there, I'm building a script where I have a GUI with a ListView in it (created using _GUICtrlListView_Create()). I also need to know which row a user clicks in the ListView, so I can update a series of GUI controls with information regarding that row. So I registered the WM_NOTIFY callback function after creating the ListView: GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY"). It would seem to me that whatever I need to do when a row is clicked - either get row information or set other controls - would have to be coded inside WM_NOTIFY. But while I was experimenting with it, it happened that calling _ArrayDisplay() inside WM_NOTIFY causes the script to freeze. I'd be grateful for your input as to what would be the correct approach to the callback function: - Is it safe to call other functions from within WM_NOTIFY? (apart from some exceptions such as _ArrayDisplay?) - Or should I be using a different approach? Thanks in advance, footswitch
  4. @M23 Come to think about it, you're probably right. I have functions inside other include files, and these functions create child GUIs. Evidently I need to pass the parent GUI's handle as a parameter. So if I'm thinking straight, if I turn my child GUI's creations and deletions into their own functions, it won't be that "noisy" to include those lines inside of them. Thank you for making me think Sometimes that's all we need, right? footswitch
  5. Hello, Not trying to get out of line here, but would there be a way a child GUI could act the same way as an InputBox, MsgBox or FileOpenDialog? When these functions are called with the parent GUI parameter defined, they do "block" the parent GUI; that would be the exact behavior I'd be looking for: $GUI_parent=GUICreate("",500,400) GUISetState() InputBox("","As you can see, clicking the parent GUI isn't possible until you close this child window.","","",-1,-1,200,200,0,$GUI_parent) If I have to use GUI_DISABLE and GUI_ENABLE, this will add a whole lot of "noise" to the script. So I was wondering if there is another way... any ideas? Regards, footswitch
  6. Well I've tried "Friso" as well, but doesn't work either. If it works for you and not for me I have to accept that this method wouldn't be reliable anyway. Nevertheless, thanks again for your help. Regards, footswitch
  7. @JoHanatCent Thanks for your reply. Yes, it's almost off-topic. Sorry about that. Please tell me, did you try this code yourself? With it, Excel 2007 returns this error (translated from Portuguese): "there's an error with your formula (...)". In fact, before messing around with Macro files, I've tried several variations of that command, all to no avail. The Macro Import method really seems to be the closest to success - in such a way that it works fine when called from Excel itself, but doesn't when called via COM. footswitch
  8. Hey guys. This got me very close to what I'm trying to do here. I want to hide the Ribbon (Office 2007), kind of full screen mode, so all I'd have would be the Excel cell grid. I suppose this would allow me to integrate an Excel grid in an AutoIt GUI. This is what I use: Application.ExecuteExcel4Macro "SHOW.TOOLBAR(""Ribbon"",False)" However, passing this action to the Excel object produces no changes. Importing and then running the Macro (as shown in the post above) returns an error. After the error, when I choose to debug, if I stop and rerun that macro, the Ribbon becomes hidden successfully. Any thoughts? Thanks in advance for your time, footswitch
  9. Hey there. Updated code: #include <WindowsConstants.au3> $FileName = @ScriptDir&'\book1.xlsx' If Not FileExists($FileName) Then MsgBox(0, "ERROR", "File not found") Exit EndIf ;Basic GUI $oExcelDoc = ObjGet($FileName); Get an excel Object from an existing filename If IsObj($oExcelDoc) Then $mainGUI = GUICreate("viewer", @DesktopWidth - 50, @DesktopHeight - 150, 10, 10, $WS_MINIMIZEBOX +$WS_SYSMENU + $WS_CLIPCHILDREN) $GUI_ActiveX = GUICtrlCreateObj($oExcelDoc, 10, 70, @DesktopWidth - 75, @DesktopHeight - 260) Else MsgBox(0,"","failed") EndIf ;------------------ ;Turns off all command bars in excel to prevent user from making changes For $Bar In $oExcelDoc.CommandBars If $Bar.Enabled = True Then $Bar.Enabled = False If $Bar.Visible = True Then $Bar.Visible = False Next $oExcelDoc.Application.DisplayFormulaBar = False $oExcelDoc.Application.CommandBars("Shadow Settings").Visible = False $oExcelDoc.Application.DisplayScrollBars = True $oExcelDoc.Application.DisplayStatusBar = False GUISetState() While 1 Sleep(500) WEnd Any hints as to make this work without the toolbars and so forth? Just the cells... Regards, footswitch
  10. Hi there, The _ExcelReadSheetToArray() function is quite slow. This is most probably due to the fact that it reads and stores information on a cell by cell basis. A while back I found this line of code that allowed me to read a whole sheet (used range) to an array: $array_output = $oExcel.transpose($oExcel.ActiveSheet.UsedRange.Value) This method can be around 150 to 200 times faster than the built-in UDF function (give or take, it's not easy to perform a proper measure, given the variables involved and the huge difference observed). Nonetheless, either one of them are "dangerous" to use if you are actually considering reading the entire sheet at once. Let's say your sheet has 90.000 rows and 55 columns. We can easily be talking about 350 MB of memory, if not more, just to temporarily store this data into an array. I never had this problem before, I was dealing with a maximum of 6.000 rows at a time (the purpose of my script is to load "chunks" of data into a SQLite database). But the need eventually came, and due to the size of some sheets I can't deal with UsedRange anymore. So here's the solution: Based on the same faster method, load x rows at a time until we reach the end of the used range. $oExcel=_ExcelBookOpen("file") $timer_global=TimerInit() ; this will measure how long it takes to read the entire used range in the sheet $aExcelUsedRange=__ExcelGetUsedRange($oExcel) If Not IsArray($aExcelUsedRange) Then ConsoleWrite("-> Excel file is empty"&@CRLF) Exit EndIf ConsoleWrite("-> "&$aExcelUsedRange[0]&" rows and "&$aExcelUsedRange[1]&" columns."&@CRLF) $sExpression="" $timer_cycle=TimerInit(); this will measure how long it takes to read each chunk of data $iStep=1000 ; get 1000 rows at a time For $r=1 To $aExcelUsedRange[0] Step $iStep+1 If $r+$iStep>$aExcelUsedRange[0] Then $iStep=$aExcelUsedRange[0]-$r $sExpression="$oExcel.transpose(.Range(.Cells("&$r&",1),.Cells("&$r+$iStep&","&$aExcelUsedRange[1]&")).Value)" With $oExcel.Activesheet $array_output=Execute($sExpression) EndWith ; place your actions here, for each chunk of data loaded ConsoleWrite("> Loading "&$iStep&" rows took "&Int(TimerDiff($timer_cycle))&" ms (row "&$r&" to "&$r+$iStep&")"&@CRLF) $timer_cycle=TimerInit() Next ConsoleWrite("-> Finalized in "&Int(TimerDiff($timer_global))&" ms."&@CRLF) _ExcelBookClose($oExcel,0,0) ; close file without saving and without alerts Exit The following function was inspired on the Excel UDF (a nice way of saying copied from) Func __ExcelGetUsedRange(ByRef $oExcel) ; Get size of current sheet as R1C1 string ; -4150 specifies that the address is returned in R1C1 string format ; SpecialCells(11) refers to the last used cell in the active worksheet Local $sLastCell = $oExcel.Application.Selection.SpecialCells(11).Address(True, True, -4150) ; Extract integer last row and col $sLastCell = StringRegExp($sLastCell, "\A[^0-9]*(\d+)[^0-9]*(\d+)\Z", 3) Local $iLastRow = $sLastCell[0] Local $iLastColumn = $sLastCell[1] ; Return 0 if the sheet is blank If $sLastCell = "R1C1" And $oExcel.Activesheet.Cells($iLastRow, $iLastColumn).Value = "" Then Return 0 EndIf Dim $aUsedRange[2] $aUsedRange[0]=$sLastCell[0] $aUsedRange[1]=$sLastCell[1] Return $aUsedRange EndFunc May it be useful to you someday as it is for me now Probably worth to take a look at and who knows at some point update the Excel UDF. (I hope I'm not missing something seriously huge in respect to data integrity) footswitch
  11. I guess you're right, @ComSpec could change the results. "your mileage may vary" It's not like I can't live without queuing, but over time I'm thinking of implementing it myself If xyz_Sem exists, find all folders named xyz_Sem_*, get the last folder number and create xyz_Sem_n+1, where n is the Queue order. Something like that. But I'm predicting some issues here: There's already a timeout condition for the current semaphores. Now when you have lots of Queues and you don't know whether they will succeed or not, you could be placing a huge delay in database response time.
  12. You are absolutely right, I just tested it under Windows 7 x64 and it did work. but the script didn't.So I retested the script and the path wasn't an issue after all, it was the mkdir call all along. As I mentioned earlier, for 64-bit compatibility: Local $iResult = RunWait(@ComSpec & " /c " & 'mkdir "' & $sCFS_Semaphore & '"', @TempDir, @SW_HIDE) Probably this compatibility issue is related to the command tools' location not being mapped to the PATH environment variable. But this fixes it. Turns out it was my fault that I didn't test for UNC support after adjusting that single line of code. Sorry about that. Wow, didn't realise there was so much study involved in it. That's... something Okay, that's a fair assumption Next step: File Locking with Cooperative Queuing Semaphores
  13. Really? Because as far as I know, the command line doesn't support UNCs. I could be wrong. About the authentication, yes, it's kind of obvious, but once you start working directly with UNCs you run the risk of needing to authenticate on-the-fly, and this script wouldn't allow that also. So... does mkdir work flawlessly? I mean, does mkdir really return an error upon creating an existing folder, even when it "thinks" it doesn't exist? Let me give you an example, based on the way that I THINK mkdir works: - mkdir checks for the directory to exist a) if it exists, return error if it doesn't exist, create it and return successfully - now, at this time, imagine another instance of mkdir is doing the exact same thing, but some miliseconds earlier. Question is: does mkdir check for the successful CREATION of the folder or, in the other hand, successful ISSUING of that command? So as you can see I'm worried about a racing event which could happen or not depending on the way mkdir works. footswitch
  14. Thanks for posting your idea, I'll definitely give it a try [EDIT] First remarks: - You need to have the desired network path mapped with a drive letter (you also need to be authenticated to that path, but mapping rules out this requirement). Second remarks: - I believe it works as advertised! Only suggestion is that you change the following in CFS.au3 From this: Local $iResult = RunWait('mkdir "' ......... To this: Local $iResult = RunWait(@ComSpec & " /c " &'mkdir "' ............ The first option doesn't work under Windows 7 64-bit Cheers, footswitch
  15. Sorry for the late reply, but AFAIK you can't "kill" the power from an USB port: it's electrically wired to the power supply. footswitch
  16. This is good stuff. I added a link in Computer Info UDF's by JSThePatriot
  17. Thank you for this great UDF For my case I needed an additional specification. I'm posting my code here since it makes sense in the given context. EDIT: I can't believe I didn't find this before... Drive Info UDFs by NerdFencer If you want to get the physical drives' sizes (Hard Drives, Hard Disks): ; ############### ; HARD DRIVE SIZES ; ############### $objWMIService = ObjGet("winmgmts:\\"&@ComputerName&"\root\cimv2") $colHardDisk = $objWMIService.ExecQuery("select Size from Win32_DiskDrive where MediaType='Fixed hard disk media' or MediaType='Fixed hard disk'") ; 'Fixed hard disk media' --> WinVista+ ; 'Fixed hard disk' --> NT4...XP $sHardDrives="" For $objHardDisk in $colHardDisk $sHardDrives&=Floor($objHardDisk.Size / (1000^3))&"+" Next $sHardDrives=StringTrimRight($sHardDrives,1)&" GB" ConsoleWrite("-> Hard Drive(s): "&$sHardDrives&@CRLF)Tested under Windows 7 32-bit. Should work on NT4+, as specified. Not sure about 64-bit editions, though (Win32_...?). footswitch
  18. @Mat, I like what you did. But then there's the whole HTML enchilada: lots of conditional arguments which I believe would really mess up the code. Nested StringRegExps are precise, easy to understand, easy to tune-up and acceptably efficient. Fighting for the best way of reinventing the wheel, are we? EDIT: typo
  19. Yeah, like _StringRegExpNested ( ByRef $aPatterns ) ; with a virtually unlimited number of nested RegExps Just to think about the combinations of Flags, Return values and Error values... what a mess it would be EDIT: typo
  20. $html="<select name='list_ck[]' size=""10"" multiple=""multiple"" style='width:250px'>"&@CRLF& _ "<option value='jsmith'>John Smith</option><option value='esmith'>Eddie Smith</option> </select>" $array1=StringRegExp ($html, "(?s)(?i)<select name='list_ck(.+?)</select>",3) ; sets flag "(?s)", which means: "." matches any character including newline ; sets flag "(?i)", which means: case insensitive If @error==1 Then ConsoleWrite("-> No matches for first RegExp!"&@CRLF) _ArrayDisplay($array1) ; joins all the results in a single string: $string="" For $i=0 To UBound($array1)-1 $string&=$array1[$i] Next $array2=StringRegExp ($string, "(?s)(?i)<option value='.+?'>(.+?)</option>",3) If @error==1 Then ConsoleWrite("-> No matches for second RegExp!"&@CRLF) _ArrayDisplay($array2) EDIT: my browser is going nuts
  21. Take a look here
  22. Okay, I get your point. I never know what I can find inside a <script> tag. In my case, it contains several lines of code. Among that code, function('random_text') might appear, often more than once. I believe this would be a good test string: $html="<html>(...)"&@CRLF& _ " this is a function('that i dont want in the output because its outside of the script tags');"&@CRLF& _ "<script javascript>"&@CRLF& _ "few lines of code here"&@CRLF& _ "few lines of code here"&@CRLF& _ "more code and then function('FIRST TAG testing one enter"&@CRLF& _ "two and thr33.'); and etc."&@CRLF& _ "this will continue through the ages"&@CRLF& _ "and possibly there's a second function('FIRST TAG with mor3 alphanumeric chars here')"&@CRLF& _ "; and now here it is a {function('i dont want to catch this one because it starts with {');}"&@CRLF& _ "few lines of code here"&@CRLF& _ "few lines of code here"&@CRLF& _ "and finally</script>(...)"&@CRLF& _ "remember that this {function('also cant be present in the output because its outside of the script tags');(...)</html>"&@CRLF& _ "<html>(...)"&@CRLF& _ " this is a function('that i dont want in the output because its outside of the script tags');"&@CRLF& _ "<script javascript>"&@CRLF& _ "few lines of code here"&@CRLF& _ "few lines of code here"&@CRLF& _ "more code and then function('SECOND TAG testing one enter"&@CRLF& _ "two and thr33.'); and etc."&@CRLF& _ "this will continue through the ages"&@CRLF& _ "and possibly there's a second function('SECOND TAG with mor3 alphanumeric chars here')"&@CRLF& _ "; and now here it is a {function('i dont want to catch this one because it starts with {');}"&@CRLF& _ "few lines of code here"&@CRLF& _ "few lines of code here"&@CRLF& _ "and finally</script>(...)"&@CRLF& _ "remember that this {function('also cant be present in the output because its outside of the script tags');(...)</html>" From this, i only want this output: (array) 0|FIRST TAG testing one entertwo and thr33. 1|FIRST TAG with mor3 alphanumeric chars here 2|SECOND TAG testing one entertwo and thr33. 3|SECOND TAG with mor3 alphanumeric chars here The script that I posted earlier today (one RegExp over another) performs this operation successfully: 1. Get everything inside <script> tags 2. Get everything inside function(''), as long as function doesn't have a preceding {
  23. Thank you for your feedback. I eventually ended up doing this with two steps last night. Not that it came to me at first. Sorry for not posting on time. Anyway, would be interesting to see a way of doing this in just one step, if such thing is possible. The test string provided is all we need. I need all the functions() inside <script ... </script>, as long as they don't have a preceding "{". So, in this case, my output should be: function('22') function('33') function('55') function('66') @Ascend4nt, the lack of the ">" is just my natural lazyness, because of the many possible scenarios like <script>, <script javascript>, <script something>... @GMK, I believe I do NOT need a "?" after "[^\{]", because I actually want to exclude these scenarios. These are the lines I'm currently using: $array1=StringRegExp ($html, "(?s)(?i)<script(.+?)</SCRIPT>",3) ; next we combine the matches all together: $string="" For $i=0 To UBound($array1)-1 $string&=$array1[$i] Next $array2=StringRegExp ($string, "(?s)(?i)[^\{]function\('(.*?)'\)",3)
  24. Welcome to the forum, vins! Use the application supplied with the AutoIt installation, AutoIt Window Info. Click the "Control" tab. Press Ctrl+Alt+F to unlock/lock the application. Then click in the install window to activate it (give it focus). Move your mouse over the checkbox and note down the "ID" number. Create a new script and use this as a starting point: WinActivate("Date and Time") ControlClick("Date and Time","",351) On Windows 7, if you open the Date and Time settings, this will activate the window and click "Show this clock" (Control ID 351) in the Tab "additional clocks". Good luck! footswitch
  25. Hello there, I need to get all the "function('random_string')" INSIDE the <script></script> tags and WITHOUT the "{" character. So I'm trying to accomplish something in between of these two: #include <array.au3> $html="{function('00')--<script--{function('11')--function('22')--function('33')--</script>--<script--{function('44')--function('55')--function('66')--</script>--function('77')" $array1=StringRegExp ($html, "(?s)(?i)<script.+function\('(.*?)'\).+</SCRIPT>",3) If @error==1 Then ConsoleWrite("-> No matches for first RegExp!"&@CRLF) ; RegExp explained: ; sets flag "(?s)", which means: "." matches any character including newline ; sets flag "(?i)", which means: case insensitive ; looks for "<script", then a bunch of text must be present - ".+" - until it finds the last occurrence of "function('random string here')" - why only the last occurrence? ; then another bunch of text must be present and finally "</SCRIPT>" needs to appear after it all _ArrayDisplay($array1) $array2=StringRegExp ($html, "(?s)(?i)[^\{]function\('(.*?)'\)",3) If @error==1 Then ConsoleWrite("-> No matches for second RegExp!"&@CRLF) ; RegExp explained: ; find every occurrence of "function('random string here')" that doesn't have a preceding "{" _ArrayDisplay($array2) I'm not quite the RegExp Guru Any thoughts? Thanks, footswitch
×
×
  • Create New...