Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 08/18/2020 in all areas

  1. Hello. It's not a a bug. In the "Registry Virtualization Scope"->"Registry virtualization is disabled for the following:" section says: Processes that have requestedExecutionLevel specified in their manifests. So for that reason You don't get the virtualization Enabled. If you run from Scite It will not work at least you edit the AutoIt.exe executable and remove "requestedExecutionLevel" line from manifest. If You run compiling your .au3 just add #AutoIt3Wrapper_res_requestedExecutionLevel=None on the top of your script and build it. Saludos PD: took me about 20 minutes to get loaded the input for write the message due to my internet speed. 😭
    2 points
  2. Yashied

    Restart UDF

    LAST VERSION - 1.0 07-Mar-10 This is my very simple and small UDF. Allows you to restart the script from any location with full restoration of the original command line parameters. I use this library in several of my programs, and I was not disappointed. I hope this UDF will be useful for many as for me. I will be glad to any feedback and suggestions. Restart UDF Library v1.0 Previous downloads: 943 Restart.au3 Example #NoTrayIcon #Include <Misc.au3> #Include <Restart.au3> _Singleton('MyProgram') If MsgBox(36, 'Restarting...', 'Press OK to restart this script.') = 6 Then _ScriptRestart() EndIf
    1 point
  3. @Fractured Workbooks have names and Worksheets have names. The Excel Object Model lets you specify those names using the object model's object, properties, and methods. I just used ActiveWorkbook & Activesheet as shortcuts. You can name the workbook that you want to reference by doing something like Application.WorkBooks("Book1") and similarly Workbooks("Book1").Sheets("sheet1") . So you could copy a range from Book1.Sheet1 to Book2.Sheet1 (if that makes sense). If you need a better explanation or example, please ask. Quick & Dirty Example of naming the workbook or sheet that you want to reference: #include <Excel.au3> example() Func example() Local $oExcel $oExcel = _Excel_Open() _Excel_BookNew($oExcel) _Excel_BookNew($oExcel) ;Write A-Z across row 1 to Book1 For $iCol = 1 To 26 ;Cols A-Z $oExcel.Workbooks("book1").Sheets("Sheet1").Cells(1, $iCol) = Chr(Asc("A") + ($iCol - 1)) Next ;Write Z-A across row 1 to Book2 For $iCol = 26 To 1 Step -1 ;Cols Z-A $oExcel.Workbooks("book2").Sheets("Sheet1").Cells(1, $iCol) = Chr(Asc("Z") - ($iCol - 1)) Next EndFunc
    1 point
  4. Ok..you rock! Now ive got some knowledge and some reading to do and Ill be all over this! Thanks!
    1 point
  5. A quick & dirty example: #include <Excel.au3> example() Func example() Local $oExcel $oExcel = _Excel_Open() _Excel_BookNew($oExcel) ;Write A-Z across Row 1 For $iCol = 1 To 26 ;Cols A-Z $oExcel.ActiveWorkBook.ActiveSheet.Cells(1, $iCol) = Chr(Asc("A") + ($iCol - 1)) Next EndFunc As you can see, .Cells lets you specify a cell by its row and col. The example above merely writes the characters across row 1.
    1 point
  6. Try Send("^!+s") The keys are always sent to the current window. In doubt, it's good to check if the active window is really Photoshop.
    1 point
  7. Thank you Danyfirex! 👍 I will do investigating and later I will post here results ... EDIT: Yes. You are right. Default manifest's ExecLevel is "asInvoker" (I expected none) and after adding pragma compile level=none it works like it should work. Directive for old AutoIt's versions: #AutoIt3Wrapper_res_requestedExecutionLevel=None Directive for new AutoIt's versions: #pragma compile(ExecLevel, none)
    1 point
  8. Just add the following line twice, after GUICtrlCreateIcon() and after GUICtrlCreateButton() GUICtrlSetResizing(-1, $GUI_DOCKALL)
    1 point
  9. @WinWiesel If you are working with JSON data, are you aware that JSON parsers and processors automatically encode and decode JSON as needed? It is a part of the specification. Below is a brief example that takes encoded JSON, decodes it, displays the decoded JSON fields, adds another JSON field and redisplays the encoded JSON. Notice that string3 is entered in its original form and encoded by the parser. Json.au3 is a JSON parser based on JSMN. You can read more about it in the associated link that I provided in the example. #include <Constants.au3> #include <json.au3> ;https://www.autoitscript.com/forum/topic/148114-a-non-strict-json-udf-jsmn/ Const $JSON = '{' & _ '"string1" : "\u4e3a\u4e86\u9632\u6b62\u5723\u7269\u91d1\u5777\u5783\u843d\u5165\u4fb5\u7565\u8005\u7684\u624b\u4e2d\uff0c\u5723\u5730\u4e9a\u6208\u5927\u9646\u4e0a\u7684\u6218\u58eb\u4eec\u7eb7\u7eb7\u633a\u8eab\u800c\u51fa\u3002",' & _ '"string2" : "F1\u00ae 2020 allows you to create your F1\u00ae team whatever"' & _ '}' Global $oJson = Json_Decode($JSON) ;Display encoded JSON WriteNotepadLogLine("Original Encoded JSON") WriteNotepadLogLine(Json_Encode($oJson, $JSON_PRETTY_PRINT)) ;Parse and display JSON fields WriteNotepadLogLine() WriteNotepadLogLine("Parse decoded JSON") WriteNotepadLogLine("String 1 = " & Json_Get($oJson, ".string1")) WriteNotepadLogLine("String 2 = " & Json_Get($oJson, ".string2")) ;Add a 3rd JSON field and redisplay encoded JSON Json_Put($oJson, ".string3", "为了防止圣物金坷垃落入侵略者的手中") WriteNotepadLogLine() WriteNotepadLogLine("Encoded JSON with New Field") WriteNotepadLogLine(Json_Encode($oJson, $JSON_PRETTY_PRINT)) Func WriteNotepadLogLine($sMsg = "") Const $TITLE_NOTEPAD = "[RegExpTitle:Untitled - Notepad]" Static $hWndNotepad = -1 ;If we don't have a handle to notepad yet If $hWndNotepad = -1 Then ;If there isn't an existing instance of notepad running, launch one If Not WinExists($TITLE_NOTEPAD) Then Run("Notepad.exe") ;Get handle to notepad window $hWndNotepad = WinWait($TITLE_NOTEPAD, "", 3) If Not $hWndNotepad Then Exit MsgBox($MB_ICONERROR, "ERROR", "Unable to find Notepad window.") EndIf ;Write to Notepad If WinExists($hWndNotepad) Then ControlCommand($hWndNotepad, "", "Edit1", "EditPaste", $sMsg & @CRLF) EndFunc Output: Original Encoded JSON { "string1": "\u4e3a\u4e86\u9632\u6b62\u5723\u7269\u91d1\u5777\u5783\u843d\u5165\u4fb5\u7565\u8005\u7684\u624b\u4e2d\uff0c\u5723\u5730\u4e9a\u6208\u5927\u9646\u4e0a\u7684\u6218\u58eb\u4eec\u7eb7\u7eb7\u633a\u8eab\u800c\u51fa\u3002", "string2": "F1® 2020 allows you to create your F1® team whatever" } Parse decoded JSON String 1 = 为了防止圣物金坷垃落入侵略者的手中,圣地亚戈大陆上的战士们纷纷挺身而出。 String 2 = F1® 2020 allows you to create your F1® team whatever Encoded JSON with New Field { "string1": "\u4e3a\u4e86\u9632\u6b62\u5723\u7269\u91d1\u5777\u5783\u843d\u5165\u4fb5\u7565\u8005\u7684\u624b\u4e2d\uff0c\u5723\u5730\u4e9a\u6208\u5927\u9646\u4e0a\u7684\u6218\u58eb\u4eec\u7eb7\u7eb7\u633a\u8eab\u800c\u51fa\u3002", "string2": "F1® 2020 allows you to create your F1® team whatever", "string3": "\u4e3a\u4e86\u9632\u6b62\u5723\u7269\u91d1\u5777\u5783\u843d\u5165\u4fb5\u7565\u8005\u7684\u624b\u4e2d" }
    1 point
  10. This script sequentially renames all remaining sections of an .ini file after deleting one of the sections. Local $sFileName = "TestIni.ini" ; --------- Create a test .ini file ---------- If FileExists($sFileName) Then FileDelete($sFileName) FileWrite($sFileName, StringRegExpReplace(FileRead(@ScriptFullPath), "(?s)(^.*#cs\R|\R#ce.*$)", "")) ; -------- End of Create .ini file ----------- _DeleteSect($sFileName, 2) Run('Notepad.exe "' & $sFileName & '"') Func _DeleteSect($sFilePath, $Sect) IniDelete($sFilePath, $Sect) $aArray = IniReadSectionNames($sFilePath) For $i = 1 To $aArray[0] IniRenameSection($sFilePath, $aArray[$i], $i) Next ; Format and save .ini file Local $sFileContents = FileRead($sFilePath) FileDelete($sFilePath) FileWrite($sFilePath, StringStripWS(StringRegExpReplace($sFileContents, "\s*(\[\d+\])", @CRLF & @CRLF & "$1"), 3) & @CRLF) ; (1) = strip leading white spaces, and, (2) = strip trailing white spaces EndFunc ;==>_DeleteSect #cs [1] s = 1 m = 4 [2] h = 2 j = 7 k = 9 l = 22 r = 99 [3] a = 0 l = 111 y = 88 w = 90 [4] d =0 #ce
    1 point
  11. MONaH-Rasta, I rarely want to pause my scripts - they are usually designed to work full-time! But there are many ways to pause scripts programmatically - just search the forum and you will find many examples of how to do it. As an aside, I quite often use TrayOnEvent mode for the tray menu, while retaining MessageLoop mode for the main idle loop. That way the tray items get actioned instantly and are not affected by any ongoing functions within the main script. Why is that important? The Interrupting a running function tutorial in the Wiki will explain. M23
    1 point
  12. There are three ways you can posts scripts, these are: Inline code Attachments Download system Each has different advantages and disadvantages. In general you should use: Inline code - for short code snippets Attachments - for more complicated code larger than a page. Downloads system - for projects or complex libraries Inline Code Best for entering short snippets of code Easiest for other users to see May be accidentally modified by forum upgrades or when re-editing your post - it's happened before... Inline code is entered using the "Add Code" button in the toolbar and after posting appears with syntax highlighting like this: ; This is some AutoIt code MsgBox(4096, "Message", "Hello there!") Code over around 50 lines will appear in a scrollable box. At this point it becomes more difficult for other users to work with and you should consider an attachment instead. Attachments Best for long pieces of code, entire programs, or multiple files Unlikely to be accidentally lost or modified by forum upgrades or when re-editing your post Counts against your global attachment allocation Can be seen in the "username / My Attachments" part of your profile, along with the number of downloads Multiple attachments can be added to a post. As attachments are stored as complete files in the filesystem, they are more robust than inline code snippets. Downloads System Best for very long and complicated projects or libraries that are of significant use to the community Uses a different part of the forum that is optimised for file downloads and features screenshots, change logs, download counts, etc. Does not count against your global attachment allocation This can be accessed here: Downloads System.
    1 point
  13. Melba23

    Two GUI windows

    krasnoshtan, The Managing Multiple GUIs tutorial in the Wiki will explain how to do this. M23
    1 point
  14. jpujut, Interesting problem - here is my best effort so far: #include <TrayConstants.au3> Opt("TrayOnEventMode", 1) ; Use event trapping for tray menu Opt("TrayMenuMode", 3) ; Default tray menu items will not be shown. ; Flag to show if update has occurred Global $fUpdate = False $cTray_Change_Item = TrayCreateItem("Item set at " & @SEC) TrayCreateItem("") $cTray_Exit_Item = TrayCreateItem("Exit") TrayItemSetOnEvent($cTray_Exit_Item, "_Exit") ; Update tray when mouse first goes over TraySetOnEvent($TRAY_EVENT_MOUSEOVER, "_Update_Tray") While 1 Sleep(10) WEnd Func _Update_Tray() ; If not already updated If Not $fUpdate Then ; Run update code ConsoleWrite("Updating at: " & @SEC & @CRLF) TrayItemSetText($cTray_Change_Item, "Item set at " & @SEC) ; Set flag to show update completed $fUpdate = True ; Register Adlib to clear flag after 1 sec AdlibRegister("_Reset_UpDate", 1000) ConsoleWrite("Adlib set" & @CRLF) EndIf EndFunc Func _Reset_UpDate() AdlibUnRegister("_Reset_Update") $fUpdate = False ConsoleWrite("Reset" & @CRLF) EndFunc Func _Exit() Exit EndFunc It updates the tray when the mouse first goes over the icon, sets a flag to prevent multiple updates, and sets a timer to clear the flag after 1 sec - this timer does not run until after the menu is closed, so the delay could be even shorter. Please ask if you have any questions. M23
    1 point
  15. BrewManNH

    ByRef explanation

    Normally when you pass a value to a function, the value stays inside the function as the variable you assigned to it. When you pass it ByRef, a copy of the original variable is passed and anything done to the byref variable is reflected in the value of the variable you passed to that function. Global $test = 123 FuncNotByRef($test) ConsoleWrite("Value of $test after the function = " & $test & @CRLF) FuncByRef($test) ConsoleWrite("Value of $test after the function = " & $test & @CRLF) Func FuncNotByRef($incoming) ConsoleWrite("Value of $incoming = " & $incoming & @CRLF) $incoming = 456 ConsoleWrite("Value of $incoming is now = " & $incoming & @CRLF) EndFunc ;==>FuncNotByRef Func FuncByRef(ByRef $incoming) ConsoleWrite("Value of $incoming = " & $incoming & @CRLF) $incoming = 456 ConsoleWrite("Value of $incoming is now = " & $incoming & @CRLF) EndFunc ;==>FuncByRef
    1 point
  16. Yashied

    Restart UDF

    Wow! It turns out that it was in demand. Thanks.
    1 point
×
×
  • Create New...