Leaderboard
Popular Content
Showing content with the highest reputation on 05/06/2016 in all areas
-
1 point
-
Move files based on date
tuffgong reacted to InunoTaishou for a topic
Local $aLogs = _FileListToArray($sPath, "*", 1) If (Not @error) Then For $i = 1 To $aLogs[0] $aDate = FileGetTime($sPathIN & "\" & $aLogs[$i], 0, 0) If Not @error And IsArray($aDate) Then $aaDate = $aDate[0] & "/" & $aDate[1] & "/" & $aDate[2] ;~ FileMove($sPathIN & "\" & $aLogs[$i], $sPathOUT & "\", 1 + 8) If _DateDiff("D", $aaDate, _NowCalcDate()) > 35 Then FileMove($sPathIN & "\" & $aLogs[$i], $sPathOUT & "\", 1 + 8) EndIf Next EndIf1 point -
Compiling scripts from console with AutoIt3Wrapper
Trong reacted to LFCavalcanti for a topic
Yeah, that is why I'll upload all the source files to Github this weekend. The sources will be used to generate two executables, one for an IT technician to access an User PC and the other the User will run in it his computer so the technician access it. IF the IT person who will deploy the "solution" on his Help Desk doesn't want to mess around with the source files, I'll make an GENERATOR, to input the UltraVNC repeater information, language files for the text and so on... this GENERATOR will compile both executables and the TI pro just deploy them. If that person wants to change the code, etc, just open the sources files and mess around with them. (Mess here is meant as learn and modify as needed). As I explained for @Trong, the compiled "exe" are easier to deploy for the users. The app will have both the function to run UltraVNC and establish a reverse connection to the Repeater and be installed, to solve problems with UAC restricitions. I'm not an native English speaker myself, I'm from Brazil. XD1 point -
Pause script if network is disabled, resume when enabled
Trong reacted to InunoTaishou for a topic
There's this function _WinAPI_IsInternetConnected #include <WinAPIDiag.au3> #include <GUIConstants.au3> AutoItSetOption("GuiOnEventMode", 1) Global $hMain = GUICreate("Title") GUISetState(@SW_SHOW, $hMain) GUISetOnEvent($GUI_EVENT_CLOSE, Close) AdlibRegister(CheckNetwork, 1000) While (True) Sleep(100) WEnd Func CheckNetwork() If (_WinAPI_IsInternetConnected()) Then Return AdlibUnRegister(CheckNetwork) Local $bOnEventRet = AutoItSetOption("GuiOnEventMode", 0) Local $hNetwork = GUICreate("Network", 200, 30) Local $lblNetwork = GUICtrlCreateLabel("Network is currently unavailable", 10, 10) GUISetState(@SW_DISABLE, $hMain) GUISetState(@SW_SHOW, $hNetwork) While (Not _WinAPI_IsInternetConnected()) Switch (GUIGetMsg()) Case $GUI_EVENT_CLOSE GUIDelete($hNetwork) GUIDelete($hMain) Exit 0 EndSwitch WEnd GUIDelete($hNetwork) GUISetState(@SW_ENABLE, $hMain) AdlibRegister(CheckNetwork, 1000) AutoItSetOption("GuiOnEventMode", $bOnEventRet) EndFunc Func Close() GUIDelete($hMain) Exit 0 EndFunc1 point -
czardas, Adding a parameter so that the user could choose is exactly what I had envisaged. We already do that for PivotSort on 1D arrays, so it seems logical to do the same sort of thing for 2D - in fact we could use the same parameter! And I do not see this as massive bloat - I make it 72 lines in total for the 2 functions, plus a few more to deal with the parameter. What we need now is some details of when the user would be best advised to use your "new" algorithm - the 50+ element suggestion for PivotSort was made empirically after much testing, so I could I ask you to provide something similar along the lines of what you have been suggesting earlier in this thread. M231 point
-
Regex toolkit
Earthshine reacted to BrewManNH for a topic
It's not needed because it actually makes your script much slower with a large amount of data. What this function does is takes the memory used by the program and dumps it to disk in the page file. Reading data from a file is many times slower than reading the same data from memory. Also, having more free memory means that all the money you spent on that 16Gbs of memory was a waste, because you're not actually using it. This was a useless holdover from the XP days, and wasn't even needed back then either.1 point -
#include <WinAPI.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <GDIPlus.au3> gui_func() Func gui_func() Global $hBMP, $hBitmap, $hGraphic, $hImage, $iX, $iY, $hClone, $t, $aMPos Global $GuiSizeX = 974, $GuiSizeY = 510 Global $pngFile = "GDI+.bmp" Global $hGUI = GUICreate("GDI+", $GuiSizeX, $GuiSizeY) GUISetState() _GDIPlus_Startup() Global $hBitmap = _GDIPlus_ImageLoadFromFile($pngFile) ;create an empty bitmap Global $g_hHBITMAP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) ;convert GDI+ bitmap to GDI bitmap _GDIPlus_BitmapDispose($hBitmap) ;delete GDI+ bitmap because not needed anymore Global $g_hDC = _WinAPI_GetDC($hGUI) ;get device context from GUI Global $g_hDC_Backbuffer = _WinAPI_CreateCompatibleDC($g_hDC) ;creates a memory device context compatible with the specified device $g_oDC_Obj = _WinAPI_SelectObject($g_hDC_Backbuffer, $g_hHBITMAP) ;selects an object into the specified device context $g_hGfxCtxt = _GDIPlus_GraphicsCreateFromHDC($g_hDC_Backbuffer) ;create a graphics object from a device context (DC) _GDIPlus_GraphicsSetSmoothingMode($g_hGfxCtxt, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;set smoothing mode (8 X 4 box filter) _GDIPlus_GraphicsSetPixelOffsetMode($g_hGfxCtxt, $GDIP_PIXELOFFSETMODE_HIGHQUALITY) _WinAPI_BitBlt($g_hDC, 0, 0, $GuiSizeX, $GuiSizeY, $g_hDC_Backbuffer, 0, 0, $SRCCOPY) GUIRegisterMsg($WM_PAINT, "MY_PAINT") While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE _WinAPI_SelectObject($g_hDC_Backbuffer, $g_oDC_Obj) _GDIPlus_GraphicsDispose($g_hGfxCtxt) _WinAPI_DeleteObject($g_hHBITMAP) _WinAPI_ReleaseDC($hGUI, $g_hDC) _WinAPI_DeleteDC($g_hDC_Backbuffer) _GDIPlus_Shutdown() GUIDelete($hGUI) Exit Case $GUI_EVENT_RESTORE MY_PAINT() EndSwitch WEnd EndFunc ;==>gui_func Func MY_PAINT() ;sleep (2000) _WinAPI_BitBlt($g_hDC, 0, 0, $GuiSizeX, $GuiSizeY, $g_hDC_Backbuffer, 0, 0, $SRCCOPY) Return "GUI_RUNDEFMSG" EndFunc ;==>MY_PAINT1 point
-
Regex toolkit
Xandy reacted to argumentum for a topic
I don't remember very clearly the discussion here in the forums, but I remember it was useless. Try a compiled script with it and without it. You'll find that is not needed. Try for yourself.1 point -
General Query
pranaynanda reacted to RTFC for a topic
To prevent the tray icon from appearing for your own scripts, just add directive #NoTrayIcon.1 point -
General Query
pranaynanda reacted to mLipok for a topic
I'm not english native speakers, and after re reading this documentation I agree that there is indeed not quite well writen for such member like you and me If you want to help make it better: Please quote here each sentence which is dificult to understand for you, and ask a questions. But for now I try to focus your attention and give you a little help: You do not must declare it . This is done automaticaly by AutoIt. Here is my quick example: #include <MsgBoxConstants.au3> ConsoleWrite("! Paramters count = " & $CmdLine[0] & @CRLF) For $iParameter_idx = 1 To $CmdLine[0] MsgBox($MB_OK, "Paramter #" & $iParameter_idx, $CmdLine[$iParameter_idx]) Next EDIT: I changed this example a little. First: Just copy this example to new (empty) au3 file and run it to see whats happend. Next: compile it to exe and run from CMD with Parameters1 point -
Is far as I know it compres the used memory. Why do you believe it's better without it?1 point
-
@czardas Whilst the standard _arraySort() in autoIt is a good choice for generic sorting, Like you have done I often find myself writing specific sorting functions for different scripts. When you as sorting the same type of data in a script and you understand the data e.g. is it mostly in order to start with, all the same data type, size of data etc You can then choose the most appropriate algorithm and remove any unnecessary error and data type checking within the main sorting loops. It's surprising how big an improvement can be made to the sort speeds especially with some the the large file I deal with at work. I was interested to see you use of the double pivot method. If you you were to submit this as a replacement for the standard arraySort, then I think that adding an extra parameter where the default behaviour was to replicate the stable sort of the current function. Users could the set the parameter to the go faster mode when speed was more important than having a stable sort.1 point
-
This should do it: Local $data_size = GetStreamSize($sStream_Data) MsgBox(0, "", BinaryLen($data_size) & " bytes")1 point
-
There are several ways to get to the element - try a different one. Also check if you have frames - often IEgetobjbyname doesnt work because the element is contained in a frame.1 point
-
1 point
-
1 point
-
Try this function instead: Func _GDIPlus_ImageCompare($hImage1, $hImage2, $bFastCmp = True) Local Const $iW = _GDIPlus_ImageGetWidth($hImage1), $iH = _GDIPlus_ImageGetHeight($hImage1) If ($iW <> _GDIPlus_ImageGetWidth($hImage2)) Then Return SetError(1, 0, 0) If ($iH <> _GDIPlus_ImageGetHeight($hImage2)) Then Return SetError(2, 0, 0) Local $t = TimerInit() Local $tBitmapData1 = _GDIPlus_BitmapLockBits($hImage1, 0, 0, $iW, $iH, $GDIP_ILMREAD, $GDIP_PXF32ARGB) Local $tBitmapData2 = _GDIPlus_BitmapLockBits($hImage2, 0, 0, $iW, $iH, $GDIP_ILMREAD, $GDIP_PXF32ARGB) Local $pScan1 = DllStructGetData($tBitmapData1, "Scan0") Local $tPixel1 = DllStructCreate("uint[" & $iW * $iH & "];", $pScan1) Local $iStride = Abs(DllStructGetData($tBitmapData1, "Stride")) Local $pScan2 = DllStructGetData($tBitmapData2, "Scan0") Local $tPixel2 = DllStructCreate("uint[" & $iW * $iH & "];", $pScan2) If $bFastCmp Then $iResult = DllCall("msvcrt.dll", "int:cdecl", "memcmp", "ptr", $pScan1, "ptr", $pScan2, "uint", DllStructGetSize($tPixel1))[0] Else If ($iW * $iH + 1) * 3 > 16 * 1024^2 Then Return SetError(3, 0, 0) Local $iX, $iY, $iRowOffset, $iPixel1, $iPixel2, $c = 1, $aDiff[$iW * $iH + 1][3] For $iY = 0 To $iH - 1 $iRowOffset = $iY * $iW + 1 For $iX = 0 To $iW - 1 $iPixel1 = DllStructGetData($tPixel1, 1, $iRowOffset + $iX) ;get pixel color $iPixel2 = DllStructGetData($tPixel2, 1, $iRowOffset + $iX) ;get pixel color If $iPixel1 <> $iPixel2 Then $aDiff[$c][0] = $iX & ", " & $iY $aDiff[$c][1] = "0x" & Hex($iPixel1, 8) $aDiff[$c][2] = "0x" & Hex($iPixel2, 8) $c += 1 EndIf Next Next $aDiff[0][0] = TimerDiff($t) $aDiff[0][1] = $iW $aDiff[0][2] = $iH EndIf _GDIPlus_BitmapUnlockBits($hImage1, $tBitmapData1) _GDIPlus_BitmapUnlockBits($hImage2, $tBitmapData2) If $bFastCmp Then Return SetError(0, Int(TimerDiff($t)), $iResult = 0) ReDim $aDiff[$c][3] Return $aDiff EndFunc1 point
-
You may encounter unexpected results if you use "==" instead of "=" because "==" performs a String Comparison, not a numeric comparison.1 point
-
_WinAPI_SetWindowLong and $GWL_STYLE/$GWL_EXSTYLE
Xandy reacted to vladinator for a topic
Thanks mate! BiXOR to remove flag BitOR to add flag BitAND($bits, $flag) == $flag ; to check if the flag is there BitAND($bits, $flag) <> $flag ; to check if the flag is missing1 point -
Hi guys While writing on a much bigger project than this i've got nice idea for my room. I positioned a microphone connected to my computer near my door at home. My computer is running with winamp paused. And this script running: ;~ ----------------------------------------------------------------- ;~ MusicStarter TestVersion ;~ By Nemcija (BlackShadow3@web.de) ;~ With UDF's by CyberZeroCool ;~ ;~ Just call it crap :D ;~ ----------------------------------------------------------------- #region Settings $VoiceActivationLevel = 5 ; Use Debugmode to determine this $SleepBeforeCheck = 60 ;Seconds bevor start checking the microphonelevel (time to leave the room :D) $Debugmode = false ;To determine the activation level #endregion Settings #region Includes #Include <string.au3> #endregion Includes #region Functions Func _mciSendString($lpszCommand, $lpszReturnString, $cchReturn, $hwndCallback) Return DllCall("winmm.dll", "long", "mciSendStringA", "str", $lpszCommand, "str", $lpszReturnString, "long", $cchReturn, "long", 0) EndFunc Func _mciShowError($mciError,$add = "test") Dim $errStr $errStr = _StringRepeat(" ", 256) $Result = DllCall("winmm.dll", "long", "mciGetErrorStringA", "long", $mciError, "string", $errStr, "long", StringLen($errStr)) MsgBox(0, "MCI "&$add, "MCI Error Number " & $mciError & ":" & $Result[2]) EndFunc ;==>_mciShowError Func _LevelCheck() Global $lpszCommand,$lpszReturnString,$cchReturn $mciError = _mciSendString($lpszCommand, $lpszReturnString, $cchReturn, 0) If $mciError[0] <> 0 Then _mciShowError($mciError[0]) EndIf _AddToLastLevels($mciError[2]) EndFunc Func _AddToLastLevels($level) Global $LastLevels,$LevelTime,$Debugmode $LastLevels[$LastLevelsSet] = $level $LastLevelsSet += 1 If $Debugmode Then ToolTip($level) If $LastLevelsSet = $LevelTime+1 Then $LastLevelsSet = 1 EndFunc #endregion Functions #region Startup $lpszDevice = "new type waveaudio" $lpszOpenFlags = "alias mywave" $lpszFlags = "" $lpszCommand = StringFormat( "open %s %s %s", $lpszDevice, $lpszOpenFlags, $lpszFlags) $lpszReturnString = _StringRepeat(" ", 256) $cchReturn = StringLen($lpszReturnString) $mciError = _mciSendString($lpszCommand, $lpszReturnString, $cchReturn, 0); If $mciError[0] <> 0 Then _mciShowError($mciError[0],"Startup Error") Exit EndIf $lpszDeviceID = "mywave" $lpszRequest = "level" $lpszFlags = "" $lpszCommand = StringFormat( "status %s %s %s", $lpszDeviceID, $lpszRequest, $lpszFlags) $LevelTime = 15 ; *100ms Dim $LastLevels[$LevelTime+1] For $i = 1 To $LevelTime $LastLevels[$i] = 0 Next $LastLevelsSet = 1 AdlibEnable("_LevelCheck",100) #endregion Startup #region Runtime Sleep($SleepBeforeCheck*1000) While 1 Sleep(100) $Active = False $i = 0 While (($i <= $LevelTime) And (Not $Active)) $Active = $Active Or ($LastLevels[$i] >= $VoiceActivationLevel) $i +=1 WEnd If $Active Then Send("{MEDIA_PLAY_PAUSE}") Exit EndIf WEnd #endregion Runtime So when i come home from work plop ... i open the door and the music starts playing :D Before you ask why i'm using Dim $LastLevels[$LevelTime+1] and an search procedure .. I've just copied that part from a much bigger project i'm working on at the time And thanks to CyberZeroCool for the UDF's *edit* Another way to use it: Clap in your hands -> Watch this video Greetings Nemcija. P.S.: I hope you understand my english1 point
-
@Pascal257: Mh.... i tried to write a clap control - but it is very hard to adjust :) I think it takes a long period of testing .. But if you want to have al look at it: ;~ ----------------------------------------------------------------- ;~ ClapWinampcontrol TestVersion ;~ By Nemcija (BlackShadow3@web.de) ;~ With UDF's by CyberZeroCool ;~ ;~ Just call it crap :D ;~ ----------------------------------------------------------------- #region Settings $VoiceActivationLevel = 50 ; Should be louder than your music ^^ ; But you will have to clap as loud as possible o_O ; Not good :( $Debugmode = false ;To determine the activation level (clap once and remember the number) #endregion Settings #region Includes #Include <string.au3> #endregion Includes #region Functions Func _mciSendString($lpszCommand, $lpszReturnString, $cchReturn, $hwndCallback) Return DllCall("winmm.dll", "long", "mciSendStringA", "str", $lpszCommand, "str", $lpszReturnString, "long", $cchReturn, "long", 0) EndFunc Func _mciShowError($mciError,$add = "test") Dim $errStr $errStr = _StringRepeat(" ", 256) $Result = DllCall("winmm.dll", "long", "mciGetErrorStringA", "long", $mciError, "string", $errStr, "long", StringLen($errStr)) MsgBox(0, "MCI "&$add, "MCI Error Number " & $mciError & ":" & $Result[2]) EndFunc ;==>_mciShowError Func _LevelCheck() Global $lpszCommand,$lpszReturnString,$cchReturn $mciError = _mciSendString($lpszCommand, $lpszReturnString, $cchReturn, 0) If $mciError[0] <> 0 Then _mciShowError($mciError[0]) EndIf _AddToLastLevels($mciError[2]) EndFunc Func _AddToLastLevels($level) Global $LastLevels,$LevelTime,$Debugmode $LastLevels[$LastLevelsSet] = $level $LastLevelsSet += 1 If $Debugmode Then ToolTip($level) If $LastLevelsSet = $LevelTime+1 Then $LastLevelsSet = 1 EndFunc #endregion Functions #region Startup $lpszDevice = "new type waveaudio" $lpszOpenFlags = "alias mywave" $lpszFlags = "" $lpszCommand = StringFormat( "open %s %s %s", $lpszDevice, $lpszOpenFlags, $lpszFlags) $lpszReturnString = _StringRepeat(" ", 256) $cchReturn = StringLen($lpszReturnString) $mciError = _mciSendString($lpszCommand, $lpszReturnString, $cchReturn, 0); If $mciError[0] <> 0 Then _mciShowError($mciError[0],"Startup Error") Exit EndIf $lpszDeviceID = "mywave" $lpszRequest = "level" $lpszFlags = "" $lpszCommand = StringFormat( "status %s %s %s", $lpszDeviceID, $lpszRequest, $lpszFlags) $LevelTime = 30 ; *100ms Dim $LastLevels[$LevelTime+1] For $i = 1 To $LevelTime $LastLevels[$i] = 0 Next $LastLevelsSet = 1 AdlibEnable("_LevelCheck",50) #endregion Startup #region Runtime While 1 Sleep(50) $i = 1 $ClapCount = 0 While $i <= $LevelTime If $LastLevels[$i] >= $VoiceActivationLevel Then $ClapCount +=1 $i +=2 EndIf $i +=1 WEnd If $LastLevels[Mod($LastLevelsSet+1,$LevelTime)] >= $VoiceActivationLevel Then Switch($ClapCount) Case 1 Send("{MEDIA_PLAY_PAUSE}") Case 2 Send("{MEDIA_NEXT}") Case 3 Send("{MEDIA_PREV}") EndSwitch For $i = 1 To $LevelTime $LastLevels[$i] = 0 Next EndIf WEnd #endregion Runtime1 point