Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 03/20/2018 in all areas

  1. water

    AD - Active Directory UDF

    Version 1.6.3.0

    17,293 downloads

    Extensive library to control and manipulate Microsoft Active Directory. Threads: Development - General Help & Support - Example Scripts - Wiki Previous downloads: 30467 Known Bugs: (last changed: 2020-10-05) None Things to come: (last changed: 2020-07-21) None BTW: If you like this UDF please click the "I like this" button. This tells me where to next put my development effort
    1 point
  2. Hey guys, the code that I've written/borrowed below is mostly an example of using the commUDF listed at the bottom, just applied to an Arduino with accompanying Arduino code. Uses Serial communication to turn on a LED, then reads a response from the arduino and prints it in the console. I hope it helps Autoit Code: #include <CommMG.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $CMPort = 3 Global $CmBoBaud = 9600 Global $sportSetError = '' Global $CmboDataBits = 8 Global $CmBoParity = "none" Global $CmBoStop = 1 Global $setflow = 2 _CommSetPort($CMPort, $sportSetError, $CmBoBaud, $CmboDataBits, $CmBoParity, $CmBoStop, $setflow) If @error Then MsgBox(16, "Error!", "Can't connect to Arduino on port - " & $CMPort) Exit EndIf _CommSetRTS(0) _CommSetDTR(0) While 1 ; Just use to call function, doesn't need to be a loop. LED_ON() Sleep(100) LED_OFF() Sleep(100) WEnd Func LED_ON() _CommSendString("1") ;Sends the Arduino a string of "1" to turn on LED Local $ret = _CommGetLine(@CR, 100, 100) ; Waits for up to 100 for a carriage return response from Arduino. ConsoleWrite($ret & @CRLF) ;Print to Console. EndFunc ;==>LED_ON_OFF Func LED_OFF() _CommSendString("0") ;Sends Arduino string of "0" to turn off the LED Local $ret = _CommGetLine(@CR, 100, 100) ; Waits for up to 100 for a carriage return response from Arduino. ConsoleWrite($ret & @CRLF) ;Print to Console. EndFunc ;==>LED_BLINK_10 Arduino Code: int led = 12; void setup() { // put your setup code here, to run once: Serial.begin(9600); pinMode(led, OUTPUT); } void loop() { // put your main code here, to run repeatedly: if (Serial.available()) { int data = Serial.read(); if (data == '1') //On { digitalWrite(led, HIGH); //writeslow(); Serial.print("The LED is on!"); } if (data == '0') //Off { digitalWrite(led, LOW); Serial.print("The LED is OFF!"); } } } Serial/Com port UDF this is all based on
    1 point
  3. https://github.com/Microsoft/WinAppDriver/blob/master/README.md I think I’ve died and gone to heaven watch this video https://channel9.msdn.com/events/Connect/2016/202
    1 point
  4. My Script is now counting time correctly, and i can keep that code and inject it into any other script i make. Very happy i can keep time now hahah.
    1 point
  5. Thanks everyone! I've gotten some improvements cooked up and i think I've actually got something working. I appreciate the time you all took to reply.
    1 point
  6. Earthshine

    WindowInfo - control ID

    also, try just a WinWaitActive for waiting for your application. please, also post your CODE, not images of your code. that is super annoying and I am not going to type all that in to test or edit.
    1 point
  7. Because the process list is a 2D array, with process name and PID. I've examplified how to obtain the list on non-taboo process names only, but it's a trivial change to obtain both the names and their PID. I didn't have AutoIt handy to check which parameters to pass to _ArrayToString to obtain the same result.
    1 point
  8. I was able to find it here: https://social.msdn.microsoft.com/Forums/en-US/06bdec1d-4ffa-4a4a-b381-9265c304cc85/command-line-configuration-of-power-button-function?forum=quebecmisc Run("powercfg.exe -SETACVALUEINDEX 381b4222-f694-41f0-9685-ff5bb260df2e 4f971e89-eebd-4455-a8de-9e59040e7347 5ca83367-6e45-459f-a27b-476b1d01c936 3", "C:\WINDOWS\system32", @SW_HIDE) Run("powercfg.exe -SETDCVALUEINDEX 381b4222-f694-41f0-9685-ff5bb260df2e 4f971e89-eebd-4455-a8de-9e59040e7347 5ca83367-6e45-459f-a27b-476b1d01c936 3", "C:\WINDOWS\system32", @SW_HIDE) Run("powercfg.exe -powercfg.exe -SETACVALUEINDEX 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c 4f971e89-eebd-4455-a8de-9e59040e7347 7648efa3-dd9c-4e3e-b566-50f929386280 3", "C:\WINDOWS\system32", @SW_HIDE) Run("powercfg.exe -powercfg.exe -SETDCVALUEINDEX 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c 4f971e89-eebd-4455-a8de-9e59040e7347 7648efa3-dd9c-4e3e-b566-50f929386280 3", "C:\WINDOWS\system32", @SW_HIDE)
    1 point
  9. Try this: Local $PList = ProcessList() ;~ _ArrayDisplay($PList) Local $RL = ["smss", "csrss", "svchost", "iexplore.exe", "chrome", "conhost"] Local $sTabooP = "(?i)((?:" & _ArrayToString($RL) & ")(?:\.exe)?\*?)" Local $sProc For $i = 1 To UBound($PList) - 2 $sProc &= $PList[$i][0] & '*' ; use * as séparator Next $sProc &= $PList[$i][0] ; no final séparator Local $sUserP = StringRegExpReplace($sProc, $sTabooP, "") Local $aUserP = StringSplit($sUserP, '*', 2) _ArrayDisplay($aUserP)
    1 point
  10. Can you test the following: I haven't removed the file paths yet, the only issue I have with that is if a user selects another folder to add more docs to merge, then the script wouldn't know where to look for the files. For example if you wanted to merge documents from: C:\Folder1\Image1.jpg C:\Folder2\Image1.jpg It wouldn't know where Image1.jpg is coming from if we remove the file path. Hope that makes sense. #include <Array.au3> #include <File.au3> #include <GuiComboBox.au3> #include <GuiConstantsEx.au3> #include <GuiEdit.au3> #include <GuiListBox.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Word.au3> Global $idListDocs, $idListItems, $idItemUp, $idItemDown, $iLastItemSelect, $idSelectDoc Selectapps() Func Selectapps() Local $sSelectDoc = "Select New or Opened Document" Local $sSelectPathDoc = FileReadLine(@AppDataDir & "\Microsoft\Templates\Path.ini", 1) If @error Then $sSelectPathDoc = "" Local $bDocAttach = True Local $oWord = _Word_Create(True, False) GUICreate("Merge File(s)", 400, 395, 350, 250) GUISetBkColor(0xFFFFFF) $idSelectDoc = GUICtrlCreateCombo($sSelectDoc, 10, 10, 310, 20) Local $oDocs = _Word_DocGet($oWord) If @error Then $bDocAttach = False Else _GUICtrlComboBox_BeginUpdate($idSelectDoc) For $oDoc In $oDocs _GUICtrlComboBox_AddString($idSelectDoc, $oDoc.FullName) Next _GUICtrlComboBox_EndUpdate($idSelectDoc) EndIf Local $idBrowseDoc = GUICtrlCreateButton("Open...", 325, 9, 70, 23) $idListDocs = GUICtrlCreateList("", 10, 60, 310, 150, BitOR($WS_BORDER, $WS_VSCROLL)) Local $idSelectFolder = GUICtrlCreateInput("", 10, 35, 310, 20) _GUICtrlEdit_SetCueBanner($idSelectFolder, "Select Folder") GUICtrlSetData($idSelectFolder, $sSelectPathDoc) _AddSelectFolder(GUICtrlRead($idSelectFolder)) Local $idBrowseFolder = GUICtrlCreateButton("Browse...", 325, 34, 70, 23) Local $idAddItem = GUICtrlCreateButton("Add", 325, 60, 70, 30) Local $idClearItem = GUICtrlCreateButton("Clear Item", 325, 95, 70, 30) Local $idClearAll = GUICtrlCreateButton("Clear All", 325, 130, 70, 30) $idListItems = GUICtrlCreateList("", 10, 215, 310, 150, BitOR($WS_BORDER, $WS_VSCROLL)) $idItemUp = GUICtrlCreateButton("Up", 325, 215, 70, 20) $idItemDown = GUICtrlCreateButton("Down", 325, 240, 70, 20) Local $idRemoveItem = GUICtrlCreateButton("Remove", 325, 265, 70, 30) Local $idMergeFiles = GUICtrlCreateButton("Merge File", 325, 300, 70, 30) Local $idCloseGui = GUICtrlCreateButton("Cancel", 325, 335, 70, 30) GUICtrlCreateLabel("Info:", 5, 370, 25, 20, $SS_CENTERIMAGE) GUICtrlSetFont(2, 9, 999, 0, "Calibri") GUICtrlSetColor(-1, 0xC0C0C0) Local $idStatus = GUICtrlCreateLabel("Select files to merge!", 30, 370, 360, 20, $SS_CENTERIMAGE) GUICtrlSetFont(2, 9, 999, 0, "Calibri") GUICtrlSetColor(-1, 0xC0C0C0) GUISetState(@SW_SHOW) AdlibRegister("_ControlUpdate") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_ClOSE, $idCloseGui ExitLoop Case $idSelectDoc If GUICtrlRead($idSelectDoc) = $sSelectDoc Then ContinueLoop $sSelectDocPath = StringLeft(GUICtrlRead($idSelectDoc), StringInStr(GUICtrlRead($idSelectDoc), "\", 0, -1) - 1) GUICtrlSetData($idSelectFolder, $sSelectDocPath) _AddSelectFolder(GUICtrlRead($idSelectFolder)) Case $idBrowseDoc Local $sBrowseDoc = FileOpenDialog("Select Merge Document File Path", @ScriptDir, "Word Doc(*.doc;*.docx)", 3) If @error Then ContinueLoop GUICtrlSetData($idSelectDoc, $sBrowseDoc) Case $idBrowseFolder Local $sBrowseFolder = FileSelectFolder ("Select Folder with Documents to merge", "", 4, @ScriptDir) If @error Then ContinueLoop _AddSelectFolder($sBrowseFolder) Case $idAddItem $iListDocs = _GUICtrlListBox_GetCurSel($idListDocs) If $iListDocs = -1 Then ContinueLoop _GUICtrlListBox_AddString($idListItems, _GUICtrlListBox_GetText($idListDocs, $iListDocs)) Case $idClearItem If _GUICtrlListBox_GetCurSel($idListDocs) = -1 Then ContinueLoop _GUICtrlListBox_DeleteString($idListDocs, _GUICtrlListBox_GetCurSel($idListDocs)) Case $idClearAll GUICtrlSetData($idSelectFolder, "") _GUICtrlListBox_ResetContent($idListDocs) Case $idItemUp _ListBoxDirect($idListItems, "Up") Case $idItemDown _ListBoxDirect($idListItems, "Down") Case $idRemoveItem If _GUICtrlListBox_GetCurSel($idListItems) = -1 Then ContinueLoop _GUICtrlListBox_DeleteString($idListItems, _GUICtrlListBox_GetCurSel($idListItems)) Case $idMergeFiles If FileExists(GUICtrlRead($idSelectDoc)) = 0 Then ContinueLoop Local $bDocStart = True, $bDocAdd = False $iCount = _GUICtrlListBox_GetCount($idListItems) If $iCount <= 0 Then ContinueLoop GUICtrlSetState($idAddItem, $GUI_DISABLE) GUICtrlSetState($idBrowseFolder, $GUI_DISABLE) GUICtrlSetState($idItemUp, $GUI_DISABLE) GUICtrlSetState($idItemDown, $GUI_DISABLE) GUICtrlSetState($idRemoveItem, $GUI_DISABLE) GUICtrlSetState($idMergeFiles, $GUI_DISABLE) If $bDocAttach = False Then $oWordDoc = _Word_DocOpen($oWord, GUICtrlRead($idSelectDoc)) Else $oWordDoc = _Word_DocAttach($oWord, GUICtrlRead($idSelectDoc)) EndIf For $i = 0 To $iCount $iFileExtension = _FileExtension(_GUICtrlListBox_GetText($idListItems, $i)) If $iFileExtension = -1 Then ContinueLoop GUICtrlSetData($idStatus, "Merging " & _GUICtrlListBox_GetText($idListItems, $i)) If $bDocStart Then $bDocAdd = _MergeDocuments($oWordDoc, $iFileExtension, _GUICtrlListBox_GetText($idListItems, $i)) $bDocStart = False ContinueLoop Else If $bDocAdd Then $oWordDoc.Bookmarks("\EndofDoc").Range.InsertBreak($WdPageBreak) EndIf $bDocAdd = _MergeDocuments($oWordDoc, $iFileExtension, _GUICtrlListBox_GetText($idListItems, $i)) Next _GUICtrlListBox_ResetContent($idListItems) GUICtrlSetState($idAddItem, $GUI_ENABLE) GUICtrlSetState($idBrowseFolder, $GUI_ENABLE) GUICtrlSetState($idRemoveItem, $GUI_ENABLE) GUICtrlSetState($idMergeFiles, $GUI_ENABLE) _Word_DocSave($oWordDoc) ;~ _Word_DocSaveAs($oWordDoc, GUICtrlRead($idSelectDoc)) ;~ _Word_DocClose($oWordDoc) ;~ _Word_Quit($oWord) GUICtrlSetData($idStatus, "Select files to merge!") MsgBox(64, "Completed", "Merged Completed!") EndSwitch WEnd EndFunc Func _ListBoxDirect($_hListBox, $_sListBoxDirect) Local $iListItemSelect = _GUICtrlListBox_GetCurSel($_hListBox) Local $iListItemCount = _GUICtrlListBox_GetCount($idListItems) - 1 Local $sListItemSelect = _GUICtrlListBox_GetText($_hListBox, $iListItemSelect) Switch $_sListBoxDirect Case "Up" If $iListItemSelect <= 0 Then Return _GUICtrlListBox_DeleteString($_hListBox, $iListItemSelect) _GUICtrlListBox_InsertString($_hListBox, $sListItemSelect, $iListItemSelect - 1) _GUICtrlListBox_SetCurSel($_hListBox, $iListItemSelect - 1) Case "Down" If $iListItemSelect >= $iListItemCount Then Return _GUICtrlListBox_DeleteString($_hListBox, $iListItemSelect) _GUICtrlListBox_InsertString($_hListBox, $sListItemSelect, $iListItemSelect + 1) _GUICtrlListBox_SetCurSel($_hListBox, $iListItemSelect + 1) Case Else Return EndSwitch EndFunc Func _ControlUpdate() Local $iListItemSelect = _GUICtrlListBox_GetCurSel($idListItems) If $iLastItemSelect = $iListItemSelect Then Return Local $iListItemCount = _GUICtrlListBox_GetCount($idListItems) - 1 $iLastItemSelect = $iListItemSelect Switch $iListItemSelect Case -1 If $iListItemCount = 0 Or $iListItemCount = -1 Then GUICtrlSetState($idItemDown, $GUI_DISABLE) GUICtrlSetState($idItemUp, $GUI_DISABLE) EndIf Case 0 GUICtrlSetState($idItemUp, $GUI_DISABLE) If $iListItemCount > 0 Then GUICtrlSetState($idItemDown, $GUI_ENABLE) Case $iListItemCount GUICtrlSetState($idItemDown, $GUI_DISABLE) If $iListItemSelect > 0 Then GUICtrlSetState($idItemUp, $GUI_ENABLE) Case Else GUICtrlSetState($idItemUp, $GUI_ENABLE) GUICtrlSetState($idItemDown, $GUI_ENABLE) EndSwitch EndFunc Func _AddSelectFolder($_sFolderPath) Local $aFolderList = _FileListToArrayRec($_sFolderPath, "*.doc;*.docx;*.jpg;*.jpeg;*.png;*.tif;*.tiff|~*.doc;~*.docx", 1, 0, 0, 2) If @error Then Return "" For $i = 1 To $aFolderList[0] If $aFolderList[$i] = GUICtrlRead($idSelectDoc) Then ContinueLoop _GUICtrlListBox_AddString($idListDocs, $aFolderList[$i]) Next EndFunc Func _MergeDocuments($_oWordDoc, $_iFileExtension, $_sFileName) Switch $_iFileExtension Case 1 $_oWordDoc.Bookmarks("\EndOfDoc").Range.InsertFile($_sFileName) Return True Case 2 _Word_DocPictureAdd($_oWordDoc, $_sFileName, False, True, $_oWordDoc.Bookmarks("\EndOfDoc").Range) Return True Case Else Return False EndSwitch EndFunc Func _FileExtension($_sFileName) Local $iFileExtension = StringInStr($_sFileName, ".", 0, -1) If $iFileExtension = 0 Then Return -1 Local $sFileExtension = StringTrimLeft($_sFileName, $iFileExtension) Switch $sFileExtension Case "doc", "docx" Return 1 Case "jpg", "jpeg", "tif", "tiff", "png" Return 2 EndSwitch Return -1 EndFunc
    1 point
  11. jchd

    MapKeys() on empty map

    This isn't a 0D array (that could qualify a flat variable), but a different unicorn: it's a 1D array with zero row. AutoIt allows array dimension(s) to be 0: Local $a[0] is perfectly valid, just like $a[0][3] (a 2D array of zero row of three columns each, or $a[0][2][5] (a 3D array of zero planes of 2 rows by 5 columns). All of this is perfectly sensible, as functions returning an array should return a suitable dimensionned array with zero rows when there is no data to return. That would save extra code in applications and verbiage in help. Unfortunately this possibility is relatively recent and older UDFs do return anything like an empty string or an error in such case, which is plain wrong IMVHO. If you're the only child and someone asks for the number of brothers/sisters you have, you say "zero" or "none" but you never reply "error" or "" (an empty string).
    1 point
  12. I tried to do a small animation. i took the code of this topic and some code from GDI+ animated loading screens build 2014-06-20 from UEZ GDI+ animated loading screens It's not perfect ... #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <Memory.au3> #include <GDIPlus.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <TrayConstants.au3> Global Const $hDwmApiDll = DllOpen("dwmapi.dll") Global $sChkAero = DllStructCreate("int;") DllCall($hDwmApiDll, "int", "DwmIsCompositionEnabled", "ptr", DllStructGetPtr($sChkAero)) Global $bAero = DllStructGetData($sChkAero, 1) Global $fStep = 0.02 If Not $bAero Then $fStep = 1.25 _GDIPlus_Startup() Global $iW = 300, $iH = 120 $hGUI = GUICreate("Office", 442, 252, @DesktopWidth /2.95, @DesktopHeight /3.2, $WS_POPUP) GUISetBkColor(0xB7472A) ;GUISetBkColor(0x2b579a) ;Word Blue GUISetBkColor(0x217346) ;Excel Green $Label1 = GUICtrlCreateLabel("SciTE4AutoIt3", 8, 8, 102, 21) GUICtrlSetFont(-1, 10, 400, 0, "Segoe UI Light") GUICtrlSetColor(-1, 0xFFFFFF) $Label2 = GUICtrlCreateLabel("AutoIt 247", 64, 72, 314, 75, BitOR($SS_CENTER,$SS_CENTERIMAGE)) GUICtrlSetFont(-1, 40, 400, 0, "Segoe UI Light") GUICtrlSetColor(-1, 0xFFFFFF) $Label3 = GUICtrlCreateLabel("Starting...", 10, 205, 54, 21) GUICtrlSetFont(-1, 10, 400, 0, "Segoe UI Light") GUICtrlSetColor(-1, 0xFFFFFF) $Label4 = GUICtrlCreateLabel("r", 410, 4, 20, 21) GUICtrlSetFont(-1, 12, 400, 0, "Webdings") GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetTip(-1, "Closes the splash screen.") $Label5 = GUICtrlCreateLabel("0", 385, 0, 20, 21) GUICtrlSetFont(-1, 12, 400, 0, "Webdings") GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetTip(-1, "Minimises the splash screen.") GUISetState(@SW_SHOW) Global Const $iPic = GUICtrlCreatePic("", 80, 150, $iW, $iH) GUICtrlSetState(-1, $GUI_DISABLE) WinSetTrans($hGUI, "", 0) GUISetState() Global $hHBmp_BG, $hB, $iSleep = 50 GUIRegisterMsg($WM_TIMER, "PlayAnim") DllCall("user32.dll", "int", "SetTimer", "hwnd", $hGUI, "int", 0, "int", $iSleep, "int", 0) Global $z, $iPerc For $z = 1 To 255 Step $fStep WinSetTrans($hGUI, "", $z) Next Do Switch GUIGetMsg() Case $GUI_EVENT_CLOSE GUIRegisterMsg($WM_TIMER, "") _WinAPI_DeleteObject($hHBmp_BG) _GDIPlus_Shutdown() GUIDelete() Exit EndSwitch Until False Func PlayAnim() $hHBmp_BG = _GDIPlus_ThreeBalls($iW, $iH, $iPerc) $hB = GUICtrlSendMsg($iPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBmp_BG) If $hB Then _WinAPI_DeleteObject($hB) _WinAPI_DeleteObject($hHBmp_BG) ; Joue sur la vitesse d affichage $iPerc += 0.5 If $iPerc > 110 Then $iPerc = 0 EndFunc ;==>PlayAnim Func _GDIPlus_ThreeBalls($iW, $iH, $iPerc, $sString = "Please wait...", $iRadius = 12, $iBalls = 3, $bHBitmap = True) Local Const $iDiameter = $iRadius * 2 Local $tPointF1 = DllStructCreate("float;float") Local $pPointF1 = DllStructGetPtr($tPointF1) Local $tPointF2 = DllStructCreate("float;float") Local $pPointF2 = DllStructGetPtr($tPointF2) DllStructSetData($tPointF1, 1, $iDiameter) DllStructSetData($tPointF1, 2, 0) DllStructSetData($tPointF2, 1, $iDiameter) DllStructSetData($tPointF2, 2, $iDiameter) Local $hBrushBall2 = DllCall($__g_hGDIPDll, "uint", "GdipCreateLineBrush", "ptr", $pPointF1, "ptr", $pPointF2, "uint", 0xFFcecbca, "uint", 0xFFf2eeed, "int", 1, "int*", 0) $hBrushBall2 = $hBrushBall2[6] Local $hBitmap = _GDIPlus_BitmapCreateFromScan0($iW, $iH) Local Const $hCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsSetSmoothingMode($hCtxt, 2) _GDIPlus_GraphicsSetPixelOffsetMode($hCtxt, $GDIP_PIXELOFFSETMODE_HIGHQUALITY) Local Const $hBrushBall1 = _GDIPlus_BrushCreateSolid(0xFF217346) _GDIPlus_GraphicsFillRect($hCtxt, 0, 0, $iW, $iH, $hBrushBall1) Local $aPos[$iBalls + 2][4], $iArrayPos, $j = 1 Local Static $aCircle[$iBalls + 1] For $i = 0 To $iBalls - 1 $aPos[($iBalls - 1) - $i][0] = ($iW / 2) - (($iDiameter + $iRadius) * ($i + 1)) + (($iBalls - 1) / 2 * ($iDiameter + $iRadius)) + $iDiameter $aPos[($iBalls - 1) - $i][1] = ($iH - $iRadius) / 2 _GDIPlus_GraphicsFillEllipse($hCtxt, $aPos[($iBalls - 1) - $i][0], $aPos[($iBalls - 1) - $i][1], $iDiameter, $iDiameter, $hBrushBall1) ;draw background $aPos[($iBalls - 1) - $i][2] = 100 / $iBalls $iArrayPos = Int($iPerc / ($aPos[($iBalls - 1) - $i][2])) $aPos[$iArrayPos][3] = ($iPerc - ($iArrayPos * ($aPos[($iBalls - 1) - $i][2]))) / $aPos[($iBalls - 1) - $i][2] If $iArrayPos > 0 Then For $j = 0 To $iArrayPos - 1 $aPos[$j][3] = 1 Next EndIf Next ; Animation remplissage des balles Local $fMax = 2, $hPen = _GDIPlus_PenCreate(0x217346, 1) Local $i, $fDH Local Static $s, $t For $i = 0 To $iBalls - 1 _GDIPlus_PenSetColor($hPen, 0xFF217346) $iHeight = $iRadius * 0.05 $fDH = Sin($s + Cos($i + $t)) * $iHeight * 0.66666 $s += 0.05 _GDIPlus_GraphicsFillEllipse($hCtxt, $iRadius + $aPos[$i][0] - $iRadius * $fDH, $iRadius + $aPos[$i][1] - $iRadius * $fDH, $iDiameter * $fDH, $iDiameter * $fDH, $hBrushBall2) Next _GDIPlus_GraphicsDispose($hCtxt) _GDIPlus_BrushDispose($hBrushBall1) _GDIPlus_BrushDispose($hBrushBall2) _GDIPlus_PenDispose($hPen) If $bHBitmap Then Local $hHBITMAP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) _GDIPlus_BitmapDispose($hBitmap) Return $hHBITMAP EndIf Return $hBitmap EndFunc A lots of code only for three dots
    1 point
  13. You have some blocking function in it like sleep. Also Guioneventmode give some problem in your case. I fixed it, see the code. #include <GuiListView.au3> #include <File.au3> #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> HotKeySet("{Esc}", "_Exit") Global $c=0 Global $ssGDI[3], $ssGraphic[2], $ssImage Global Const $bg_color = "000000" Global Const $ssW = 480, $ssH = 320 Global $aFiles = _FileListToArrayRec("d:\testStage\", "*.jpg;*.png;*.bmp;*.gif;*.JPG;*.PNG;*.BMP;*.GIF", $FLTAR_FILES, $FLTAR_NORECUR ,$FLTAR_SORT ,$FLTAR_FULLPATH ) $guiW = 1200 $guiH = 726 $mainWindow = GUICreate("Slideshow Viewer", $guiW, $guiH, -1, -1, $WS_POPUP) $Button1 = GUICtrlCreateButton("Exit", 0, 0, 50, 50) $Button2 = GUICtrlCreateButton("Test", 60, 0, 50, 50) Global $ListView = GUICtrlCreateListView("Entry Name|Category", 5, 75, 195, 280) _GUICtrlListView_SetColumnWidth ($ListView, 0, 100) _GUICtrlListView_SetColumnWidth ($ListView, 1, 100) GUICtrlSendMsg($ListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES) GUICtrlSendMsg($ListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_FULLROWSELECT, $LVS_EX_FULLROWSELECT) GUICtrlCreateListViewItem("Name 1|Category 1", $ListView) GUICtrlCreateListViewItem("Name 2|Category 2", $ListView) screenshotWidgetInit($ssW,$ssH, 690, 100) GUISetState(@SW_SHOW, $mainWindow) GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events") While 1 _Check_MSG() WEnd Func _Check_MSG() $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE _Exit() Case $Button1 _Exit() Case $Button2 Test() EndSwitch EndFunc Func Test() For $k = 1 To UBound($aFiles) - 1 screenshotWidgetTransition($aFiles[$k]) Next EndFunc Func ListView_Click() ConsoleWrite("Left Click") EndFunc Func ListView_DoubleClick() ConsoleWrite("Double Left Click") Test() EndFunc Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam) #forceref $hWndGUI, $MsgID, $wParam Local $tagNMHDR, $event, $hwndFrom, $code $tagNMHDR = DllStructCreate("int;int;int", $lParam) If @error Then Return $event = DllStructGetData($tagNMHDR, 3) Select Case $wParam = $ListView Select Case $event = $NM_CLICK ListView_Click () Case $event = $NM_DBLCLK ListView_DoubleClick () EndSelect EndSelect Return $GUI_RUNDEFMSG EndFunc Func screenshotWidgetTransition($image, $delay = 0, $speed = 1, $sleep = 2000) Local $a, $d = $c, $iX, $iY $ssImage = _GDIPlus_ImageLoadFromFile($image) $iX = _GDIPlus_ImageGetWidth($ssImage) $iY = _GDIPlus_ImageGetHeight($ssImage) $FDesktop=$ssH/$ssW $Fact =1 If $iX > $ssW And $FDesktop > ($iY/$iX) Then $Fact=$ssW/$iX ElseIf $iY > $ssH Then $Fact=$ssH/$iY EndIf $H1 = Round(($Fact * $iY),0) $W1 = Round(($Fact * $iX),0) _GDIPlus_GraphicsDrawImageRect($ssGraphic[$d], $ssImage,($ssW - $W1)/2, ($ssH - $H1) / 2,$W1,$H1) WinSetTrans($ssGDI[$d], "", 0) WinSetOnTop($ssGDI[$d], "", 1) For $a = 0 To 254 Step $speed WinSetTrans($ssGDI[$d], "", $a) _Check_MSG() Sleep($delay) Next WinSetTrans($ssGDI[$d], "", 254) WinSetOnTop($ssGDI[Not ($d)], "", 0) WinSetTrans($ssGDI[Not ($d)], "", 0) _GDIPlus_GraphicsClear($ssGraphic[Not ($d)]) $c = 1 - $d _GDIPlus_ImageDispose ($ssImage) ; very important to realease the pics $timer = TimerInit() While TimerDiff($timer) < $sleep _Check_MSG() WEnd EndFunc ;==>screenshotWidgetTransition Func screenshotWidgetInit($ssW,$ssH,$ssX,$ssY) $ssGDI[2] = GUICreate("", $ssW, $ssH, $ssX, $ssY, $WS_POPUP, $WS_EX_MDICHILD, $mainWindow) $ssGDI[0] = GUICreate("", $ssW, $ssH, 3, 3, $WS_POPUP, $WS_EX_MDICHILD, $ssGDI[2]) $ssGDI[1] = GUICreate("", $ssW, $ssH, 3, 3, $WS_POPUP, $WS_EX_MDICHILD, $ssGDI[2]) ; GUISetBkColor("0x" & $bg_color, $ssGDI[2]) GUISetState(@SW_SHOW, $ssGDI[2]) GUISetState(@SW_SHOW, $ssGDI[0]) GUISetState(@SW_SHOW, $ssGDI[1]) WinSetTrans($ssGDI[0], "", 0) WinSetTrans($ssGDI[1], "", 0) _GDIPlus_Startup() $ssGraphic[0] = _GDIPlus_GraphicsCreateFromHWND($ssGDI[0]) $ssGraphic[1] = _GDIPlus_GraphicsCreateFromHWND($ssGDI[1]) _GDIPlus_GraphicsClear($ssGraphic[0], "0xFF" & $bg_color) _GDIPlus_GraphicsClear($ssGraphic[1], "0xFF" & $bg_color) EndFunc ;==>screenshotWidgetInit Func _Exit() _GDIPlus_ImageDispose($ssImage) _GDIPlus_GraphicsDispose($ssGraphic[0]) _GDIPlus_GraphicsDispose($ssGraphic[1]) GUIDelete($ssGDI[0]) GUIDelete($ssGDI[1]) GUIDelete($ssGDI[2]) _GDIPlus_Shutdown() Exit EndFunc ;==>_Exit
    1 point
    Extremely useful for Sys admins or even just an engineer to manipulate AD data or Data Collections. Tests are simple and code is simple to read and modify. If you work with anyone who doesn't know much about AD building a GUI with this UDF is very helpful. Great Job @water
    1 point
  14. Here is another method. Note : The StringRegExpReplace function captures three groups per file line:- ${1} - contains from the beginning of the line to, and including, the vertical bar, ${2} - contains from the vertical bar the end of the line (the date & time), and, ${3} - contains the line feed at the end of the line (if it exists). Then, in the 'replace' parameter of the StringRegExpReplace function, a conditional operator is use with if the date difference as the condition parameter. Conditional operator. e.g. $condition ? $expression1 : $expression2 #include <Date.au3> #include <FileConstants.au3> Local $fileName = "log.txt" Local $s = '"' & StringRegExpReplace(FileRead($fileName), "([^|]+\|)(.+)(\R*)", '"&((_DateDiff("s","${2}", _NowCalc()) > 600) ? "" : "${1}${2}${3}")&"') & '"' ;ConsoleWrite($s & @LF) ;ConsoleWrite("-----------------------" & @LF) Local $text = Execute($s) ;ConsoleWrite($text & @LF) ; Write to file Local $hFileOpen = FileOpen($fileName, $FO_OVERWRITE) FileWrite($hFileOpen, $text) FileClose($hFileOpen) ShellExecute($fileName)
    1 point
  15. Yes, I could manage the windows, but luckily: Func MemoryReadPixel($x, $y, $handle) Local $hDC Local $iColor Local $sColor $hDC = _WinAPI_GetWindowDC($handle) $iColor = DllCall("gdi32.dll", "int", "GetPixel", "int", $hDC, "int", $x, "int", $y) $sColor = Hex($iColor[0], 6) _WinAPI_ReleaseDC($handle, $hDC) Return Hex("0x" & StringRight($sColor, 2) & StringMid($sColor, 3, 2) & StringLeft($sColor, 2)) EndFunc ;==>MemoryReadPixel Works for background windows, and is MUCH faster then PixelGetColor() Here is a fast test script using PixelGetColor(), FFGetPixel() and MemoryReadPixel() #include "FastFind.au3" #include <WinAPI.au3> Opt("PixelCoordMode", 0) $handle = WinGetHandle("Untitled - Notepad") if $handle = "" Then MsgBox(0, "", "Please open a blank notepad window.") Exit EndIf $timerHndl = TimerInit() FFSnapShot(0, 0, 0, 0, 1, $handle) MsgBox(0, "", "PixelGetColor color returned : " & hex(PixelGetColor(200, 200, $handle)) & @CRLF & _ "FFGetPixel color returned : " & Hex(FFGetPixel(200, 200, 1)) & @CRLF & _ "MemoryReadPixel color returned : " & MemoryReadPixel(200, 200, $handle) ) MsgBox(0, "", "PixelGetColor average speed over 100 attempts : " & test_speed_PixelGetColor($handle) & " ms" & @CRLF & _ "FFGetPixel average speed over 100 attempts : " & test_speed_FFGetPixel($handle) & " ms" & @CRLF & _ "MemoryReadPixel average speed over 100 attempts : " & test_speed_MemoryReadPixel($handle) & " ms") Func MemoryReadPixel($x, $y, $handle) Local $hDC Local $iColor Local $sColor $hDC = _WinAPI_GetWindowDC($handle) $iColor = DllCall("gdi32.dll", "int", "GetPixel", "int", $hDC, "int", $x, "int", $y) $sColor = Hex($iColor[0], 6) _WinAPI_ReleaseDC($handle, $hDC) Return Hex("0x" & StringRight($sColor, 2) & StringMid($sColor, 3, 2) & StringLeft($sColor, 2)) EndFunc ;==>MemoryReadPixel Func test_speed_MemoryReadPixel($param1) Local $count = 0 For $i = 1 To 100 $timer = TimerDiff($timerHndl) $color = MemoryReadPixel(200, 200, $param1) $timer = TimerDiff($timerHndl) - $timer $count += $timer Sleep(10) Next Return($count / 100) EndFunc ;==>test_speed_MemoryReadPixel Func test_speed_FFGetPixel($param1) Local $count = 0 FFSnapShot(0, 0, 0, 0, 1, $param1) For $i = 1 To 100 $timer = TimerDiff($timerHndl) $color = Hex(FFGetPixel(200, 200, 1)) $timer = TimerDiff($timerHndl) - $timer $count += $timer Sleep(10) Next Return($count / 100) EndFunc ;==>test_speed_FFGetPixel Func test_speed_PixelGetColor($param1) Local $count = 0 For $i = 1 To 100 $timer = TimerDiff($timerHndl) $color = Hex(PixelGetColor(200, 200, $param1)) $timer = TimerDiff($timerHndl) - $timer $count += $timer Sleep(10) Next Return($count / 100) EndFunc ;==>test_speed_PixelGetColor While FFGetPixel() is insanely fast, it requires its own dll, and if you need to make a new snapshot for every FFGetPixel() call, its actually quite slow. Thank you very much for finding that post!
    1 point
  16. Hi How can I run 2 or more scripts in win 10 without interference? edit: found the solution-> using controlclick instead of Mouseclick
    0 points
×
×
  • Create New...