Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 06/01/2015 in all areas

  1. jchd

    SQLITE progress handler

    Forgot to answer that: no you can't issue any SQL statement but feel free to open another connection to keep on working. If you do use two or more concurrent connections to the same DB (in the same or different processes, that doesn't matter) switch to WAL mode. To do that, issue ONCE (the setting is persistent) the following statement when no other connection is active: _SQLite_Exec($hDB, "pragma journal_mode = WAL"). WAL mode allows one writer and multiple readers concurrently. Also right after each connection (every time, setting is connection-wide), issue the following: _SQLite_Exec($hDB, "pragma busy_timeout = 30000") This makes the timeout reach 5 minutes, don't ask, it's OK. Now when you have a read-modify-write operation, wrap it in an immediate transaction (begin immediate; ... end;).
    2 points
  2. When ever you hover your mouse over a native function, user defined function, or an AutoItObject method then you will see the calltip for that function. Click "Like This" if you found this useful! To use this just place the following lua file in the "...AutoIt3\SciTE\lua" directory. MouseHoverCallTips.zip downloads:741 After you have done that then open SciTE and click 'Options' --> 'Open Lua Startup Script' and paste this line after the other lines (may require administrative rights): LoadLuaFile("MouseHoverCallTips.lua") Updates and changes:
    1 point
  3. Following to my Image Crop Tool, this is a new function to visually apply effects on an image Version 1.0.0.1 Visual Image Effect UDF 1.0.0.1.au3 Features: Brightness/ContrastHue/Saturation/LightnessBlurColor Balance (RGB)Levels (HMS)SharpenTintUndo (New)Similarly to _CropImage(), _ImageEffects(() will scale the image down to get it visible on screen, all effects are implemented and stacked into an Effects History array, and replicated to the original image while saving. Clicking the OK button after having moved the sliders, implements the filter! Some particularities: Blur and Sharpen effects give different results with the same radius, this issue has been taken into account. The maximum radius of 255 will therefore be limited if using a scaled image, so that the final effect is guaranteed the same on screen as on the bigger sized image file. (see $h_Blur_Btn and $h_Sharpen_Btn and in _SaveLossless() how I rescale the Radius to get it right in the big image) The function saves to images for demo purpose _SaveClone() will save the image displayed into the GUI (You can remove this line as only for demo purpose)_SaveLossless() will save the original sized image with all applied effectsYou will see that the result is identical on both created image files. BugFixes: After applying a filter, I forgot to reset the filter values, fixedEnjoy PS as from tomorrow, I will be offline for a week... Related:
    1 point
  4. ​1) For now, I'm using Photoshop keystokes (including Ctrl+Shift+Alt+...). But, there will be the possibility to change them. 2) I will make the directory you mentioned, but (for now) I'll stay with the current structure. When I'll start bugfixing and general cleaning, I'll deal with UDFs.
    1 point
  5. Khryus, The image you posted is just a simple progress bar with elapsed and total times displayed in labels at each end. As to adjusting the playing point, in the music player I wrote and use all the time I look for a click on the progress bar and then display a slider to allow me to move around within the song. Give me a while and I will try and come up with something which shows how I went about it. M23
    1 point
  6. MikahS

    automatic login site

    This works for me: #include <IE.au3> Local $oIE, $username, $password, $oSubmit $oIE = _IECreate("http://www.atixo.de/") $username = _IEGetObjById($oIE, "infoBarLoginName") _IEFormElementSetValue($username, "demade") $password = _IEGetObjById($oIE, "infoBarLoginPassword") _IEFormElementSetValue($password, "demande") $oSubmit = _IEGetObjById($oIE, "infoBarLoginButton") _IEAction($oSubmit, "click")All good?
    1 point
  7. I created this simple function to retrieve any web page. You can then do whatever you want with the data after that (write it to a file, etc...). Let me know if you have any questions. Func _HTTP_ResponseText($URL) $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") $oHTTP.Open("GET", $URL) $oHTTP.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10 (.NET CLR 4.0.20506)") $oHTTP.Send() return $oHTTP.ResponseText EndFunc
    1 point
  8. #include <SQLite.au3> #include <SQLite.dll.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= Local $Form = GUICreate("My app.", 325, 72, 280, 138) Global $Label1 = GUICtrlCreateLabel("Label1", 15, 10, 296, 17, $SS_CENTER) Local $Button1 = GUICtrlCreateButton("Button1", 15, 35, 75, 25) Local $Button2 = GUICtrlCreateButton("Button2", 230, 35, 75, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Local $hQuery, $aRow Global $sec = @SEC _SQLite_Startup() ConsoleWrite("_SQLite_LibVersion=" & _SQLite_LibVersion() & @CRLF) _SQLite_Open() ; Without $sCallback it's a resultless statement _SQLite_Exec(-1, "Create table tblTest (a,b int,c single not null);") Local $makeALoopXTimes = 100 For $n = 1 To $makeALoopXTimes ;Sleep( 150 ) If $sec <> @SEC Then $sec = @SEC GUICtrlSetData( $Label1 , $n &' of '&$makeALoopXTimes) GUIGetMsg() ; <---- this is what i mean EndIf _SQLite_Exec(-1, "Insert into tblTest values ('string "&$n&"',"&$n&","&($n*2)&");") Next GUICtrlSetData( $Label1 , $makeALoopXTimes &' of '&$makeALoopXTimes) ;------------------------------------------------- Local $d = _SQLite_Exec(-1, "Select rowid,* From tblTest", "_cb") ; _cb will be called for each row Func _cb($aRow) For $s In $aRow If $sec <> @SEC Then $sec = @SEC GUIGetMsg() ; <---- this is what i mean EndIf ConsoleWrite($s & @TAB) Next ConsoleWrite(@CRLF) ; Return $SQLITE_ABORT ; Would Abort the process and trigger an @error in _SQLite_Exec() EndFunc ;==>_cb _SQLite_Close() _SQLite_Shutdown() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd this is what I mean
    1 point
  9. For the OP question : $sScriptName = @Compiled ? @ScriptName : StringRegExpReplace(@AutoItExe, ".+\\", "") While 1 $aList = ProcessList($sScriptName) If $aList[0][0] = 1 Then ExitLoop For $i = 1 To $aList[0][0] If $aList[$i][1] <> @AutoItPID Then ProcessClose($aList[$i][1]) Next WEndAn alternative to _Singleton based on the program name : $sScriptName = @Compiled ? @ScriptName : StringRegExpReplace(@AutoItExe, ".+\\", "") If UBound(ProcessList($sScriptName)) > 2 Then Exit
    1 point
  10. @czardas Congratulations on your 7,800th post The best thing to do when you need to ReDim an array is: TD
    1 point
  11. Glad to be of service
    1 point
  12. Well, I never intended to start a flame war about this. But at this rate, why not allocate at once the maximum size head first and finally ReDim it to truncate to the actual used size? Only if you started at a power of 2. Why so? Min() can do that. Anyway, things aren't that simple when the array has more than one dimension.
    1 point
  13. Just use _SingleScript() function: #include <_SingleScript.au3> _SingleScript() MsgBox(Default, Default, "No other script with name " & StringTrimRight(@ScriptName, 4) & " is executing any more.", 0) _SingleScript.au3 include file: #include-once ;============================================================================================================== ; UDF Name: _SingleScript.au3 ; Description: iMode=0 Close all executing scripts with the same name and continue. ; iMode=1 Wait for completion of predecessor scripts with the same name. ; iMode=2 Exit if other scripts with the same name are executing. ; iMode=3 Test, if other scripts with the same name are executing. ; ; Syntax: _SingleScript([iMode=0]) ; Default: iMode=0 ; Parameter(s): iMode: 0/1/2/3 see above ; Requirement(s): none ; Return Value(s): -1= error @error=-1 invalid iMode ; 0= no other script executing @error=0 @extended=0 ; 1= other script executing @error=0 @extended=1 (only iMode=3) ; Example: ; #include <_SingleScript.au3> ; _SingleScript() ; Close mode ( iMode defaults to 0 ) ; MsgBox(Default, Default, "No other script with name " & StringTrimRight(@ScriptName, 4) & " is executing.", 0) ; ; see other example at end of this UDF ; ; Author: Exit ( http://www.autoitscript.com/forum/user/45639-exit ) ; COPYLEFT: © 2013 Freeware by "Exit" ; ALL WRONGS RESERVED ;============================================================================================================== Func _SingleScript($iMode = 0) Local $oWMI, $oProcess, $oProcesses, $aHandle, $aError, $sMutexName = "_SingleScript " & StringTrimRight(@ScriptName, 4) If $iMode < 0 Or $iMode > 3 Then Return SetError(-1, -1, -1) If $iMode = 0 Or $iMode = 3 Then ; (iMode = 0) close all other scripts with the same name. (iMode = 3) check, if others are running. $oWMI = ObjGet("winmgmts:\\" & @ComputerName & "\root\CIMV2") If @error Then RunWait(@ComSpec & ' /c net start winmgmt ', '', @SW_HIDE) RunWait(@ComSpec & ' /c net continue winmgmt ', '', @SW_HIDE) $oWMI = ObjGet("winmgmts:\\" & @ComputerName & "\root\CIMV2") EndIf $oProcesses = $oWMI.ExecQuery("SELECT * FROM Win32_Process", "WQL", 0x30) For $oProcess In $oProcesses If $oProcess.ProcessId = @AutoItPID Then ContinueLoop If Not ($oProcess.Name = StringTrimRight(@ScriptName, 4) & ".EXE" Or ($oProcess.Name = "AutoIt3.exe" And StringInStr($oProcess.CommandLine, StringTrimRight(@ScriptName, 4) & ".au3"))) Then ContinueLoop If $iMode = 3 Then Return SetError(0, 1, 1) ; indicate other script is running. Return value and @extended set to 1. If ProcessClose($oProcess.ProcessId) Then ContinueLoop MsgBox(262144, "Debug " & @ScriptName, "Error: " & @error & " Extended: " & @extended & @LF & "Processclose error: " & $oProcess.Name & @LF & "******", 0) Next Sleep(100) ; allow process to terminate EndIf $aHandle = DllCall("kernel32.dll", "handle", "CreateMutexW", "struct*", 0, "bool", 1, "wstr", $sMutexName) ; try to create Mutex $aError = DllCall("kernel32.dll", "dword", "GetLastError") ; retrieve last error If Not $aError[0] Then Return SetError(0, 0, 0) If $iMode = "2" Then Exit 1 If $iMode = "0" Then Return SetError(1, 0, 1) ; should not occur DllCall("kernel32.dll", "dword", "WaitForSingleObject", "handle", $aHandle[0], "dword", -1) ; infinite wait for lock Return SetError(0, 0, 0) EndFunc ;==>_SingleScript #comments-start Here is the other example. Uncomment and use TIDY to reformat. #include <_SingleScript.au3> If $cmdline[0] = 0 Then ; submit all scripts TraySetToolTip("No Case") _SingleScript() ; Kill other scripts, if others are executing For $i = 0 To 7 Sleep(100) ShellExecute(@ScriptFullPath, $i) Next Exit MsgBox(64 + 262144, Default, "All scripts submitted. See icons in system tray. Case 1 already disappeared.", 0) EndIf TraySetToolTip("Case " & $cmdline[1]) Switch $cmdline[1] Case 0 $rc = _SingleScript(3) ; Check, if others are executing MsgBox(64 + 262144, Default, "Case " & $cmdline[1] & " executing. " & ($rc ? "Some" : "No") & " other scripts executing.", 0) Case 1 _SingleScript(2) ; Kill this scropt, if others are executing Beep(440, 3000) ; you will NOT hear the long beep. Case 2, 3, 4, 6, 7 _SingleScript(1) ; Wait for predecessors completed MsgBox(64 + 262144, Default, "Case " & $cmdline[1] & " executing.", 0) Case 5 _SingleScript(1) ; Wait for predecessors completed (case 1-4) MsgBox(64 + 262144, Default, "Case " & $cmdline[1] & " executing." & @CRLF & "Now killing other scripts. See icons in system tray.", 0) _SingleScript() ; Now kill other scripts. Should be case 6 and 7 _SingleScript(3) ; Check, if others are executing MsgBox(64 + 262144, Default, "Case " & $cmdline[1] & " executing. " & (@extended ? "Some" : "No") & " other scripts executing.", 0) EndSwitch #comments-end
    1 point
  14. TD, until you do not have a rough estimate about how many elements the array will hold at maximum, it is useless to discuss if factor 1.5 or 2 or increasing the size by a fixed number best fits your needs. Until you do not know how important performance is for the problem you try to solve it is useless to ... First goes the planning, then the coding!
    1 point
  15. This code returns true for your example workbook: #include <Excel.au3> #include <File.au3> Global $sFile = "C:\temp\Huis-3D-Excel-Pendulum_97.xls" $oExcel = _Excel_Open() $oWorkbook = _Excel_BookOpen($oExcel, $sFile) ConsoleWrite("Workbook has macros: " & _CheckMacros($oWorkbook, $sFile) & @CRLF) ; Code taken from http://www.siddharthrout.com/2012/04/12/check-if-an-excel-file-has-a-macro/ Func _CheckMacros($oWorkbook, $sFilepath) Local $sCode, $sFiletype, $sDrive, $sDir, $sFilename, $sExtension _PathSplit($sFilepath, $sDrive, $sDir, $sFilename, $sExtension) Switch StringMid($sExtension, 2) ; Excel files which can have a macro Case "XLS", "XLSM", "XLTM", "XLT", "XLA", "XLSB", "XLAM" With $oWorkbook.VBProject ; Components are like sheet1, thisworkbook, module etc. If .VBComponents.Count > 0 Then For $i = 1 To .VBComponents.Count ; Get the entire code in the module $sCode = .VBComponents.Item($i).CodeModule.Lines(1, .VBComponents.Item($i).CodeModule.CountOfLines) $sCode = " " & StringReplace($sCode, @CRLF, " ") & " " If StringInStr($sCode, " Sub ") > 0 Then Return True Next EndIf EndWith EndSwitch Return False EndFunc ;==>_CheckMacros
    1 point
  16. spudw2k

    RemoteIt - PSExec GUI

    Well, it's been several years since I put this together and decided to revisit it. Of course it doesn't work out-of-the-box anymore. As I have learned a lot since I put this together, I decided to give it a go at updating it. I plan to incorporate more intermediate/advanced methods as well as exhibit best practices and coding standards. A few specific things I plan to address: Change code to OnEvent execution instead of large While loop - Done Parallelize execution via multi-processing - Done Utilize STDOUT in lieu of using temp files - In Progress Incorporate multi-process communication through >Mailslots - Done Just working on the GUI so far...a good way to go still, but here is my new "GUI" code so far. Things To Do: Create Settings GUI Parallel / Worker Execution Testing Mailbox Communication Status Window Interaction Host List Browser PSExec Integration Log / Export Capability - In Progress Add Start/Finish Info To Execution Status Bug Fixes - Ongoing Please keep in mind that it is not fully functional. The PSEXEC integration is not yet in place. For now it is merely a GUI will some parallel processing pieces that utilize a MailSlot for process communication. 0.2.6.zip
    1 point
  17. I amended ff.au3 and rebuilt the exe file and it seems to have done the trick. Thanks
    1 point
×
×
  • Create New...