Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 08/22/2019 in all areas

  1. Personal satisfaction and harder to read script.
    2 points
  2. New version 1.7.3.0 is out! Download current release Place to post bugs and suggestions (Bug tracker) Online help (Wiki) What's new: Graphic editorBetter support of limited accounts and UAC under Vista/SevenStyles editor allow multiple selectionIcons in additional controls (Tab, ListView, TreeView)Redone Object tree, with support of editable descriptionsAwareness of GUI_SS_DEFAULT stylesAnd many smaller changes (see full history) New version 1.7.2.0 is out! What's new: Added small abilities that become in latest beta of AutoitImproved language systemImproved update checkingImproved siteNew version 1.7.1.0 is out! What's new: Customizing colorsExternal import frameworkCustom controls (ones that available via standard UDFs)Rewritten support for icon - now it support full color onesBetter support (bugtracker, wiki)Bugfix release 1.7.0.1 is out! After another year, new version 1.7.0.0 is out! Most significant changes in this release: Customizable toolbarsUndo supportAligning paletteImport Autoit GUI scriptsFull help file, with context sensitive help supportAnd as usually, lots of bugfixes and small changes. After long period of development and testing, new release 1.6.0.0 is finally here! Thanks to all who support us and help done this work! Most significant changes from previous release: New, more fast and reliable form read/write routines.Rewritten form list handling codeMenus support (with visual editor)Obj support (with visual browser)Templates-based code generationGenerating event-based codeHelp file (unfinished)Old topic is here, some bugs posted there are not resolved yet, so please check it too.
    1 point
  3. wcook509

    Adventure Game

    Way back in the early 80's (I am a 72 year old youngster), I wrote a few BASIC language text-base adventure games for the Tandy/Radio Shack Color Computer. Haven't even attempted any kind of coding in 30+ years. After discovering AutoIT, I thought I would make an attempt to determine if something like those legacy games could be created using AutoIt. This is what I've come up with and it is far from finished. I would welcome comments, improvements, ideas.... (remember I am very much a novice). Thanks... Adventure.au3
    1 point
  4. Hmmmm... it seems this can be done with AutoHotKey (see the last post in this link). https://social.technet.microsoft.com/Forums/windows/en-US/40cbc1e7-bdf5-4e4a-b007-161211099f99/putting-pc-into-sleep-mode-programmatically-windows-10?forum=win10itprosetup It therefore must be possible with AutoIT. 😓
    1 point
  5. ControlHide() / ControlShow() #include <GUIConstants.au3> #include <GuiDateTimePicker.au3> $Form1 = GUICreate('DTP', 400, 300) $hDTP = _GUICtrlDTP_Create($Form1, 10, 10, 150, 150 ) GUISetState(@SW_SHOW) Sleep(3000) ControlHide($Form1, '', $hDTP) Sleep(3000) ControlShow($Form1, '', $hDTP) While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd
    1 point
  6. Maybe use IE instead as it will provide you with the right file name in the save as window ?
    1 point
  7. What is the value of @error after the Shutdown function call?
    1 point
  8. Inpho

    AutoIt Snippets

    @Deye I don't mind creating another array to list the items personally; my main goal was to increase speed at the potential sacrifice of memory. I'm not a fan of converting an array to a string in this way; it makes for (please don't take offence) un-pretty code that's hard to understand. Unfortunately using your function on a 35,000 x 10 array takes too long; I let it run for 4 minutes and stopped it. Conversely, my function completed in less than one second. Conversely again; using your function on a 35,000 row 1D array appears to be faster than mine on first tests Of course a better use case would be to make the changes as a 1D array, but I'm weird and like to account for every use. Sometimes I'm reading huge csv files into an array; converting this to a 1D array or a string to search for blank rows is a lot of expense when _ArrayFindEmptyRows will do it extremely quickly without playing ping pong with the data conversion. Thanks for sharing the function, there's something for me to learn from FYI how I created the test array: Global $aArray[35000][10] For $i = 1 To UBound($aArray) - 1 For $ii = 0 To UBound($aArray, 2) - 1 $aArray[$i][$ii] = _StringRandom(20, 4) If Mod($i, 10) = 0 Then $aArray[$i][$ii] = "" EndIf Next Next
    1 point
  9. Deye

    AutoIt Snippets

    Inpho, @Why not try delete them with a faster function than creating another array just to list valid element points? Better yet, Try this (I'm only assuming it will be fast enough for you, for 2D arrays, it will still use _array delete but with the range option and no looping .. Please Let us know .. Note: this method doesn't work if the chosen delimiter exists in any of elements in the array ..(not about the "|" one) ; 1D & 2D Func _ArrayDelEmptyRows(ByRef $Array, $bUBound = False, $sDelim = ",") ; $bUBound return the $Array[0] with elements count If UBound($Array, 2) Then Local $str, $sString, $ai ;If $Array[0][0] = UBound($Array) Then _ArrayDelete($Array, 0) $str = _ArrayToString($Array, "|", Default, Default, $sDelim) $sString = StringRegExpReplace($sDelim & $str, $sDelim & "[|]*[|]", $sDelim) $ai = _ArrayFindAll(StringSplit(StringTrimLeft($sString, 1), $sDelim, 3), "") If Not IsArray($ai) Then Return $Array Local $aTemp[UBound($Array) - UBound($ai)][UBound($Array, 2)] Local $sAi = "," & _ArrayToString($ai, ",") & "," $x = -1 For $i = 0 To UBound($Array) - 1 If StringInStr($sAi, "," & $i & ",") Then ContinueLoop $x += 1 For $j = 0 To UBound($aTemp, 2) - 1 $aTemp[$x][$j] = $Array[$i][$j] Next Next If $bUBound Then _ArrayInsert($aTemp, 0, UBound($aTemp)) Return $aTemp Else Local $pattern = $sDelim & "[" & $sDelim & "|]*[" & $sDelim & "|]" Local $str = StringRegExpReplace($sDelim & _ArrayToString($Array, $sDelim), $pattern, "|") If StringRight($str, 1) = "|" Or StringRight($str, 1) = $sDelim Then $str = StringTrimRight($str, 1) Return StringSplit(StringTrimLeft($str, 1), StringInStr($str, $sDelim) ? $sDelim : "|", $bUBound ? "" : 3) EndIf EndFunc ;==>_ArrayDelEmptyRows
    1 point
  10. I am seriously wondering what one would gain from doing this? Jos
    1 point
  11. You can do something like this here: #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <DateTimeConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <WinAPISysWin.au3> #include <file.au3> #include <array.au3> #include <GuiListView.au3> #include <Misc.au3> #include <ColorConstants.au3> #include <GUIComboBox.au3> Global $VERSION = "2.0.0 | Build: 20819" $INLOGGUI = GUICreate($VERSION & " - Inloggen", 332, 342, -1, -1, $WS_POPUPWINDOW) $BG = GUICtrlCreatePic(@ScriptDir & '\Images\LoginBG.BMP', 0, 0, 332, 342) $TITEL = GUICtrlCreateLabel("Inloggen", 0, 40, 332, 30, $ES_CENTER) GUICtrlSetFont(-1, 18, 800, 0, "Calibri") $LABELUSERNAME = GUICtrlCreateLabel("Gebruiker", 50, 150, 50, 17) $Combo1 = GUICtrlCreateCombo("Kies een medewerker...", 50, 167, 233, 25, BitOR($CBS_DROPDOWNLIST, $WS_VSCROLL)) $LABELPASSW = GUICtrlCreateLabel("Wachtwoord:", 50, 210, 77, 17, 0) $PasswordEdit = GUICtrlCreateInput("", 50, 227, 233, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER, $ES_PASSWORD)) $hPasswordEdit = GUICtrlGetHandle($PasswordEdit) $VERSIONLABEL = GUICtrlCreateLabel("Versie: " & $VERSION, 8, 323) $hLabel = GUICtrlCreateLabel("", 0, 0, 332, 50, -1, $GUI_WS_EX_PARENTDRAG) GUICtrlSetState($BG, $GUI_DISABLE) GUICtrlSetBkColor($TITEL, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetBkColor($LABELUSERNAME, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetBkColor($LABELPASSW, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetBkColor($Combo1, $GUI_BKCOLOR_TRANSPARENT) ;~ GUICtrlSetBkColor($PasswordEdit, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetBkColor($VERSIONLABEL, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetBkColor($hLabel, $GUI_BKCOLOR_TRANSPARENT) GUISetState(@SW_SHOW) Global $iColor = 0xFFFFFF GUIRegisterMsg($WM_CTLCOLOREDIT, "WM_CTLCOLOREDIT") GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func WM_CTLCOLOREDIT($hWnd, $iMsg, $wParam, $lParam) If $lParam = $hPasswordEdit Then _WinAPI_SetTextColor($wParam, 0x000000) _WinAPI_SetBkMode($wParam, $TRANSPARENT) Return _WinAPI_CreateSolidBrush($iColor) EndIf Return "GUI_RUNDEFMSG" EndFunc Func WM_COMMAND($hWnd, $iMsg, $lParam, $wParam) Switch $hWnd Case $INLOGGUI Switch _WinAPI_LoWord($lParam) Case $PasswordEdit Switch _WinAPI_HiWord($lParam) Case $EN_SETFOCUS $iColor = 0x00FFFF Case $EN_KILLFOCUS $iColor = 0xFFFFFF EndSwitch EndSwitch EndSwitch Return "GUI_RUNDEFMSG" EndFunc
    1 point
  12. http://autoit-script.ru/index.php?topic=23418.msg135107
    1 point
  13. genius257

    libVLC

    So I've been playing around with libvlc.dll and i'm wondering if anyone's interested in the code and some examples? Can't seem to find anyone who has done this in AutoIt, via the dll. Thanks for your time Edit: Well I'm happy to know someone finds it interesting I'll post the half done stuff here for now, but i will create a post in AutoIt Example Scripts, When i get more examples done . For now, any feedback would be great The file itself: LibVLC.au3 Note: Before running the examples you need libvlc.dll, libvlccore.dll and the plugins folder from VLC. If you have it installed, you can copy them from your install folder, however i would recommend a fresh download, as i personally had some old plugins that gave me annoying message-boxes i have yet to find a way to deal with. So getting the files without installing: download the windows installer (2.2.4 is the current as of this post). Open the exe with 7zip or your preferred program and extract the files and folder to the folder you wish to run the examples. As i have not looked into rules and legal matters with VLC files i won't upload them ^^' Example: #include "LibVLC.au3" Opt("GuiOnEventMode", 1) $hWnd = GUICreate("AutoIt + VLC Example", 700, 320) GUISetState(@SW_SHOW, $hWnd) ;pick a short video/audio-file, if you want to get the event $sFilePath = FileOpenDialog("Select VLC compatible file", "", "All (*.*)", 1+2, "", $hWnd) If @error<>0 Then Exit $hLibVLC_dll = DllOpen("libvlc.dll") $hVLC = libvlc_new($hLibVLC_dll, 0, 0) $m = libvlc_media_new_path($hLibVLC_dll, $hVLC, $sFilePath);path object $mp = libvlc_media_player_new_from_media($hLibVLC_dll, $m);player object libvlc_media_release($hLibVLC_dll, $m);release the path object. We're done with it. $mp_em = libvlc_media_player_event_manager($hLibVLC_dll, $mp);player event manager ;Create dllcallback to function and set to event: media player end reached $pEndReached = DllCallbackRegister("_VLC_Event_EndReached", "none:cdecl", "handle;handle") libvlc_event_attach($hLibVLC_dll, $mp_em, $libvlc_MediaPlayerEndReached, DllCallbackGetPtr($pEndReached), 0) libvlc_media_player_set_hwnd($hLibVLC_dll, $mp, $hWnd) libvlc_media_player_play($hLibVLC_dll, $mp) ;~ OnAutoItExitRegister("_CleanUp") GUISetOnEvent(-3, "_MyExit", $hWnd) While 1 Sleep(10) WEnd Func _CleanUp() libvlc_media_player_stop($hLibVLC_dll, $mp);stop the video libvlc_media_player_release($hLibVLC_dll, $mp) libvlc_release($hLibVLC_dll, $hVLC) DllClose($hLibVLC_dll) DllCallbackFree($pEndReached) GUIDelete($hWnd) EndFunc Func _MyExit() _CleanUp() Exit EndFunc Func _VLC_Event_EndReached($event, $data); the event function ConsoleWrite("EndReached"&@CRLF) EndFunc The script sometimes won't shut down. Not sure what's causing it. Found a possible cause from a discussion, suggesting it may be something to do with certain functions having problems being called from the main thread. I plan to experiment and post my results soon. Edit2 (19th March 2017): First of all, sorry about the lack of updates on this project. I always start too many projects and end up ignoring old projects, if I run into problems ^^'. So I've started moving my AutoIt scripts to GitHub. I will still post the most recent script version here. Edit3 (12th April 2017): So I've uploaded the example on my Github repository with the files needed (except a video file) to run the example. Sometimes the example will freeze. I found a thread suggesting that calling libvlc_media_player_stop and related functions from the same thread with the window message handling, may result in the problem occurring. I have a possible solution, but am unable to currently test it, as some needed code is hiding in my unorganized mess of projects.
    1 point
  14. Process CPU Usage Trackers As yet another alternative to the Performance Counters UDF, I've created this UDF to allow easy tracking of one or more processes's CPU usage. While this has obviously been done before, I haven't seen it done the way I've created it. Basically, just as the Performance Counters had Process Counter objects, so this too has Process Usage trackers. They are relatively simple to use, and require very little interaction other than invoking the functions. To create a new tracker object, call one of these: _ProcessUsageTracker_Create() ; Single process tracker _ProcessesUsageTracker_Create() ; Multiple processes tracker The multiple-process tracker requires addition of processes, which can be done one of 2 ways: _ProcessesUsageTracker_Add() ; add a single process _ProcessesUsageTracker_AddMultiple() ; multiple processes in a ProcessList-style array After the usage tracker object has been created, stats can be collected via one of two calls: _ProcessUsageTracker_GetUsage() ; single process - returns a percentage _ProcessesUsageTracker_GetUsage() ; multiple Processes - returns an array of %'s Basically the main loop of the program can be filled with 'GetUsage' calls without juggling anything around. If a process dies out, an @error code will be returned in the single-process version. The multiple-process tracker version however lets you retain dead processes in the list although their process handles will be closed. These can be alternatively cleared up on each call to 'GetUsage' (setting $bRemoveDead to True), or you can opt to clean them up with the following call: _ProcessesUsageTracker_RemoveDead() ; Removes any dead processes from the tracker object Finally, to destroy the trackers and close handles, just call the appropriate function: _ProcessUsageTracker_Destroy() _ProcessesUsageTracker_Destroy() That's about it. More info is in the headers. Here's an example of a single process cpu usage tracker: ; ======================================================================================================== ; <Process_CPUUsageExample.au3> ; ; Example usage of <Process_CPUUsage.au3> ; ; Author: Ascend4nt ; ======================================================================================================== #include "Process_CPUUsage.au3" ; -------------------- HOTKEY FUNCTION & VARIABLE -------------------- Global $bHotKeyPressed=False Func _EscPressed() $bHotKeyPressed=True EndFunc ; -------------------- MAIN PROGRAM CODE -------------------- HotKeySet("{Esc}", "_EscPressed") Local $hSplash, $sSplashText Local $sProcess, $aProcUsage, $fUsage ; Regular Process: ;~ $sProcess = "firefox.exe" ;~ $sProcess = "sp2004.exe" ; Stress Prime 2004 ; Protected Process (opens a different way): ;~ $sProcess = "audiodg.exe" ; Processes Requiring elevated privilege (will fail even with limited access rights): ;~ $sProcess = "CTAudSvc.exe" $sProcess = InputBox("Enter Process Name", "Process Name:", "", "", 320, 140) If @error Or $sProcess = "" Then Exit $aProcUsage = _ProcessUsageTracker_Create($sProcess) If @error Then Exit ConsoleWrite("Error calling _ProcessUsageTracker_Create(): " & @error & ", @extended = " & @extended & @CRLF) Sleep(250) $hSplash=SplashTextOn("Process CPU Usage Information", "", 360, 20 + 60, Default, Default, 16, Default, 12) ; Start loop Do $sSplashText="" $fUsage = _ProcessUsageTracker_GetUsage($aProcUsage) If @error Then ConsoleWrite("Error from _ProcessUsageTracker_GetUsage(): " & @error & ", @extended = " &@extended & @CRLF) ExitLoop EndIf $sSplashText &= "'"&$sProcess&"' CPU usage: " & $fUsage & " %" & @CRLF $sSplashText &= @CRLF & "[Esc] exits" ControlSetText($hSplash, "", "[CLASS:Static; INSTANCE:1]", $sSplashText) Sleep(500) Until $bHotKeyPressed _ProcessUsageTracker_Destroy($aProcUsage) _ Multiple processes example, which is best used with something like 'chrome' which spawns a number of processes with the same name: ; ======================================================================================================== ; <Processes_CPUUsageExample.au3> ; ; Example usage of <Processes_CPUUsage.au3> ; ; Author: Ascend4nt ; ======================================================================================================== #include "Processes_CPUUsage.au3" ; -------------------- HOTKEY FUNCTION & VARIABLE -------------------- Global $bHotKeyPressed=False Func _EscPressed() $bHotKeyPressed=True EndFunc ; -------------------- MAIN PROGRAM CODE -------------------- HotKeySet("{Esc}", "_EscPressed") Local $hSplash, $sSplashText Local $sProcess, $aProcList, $aProcUsage, $aPercents, $nPercents ; Regular Process: ;~ $sProcess = "firefox.exe" ;~ $sProcess = "sp2004.exe" ; Stress Prime 2004 ; Protected Process (opens a different way): ;~ $sProcess = "audiodg.exe" ; Processes Requiring elevated privilege (will fail even with limited access rights): ;~ $sProcess = "CTAudSvc.exe" $sProcess = InputBox("Enter Process Name", "Process Name:", "", "", 320, 140) If @error Or $sProcess = "" Then Exit $aProcUsage = _ProcessesUsageTracker_Create() _ProcessesUsageTracker_Add($aProcUsage, "sp2004.exe") _ProcessesUsageTracker_Add($aProcUsage, "CPUStabTest.exe") $aProcList = ProcessList("chrome.exe") _ProcessesUsageTracker_AddMultiple($aProcUsage, $aProcList) _ProcessesUsageTracker_Add($aProcUsage, $sProcess) _ProcessesUsageTracker_Add($aProcUsage, "audiodg.exe") Sleep(250) $hSplash=SplashTextOn("Process CPU Usage Information", "", 380, 24 + 15*2 + $aProcUsage[0][0]*15, Default, Default, 16+4, "Lucida Console", 11) ; Start loop Do ; DEBUG: Interrupt to allow multiple process termination ;MsgBox(0, "Next usage", "Next usage time..") $sSplashText="" $aPercents = _ProcessesUsageTracker_GetUsage($aProcUsage, True) ; True = Remove dead $nPercents = @extended If @error Then ConsoleWrite("Error from _ProcessesUsageTracker_GetUsage(): " & @error & ", @extended = " &@extended & @CRLF) ExitLoop EndIf For $i = 0 To $nPercents - 1 $sSplashText &= "'"&$aProcUsage[$i+1][0]&"' [PID #"&$aProcUsage[$i+1][1]&"] CPU usage: " & $aPercents[$i] & " %" & @CRLF Next $sSplashText &= @CRLF & "[Esc] exits" ControlSetText($hSplash, "", "[CLASS:Static; INSTANCE:1]", $sSplashText) Sleep(500) Until $bHotKeyPressed _ProcessesUsageTracker_Destroy($aProcUsage) ProcessCPUUsage.zip
    1 point
  15. Do you sometimes read the help file It clearly states: "Sets @error to 0xDEAD and @extended to 0xBEEF if the function does not exist or invalid number of parameters." $var = "Test1" Call($var) $Er = @error $Ex = @extended ConsoleWrite("$Er: " & $Er & " (dec), " & Hex($Er, 4) & " (hex); $Ex: " & $Ex & " (dec), " & Hex($Ex, 4) & " (hex)" & @CRLF) Call("Test2") $Er = @error $Ex = @extended ConsoleWrite("$Er: " & $Er & " (dec), " & Hex($Er, 4) & " (hex); $Ex: " & $Ex & " (dec), " & Hex($Ex, 4) & " (hex)" & @CRLF) Func Test2($param1) EndFunc ;==>Test2Gives you $Er: 57005 (dec), DEAD (hex); $Ex: 48879 (dec), BEEF (hex) $Er: 57005 (dec), DEAD (hex); $Ex: 48879 (dec), BEEF (hex)with Autoit 3.3.8.0 @Extended doesn't seem to work (always returns 0) but @error does. It returns @error and @extended as described.
    1 point
×
×
  • Create New...