Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/14/2018 in all areas

  1. I do my best to speak how i code, by nesting all my thoughts together in one line and hitting F5.
    2 points
  2. youtuber, Another of many ways to do this... #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Array.au3> #include <file.au3> Local $aFiles = _FileListToArrayRec('c:\k\autoit', '*', 1, 1, 1, 2) If @error Then Exit MsgBox(17, 'Error', @extended) $Form1 = GUICreate("My File List") $ButtonStartStop = GUICtrlCreateButton("Start", 10, 375, 380, 20) $Edit1 = GUICtrlCreateEdit("", 10, 10, 380, 360) GUICtrlSetData(-1, "") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $ButtonStartStop If GUICtrlRead($ButtonStartStop) = "Stop" Then GUICtrlSetData($ButtonStartStop, "Start") AdlibUnRegister('Files') ContinueLoop EndIf If GUICtrlRead($ButtonStartStop) = 'Start' Then GUICtrlSetData($ButtonStartStop, "Stop") AdlibRegister('Files', 100) EndIf EndSwitch WEnd Func Files() Local Static $idx = 0 GUICtrlSetData($Edit1, $aFiles[$idx] & @CRLF, 1) $idx += 1 EndFunc ;==>Files kylomas
    2 points
  3. This is what you are describing, i believe. But i still question the need to actually iterate through the loop whilst waiting for the stop button to be pressed.... #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $fInterrupt = 0 $hGUI = GUICreate("Test", 100, 100) $hButton_1 = GUICtrlCreateButton("START", 10, 10, 80, 30) $hButton_2 = GUICtrlCreateButton("STOP", 10, 50, 80, 30) $Counter = 1 GUISetState() GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hButton_1 $Counter = _Func_1() + 1 Case $hButton_2 _Func_2() EndSwitch WEnd Func _Func_1() $fInterrupt = 0 For $i = $Counter To 30 ConsoleWrite("SelectItem: " & $i & @CRLF) If $fInterrupt <> 0 Then ConsoleWrite("!STOPPED AT ITEM " & $i & @CRLF) Return $i EndIf Sleep(100) If $i = 30 Then $i = 0 Next EndFunc Func _Func_2() return EndFunc Func _WM_COMMAND($hWnd, $Msg, $wParam, $lParam) If BitAND($wParam, 0x0000FFFF) = $hButton_2 Then $fInterrupt = 1 Return $GUI_RUNDEFMSG EndFunc ;==>_WM_COMMAND modified from Melbas here: And if I know how many seconds elapsed between when you started and when you pressed the button, then I know where you stopped and where I need to resume. The actual visualization is nice but not ancillary.
    2 points
  4. WHAT : is .NET Common Language Runtime (CLR) Framework The Common Language Runtime (CLR) is a an Execution Environment . Common Language Runtime (CLR)'s main tasks are to convert the .NET Managed Code to native code, manage running code like a Virtual Machine, and also controls the interaction with the Operating System. As part of Microsoft's .NET Framework, the Common Language Runtime (CLR) is managing the execution of programs written in any of several supported languages. Allowing them to share common object-oriented classes written in any of the languages. HOW : To access the CLR environment you need to create an Appdomain Object - _CLR_GetDefaultDomain() An AppDomain provides an isolated region in which code runs inside of an existing process. Application domains provide an isolation boundary for security, reliability, and versioning, and for unloading assemblies. Application domains are typically created by runtime hosts, which are responsible for bootstrapping the common language runtime before an application is run. WHEN : Would you use CLR Runtime Hosts 1. To access .NET Class Libraries : System System.Collections System.Data System.Drawing System.IO System.Text System.Threading System.Timers System.Web System.Web.Services System.Windows.Forms System.Xml 2. Accessing custom build .Net Assemblies : Some Examples (but there are a ton out there) AutoItX3 - The .NET Assembly for using AutoItX JSonToXML libr. XMLRPC Libr. .NETPDF libr. .NETOCR Libr WInSCP Libr. ... 3. To Compile .Net Code into an Assembly 4. To Run C# or VB.net Code 5. To Mix AU3 and .Net functionality in your Application WHERE : To find documentation about CLR First of all you can find a lot on MSDN and here : Post 4 & Post 6 EXAMPLES : Multiple examples included in Zip !! Example : “System.Text.UTF8Encoding” Example : “System.IO.FileInfo” Example : “System.Windows.Forms” Example : AutoItX3 Custom .NET Assembly AutoItX Example : Compile Code C# and Code VB Example : Compile Code C# at Runtime WHO : Created the CLR.au3 UDF All credits go to : Danyfirex / Larsj / Trancexx / Junkew TO DO : The library is still Work in Process … (Some of the GUI Controls are not yet working as expected...) Anyone is free to participate in contributing to get the bugs resolved and to expand the CLR.au3 functionality ... Enjoy !! DOWNLOADS : (Last updated) - added CLR Constants.au3 - Danyfirex - Global Constants added (Magic numbers) - added .NET CLR CreateObject vs ObjCreate Example.au3 - Junkew • 2 approaches give the same result (only valid for COM Visible Assembly) • Includes a function that shows you which Assembly Classes are COM Visible - added .Net Conventional COM Objects Examples - ptrex - added .NET CLR CreateComInstanceFrom Example - Danyfirex - You can use it for Regfree COM Assembly Access - System.Activator has 4 methods : • CreateComInstanceFrom : Used to create instances of COM objects. • CreateInstanceFrom : Used to create a reference to an object from a particular assembly and type name. • GetObject : Used when marshaling objects. • CreateInstance : Used to create local or remote instances of an object. - added .NET Access SafeArrays Using AccVarsUtilities Example - LarsJ - added SafeArray Utilities functions in Includes - LarsJ - added .NET Access Native MSCorLib Classes - System - ptrex Multiple System Class Examples : • System.Random • System.DateTime • System.Diagnostics.PerformanceCounter • System.IO.FileInfo • System.Int32 • System.Double • System.Speech • System.Web - added Third Party Assembly Access - ptrex • WinSCP : https://winscp.net/eng/download.php • IonicZip : http://dotnetzip.codeplex.com/ - added more Examples using PowerShell GUI Assembly Access - ptrex • GUI Ribbon .NET Assembly using &nbsp;CLR Library • GUI Report Designer .NET Assembly using &nbsp;CLR Library • GUI SSRS Reporting .NET Assembly using &nbsp;CLR Library CLRv3a.zip .NET CLR Framework for AutoIT.pdf
    1 point
  5. jguinch

    Regex Help

    StringRegExp($sString, "^(([1-9]\d*)(?:-(?2))?)(?:,(?1))*$")
    1 point
  6. mikell

    Regex Help

    ? StringRegExp($str, '^([1-9]+\d*(-[1-9]+\d*)?,?)+$')
    1 point
  7. It depends on what the regex is intended to do. Using flag 3 it returns an array, but an Edit displays strings, not arrays In the particular case of your current code the array has one element only so something like this may work $arrayregex = StringRegExp($aArray[$i], 'Num(.?)', 3) ;~ _ArrayDisplay($arrayregex) ; GUICtrlSetData($ButtonStartStop, "Stop") If IsArray($arrayregex) Then GUICtrlSetData($Edit1, $arrayregex[0] & @CRLF,1) but in the real life you will probably need _ArrayToString or something else
    1 point
  8. Yes, you have to choose between the 2 modes, either OnEvent mode or GuiGetMsg mode. You can't use both together So in your code if you choose OnEvent mode, then you have to create a function to be launched using $Button2 and GUICtrlSetOnEvent($Button2, "_func_for_button2")
    1 point
  9. It took ages for the script to get loaded. I'm sure your script exceeds some limit - but caused by the way your script works it is impossible to debug. Why don't you install the game in the "official" way?
    1 point
  10. ...and the last one, based on the 3rd example from here, the OnEventMode way #include <GUIConstantsEx.au3> Opt("GuiOnEventMode", 1) Global $stop = 1 Local $aArray[10] = ["Num1", "Num2", "Num3", "Num4", "Num5", "Num6", "Num7", "Num8", "Num9", "Num10"] $Form1 = GUICreate("Form1", 489, 353, 192, 130) GUISetOnEvent($GUI_EVENT_CLOSE, "_exit") $ButtonStartStop = GUICtrlCreateButton("Start", 176, 248, 75, 25) GUICtrlSetOnEvent(-1, "_stop") $Edit1 = GUICtrlCreateEdit("", 104, 48, 233, 129) GUISetState(@SW_SHOW) While 1 Sleep(10) If not $stop Then _loop() WEnd Func _stop() $stop = not $stop EndFunc Func _loop() Local Static $index For $i = $index To UBound($aArray)-1 If $stop Then GUICtrlSetData($ButtonStartStop, "Start") Exitloop Else $index += 1 GUICtrlSetData($ButtonStartStop, "Stop") GUICtrlSetData($Edit1, $aArray[$i] & @CRLF,1) If $index = UBound($aArray) Then GUICtrlSetData($ButtonStartStop, "End !") Sleep(500) EndIf Next EndFunc Func _exit() Exit Msgbox(0,"", "bye") EndFunc Edit "I do not understand what you said." Yes. @iamtheky sometimes has an alien way of thinking that we humans cant understand ...
    1 point
  11. Pull messages in the loop: $msg = GUIGetMsg() It's not beautiful, but it's what you're asking for I think. $counterStart = 0 For $i = $counterStart To UBound($aArray)-1 If GUIGetMsg() = $idButton Then $counterStart = $i ExitLoop EndIf Next Never-mind, I'm not prepared to solve this atm. I shouldn't have said anything. My bad
    1 point
  12. That was my answer above
    1 point
  13. Added JsonDump() and updated/attached a new Zipfile in first post Jos
    1 point
  14. Zedna

    File link in system tray

    #Include <File.au3> #Include <Array.au3> #include <Process.au3> #Include <Constants.au3> Opt("TrayMenuMode", 1) ; Default tray menu items (Script Paused/Exit) will not be shown. Opt("TrayOnEventMode",1) $FileList = _FileListToArray("C:\Program Files\") ;set to this folder just to test If @error Then MsgBox(0, "", "No Files\Folders Found.") Exit EndIf Dim $ItemList[UBound($FileList)] ;~ $ItemList[0] = UBound($FileList) - 1 For $i = 1 to UBound($FileList) - 1 $ItemList[$i] = TrayCreateItem($FileList[$i]) TrayItemSetOnEvent(-1,'MyTrayEvent') Next TraySetState() While 1 Sleep(100) WEnd Func MyTrayEvent() For $i = 1 to UBound($ItemList) - 1 If $ItemList[$i] = @TRAY_ID Then MsgBox(0,'Info',$FileList[$i]) ExitLoop EndIf Next EndFunc
    1 point
×
×
  • Create New...