Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 02/21/2023 in all areas

  1. Probably main problem is this: Do Sleep(1000) ; wait 1 second before checking again Until Not $result $result is an array, not really something that you can do good checking against to determine true/false by itself. Also, you are NOT doing any checks to see if the color is still there. Also this part: Local $color = "0x6EC89B" ; the color you are looking for (green) Local $result = PixelSearch(0, 137, 1, 465, 0xE8E9F1, 0) You're searching a different color than $color, because you're not using $color for the call. Also the 0 at the end of the function means that the color must match exactly, it may be a good idea to allow some variance. Next up this part: Opt("PixelCoordMode", 2) ; WinActivate($hGui) PixelCoordMode 2 means relative to the client, however you're changing what the client is with WinActivate, so your PixelSearch will now be searching the wrong coordinates. Also deleting the GUI and re-making it isn't the best idea. Check out my modifications (still set up to test on my computer, so your color and search location are different): #include <GuiConstants.au3> OnAutoItExitRegister('__Exit') AutoItSetOption("PixelCoordMode", 1) ; 1 = Screen coords, 2 = relative to Client AutoItSetOption("WinWaitDelay", 50) Global $hGui = Null, $hTimer Global $iColor = "0x5379BD" ; the color you are looking for (green) Global $iState, $iColorShadeVariation = 10 Global $aResult, $aWinPos, $aGuiPos[2] = [350, 907], $aSearchPos[4] = [2797, 791, 2798, 792] $hGui = GUICreate("Disabled", 180, 60, $aGuiPos[0], $aGuiPos[1], $WS_DISABLED, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW)) ; $WS_DISABLED to prevent moving/resizing, $WS_EX_TOOLWINDOW so that it doesn't create an icon in the taskbar GUISetState(@SW_HIDE, $hGui) ; Make sure the GUI is initially hidden GUISetState(@SW_DISABLE, $hGui) ; Make sure the GUI is disabled, so it can't be messed with While 1 Sleep(10) ; Small sleep to avoid thrashing the CPU $aResult = PixelSearch($aSearchPos[0], $aSearchPos[1], $aSearchPos[2], $aSearchPos[3], $iColor, $iColorShadeVariation) If Not @error And IsArray($aResult) Then ; PixelSearch was successful ;~ ConsoleWrite('Success: ' & $aResult[0] & ', ' & $aResult[1] & @CRLF) GUISetState(@SW_SHOW, $hGui) ; Show our 'Disabled' GUI WinMove($hGui, '', $aGuiPos[0], $aGuiPos[1], Default, Default, 0) ; Move to the correct position WinSetOnTop($hGui, "", 1) ; Make sure it's set ontop ;~ WinActivate($hGui) ; We have no need to activate the window Do ; With the window disabled it can't be moved, so this below code isn't needed (or shouldn't be) to keep it in place ;~ $aWinPos = WinGetPos($hGui) ;~ If $aWinPos[0] <> $aGuiPos[0] Or $aWinPos[1] <> $aGuiPos[1] Then ;~ WinMove($hGui, '', $aGuiPos[0], $aGuiPos[1], Default, Default, 0) ;~ EndIf Sleep(10) ; Small wait to check again to avoid thrashing the CPU, but not so long that it's a hinderance $aResult = PixelSearch($aSearchPos[0], $aSearchPos[1], $aSearchPos[2], $aSearchPos[3], $iColor, $iColorShadeVariation) Until @error Or Not IsArray($aResult) ; Go until the PixelSearch fails GUISetState(@SW_HIDE, $hGui) ; Hide the GUI Else ; PixelSearch failed, we did not find the color you were looking for ;~ ConsoleWrite('Not found' & @CRLF) $iState = WinGetState($hGui) ; Get the GUI state If BitAND($iState, $WIN_STATE_VISIBLE) Then ; If it's visible... GUISetState(@SW_HIDE, $hGui) ; Hide it EndIf EndIf WEnd Func __Exit() GUIDelete($hGui) EndFunc ;==>__Exit Edit: Also completely agree with @SOLVE-SMART, it looks like you're zoomed to 110%, and you'll likely have the incorrect coordinates with a different zoom level, browser, theme, screen resolution, window size, etc. This is definitely not the best way to do what you want to do.
    2 points
  2. Version v1.7.4

    927 downloads

    This UDF brings the power and flexibility of jq to AutoIt scripts. jq is an open-source, powerful, and flexible command-line based JSON processor. As it says on their website, jq is like 'sed' for JSON. jq can be used for the simplest of tasks like retrieving JSON objects and values (parsing), to very advanced JSON processing using its numerous built-in functions and conditional processing. Its built-in functions can handle math, selection, conditional processing, mapping, object and array manipulation, flattening, reduction, grouping, and much more. You can even create your own jq functions. You can learn more about jq and even play with it in real-time, using jq's online jq playground, all on their website. Here and some helpful links to get you more familiar with jq, what can be done with it, its built-in functions, and its syntax. jq Home Page: https://jqlang.github.io/jq/ jq Manual: https://jqlang.github.io/jq/manual/ jqWiki (FAQ, Cookbook, Advanced Topics) https://github.com/jqlang/jq/wiki jq is a single 32 or 64 bit executable that has no other dependencies. Just like using the SQLite UDF, the only requirement to use this UDF is that the jq executable reside in a location in which the UDF can execute it. The latest win32 & win64 versions have been included in the UDF download. You can always get newer versions from the jq website. jq at a high level Like 'sed', jq reads JSON in, either through STDIN or one or more files, processes it thru one or more "filters", and outputs the results. You can, optionally, supply "options" that affect how it reads the input, where it gets its "filters", and how it writes its output. It looks a little like this: JSON ---> jq processor (using supplied filters and options) ---> Output So in jq lingo, you basically use "Filters" to tell jq what you want it to do. So in the UDF file, that is why the main functions ( _jqExec() and _jqExecFile() ) refer to filters and options. Please make note that jq works with relatively strict JSON. This means that all JSON read must be conform to the standard. Luckily, jq is pretty good at identifying where a format error exists in non standard JSON. The jq UDF There are 2 main funtions in the UDF file, _jqExec and jqExecFile. With these 2 functions, you can pretty much do anything that jq can do. The only difference between to two functions is whether the JSON is supplied by a string or a file. The 2 primary functions simply call the jq executable with the supplied information, after properly formatting the parameters. There are additional functions in the UDF to easily pretty-print your json, compact-print your json, dump the json data with its associated paths, and see if specific JSON keys exist, but they all just execute the _jqExec or _jqExecFile function with the proper filter. There are also a couple of extra functions to display what version of the UDF and jq executable you are currently using. There are also a couple of functions to enable and disable logging of jq information for debugging purposes. Most of the jq UDF file functions return an @error if unsuccessful. Some also include @extended info. Please see the actual function headers for more information on their usage and return values. The 2 primary functions below just format your jq request and pass it on the jq executable. The functions will also properly escape double quotes (") that are used in the filter. For most simple tasks, you just need to supply the JSON source and a filter. _jqExec($sJson, $sFilter, $sOptions = Default, $sWorkingDir = Default) Or _jqExecFile($sJsonFile, $sFilter, $sOptions = Default, $sWorkingDir = Default) Using jq in your script As stated earlier, the jq executable must reside somewhere where the script can locate and execute it. The _jqInit() function always has to be executed before any jq processing occurs. _jqInit() merely locates the executable or uses the supplied path. It also clears any previous debug log. The jq UDF folder contains a jq example script that has several examples to how to do some of the most common JSON processing tasks. Here are a few examples to get you started: How to pretty-print some JSON #include "jq.au3" ;Initialize jq environment _jqInit() If @error Then Exit ConsoleWrite("ERROR: Unable to initialize jq - @error = " & @error & @CRLF) $sJson = '{"fruits":[{"Apple":{"color":"Red","season":"Fall"}}, {"Banana":{"color":"Yellow","season":"Summer"}}]}' $sCmdOutput = _jqPrettyPrintJson($sJson) ConsoleWrite(@CRLF & "Pretty-Print JSON" & @CRLF & $sCmdOutput & @CRLF) How to compact-print some JSON #include "jq.au3" ;Initialize jq environment _jqInit() If @error Then Exit ConsoleWrite("ERROR: Unable to initialize jq - @error = " & @error & @CRLF) $sJson = '{ "fruits" : [{"Apple" : {"color":"Red","season":"Fall"}}, {"Banana":{"color":"Yellow","season":"Summer"}}]}' $sCmdOutput = _jqCompactPrintJson($sJson) ConsoleWrite(@CRLF & "Compact-Print JSON" & @CRLF & $sCmdOutput & @CRLF) Dump JSON data (paths and values) #include "jq.au3" ;Initialize jq environment _jqInit() If @error Then Exit ConsoleWrite("ERROR: Unable to initialize jq - @error = " & @error & @CRLF) $sJson = '{ "fruits" : [{"Apple" : {"color":"Red","season":"Fall"}}, {"Banana":{"color":"Yellow","season":"Summer"}}]}' $sCmdOutput = _jqDump($sJson) ConsoleWrite(@CRLF & "Dump JSON paths and values" & @CRLF & $sCmdOutput & @CRLF) How to GET JSON values #include "jq.au3" ;Initialize jq environment _jqInit() If @error Then Exit ConsoleWrite("ERROR: Unable to initialize jq - @error = " & @error & @CRLF) $sJson = '{"Apple" : {"color":"Red","season":"Fall"}, "Banana":{"color":"Yellow","season":"Summer"}}' $sFilter = '.Banana.color' $sCmdOutput = _jqExec($sJson, $sFilter) ConsoleWrite("Get color of banana" & @CRLF) ConsoleWrite("Input: : " & _jqCompactPrintJson($sJson) & @CRLF) ConsoleWrite("Filter : " & $sFilter & @CRLF) ConsoleWrite("Output : " & $sCmdOutput & @CRLF) or #include "jq.au3" ;Initialize jq environment _jqInit() If @error Then Exit ConsoleWrite("ERROR: Unable to initialize jq - @error = " & @error & @CRLF) $sJson = '{"Apple" : {"color":"Red","season":"Fall"}, "Banana":{"color":"Yellow","season":"Summer"}}' $sFilter = 'getpath(["Banana", "color"])' $sCmdOutput = _jqExec($sJson, $sFilter) ConsoleWrite("Get color of banana" & @CRLF) ConsoleWrite("Input: : " & _jqCompactPrintJson($sJson) & @CRLF) ConsoleWrite("Filter : " & $sFilter & @CRLF) ConsoleWrite("Output : " & $sCmdOutput & @CRLF) Check for the existence of a key #include "jq.au3" ;Initialize jq environment _jqInit() If @error Then Exit ConsoleWrite("ERROR: Unable to initialize jq - @error = " & @error & @CRLF) $sJson = '{"Apple":{"color":"Red","season":"Fall"}, "Banana":{"color":"Yellow","season":"Summer"}}' $sFilter = '.Banana | has("color")' $sCmdOutput = _jqExec($sJson, $sFilter) ConsoleWrite("Check for existence of color key within Banana object" & @CRLF) ConsoleWrite("Input: : " & _jqCompactPrintJson($sJson) & @CRLF) ConsoleWrite("Filter : " & $sFilter & @CRLF) ConsoleWrite("Output : " & $sCmdOutput & @CRLF) Count of how many Items in an object #include "jq.au3" ;Initialize jq environment _jqInit() If @error Then Exit ConsoleWrite("ERROR: Unable to initialize jq - @error = " & @error & @CRLF) $sJson = '{"Apple":{"color":"Red"}, "Banana":{"color":"Yellow","season":"Summer"}}' $sFilter = '.Banana | length' $sCmdOutput = _jqExec($sJson, $sFilter) ConsoleWrite("How many items in the Banana object" & @CRLF) ConsoleWrite("Input: : " & _jqCompactPrintJson($sJson) & @CRLF) ConsoleWrite("Filter : " & $sFilter & @CRLF) ConsoleWrite("Output : " & $sCmdOutput & @CRLF) How to PUT/Create/Modify JSON #include "jq.au3" ;Initialize jq environment _jqInit() If @error Then Exit ConsoleWrite("ERROR: Unable to initialize jq - @error = " & @error & @CRLF) $sInput = "" $sFilter = 'setpath(["Apple","color"];"Red") | setpath(["Banana","color"];"Yellow") | setpath(["Banana","season"];"Summer")' $sOptions = '-n' ;required if no input supplied $sCmdOutput = _jqExec($sInput, $sFilter, $sOptions) ConsoleWrite("Update/Create JSON" & @CRLF) ConsoleWrite("Filter : " & $sFilter & @CRLF) ConsoleWrite("Output : " & @CRLF & $sCmdOutput & @CRLF) List all of the fruits (top-level keys) #include "jq.au3" ;Initialize jq environment _jqInit() If @error Then Exit ConsoleWrite("ERROR: Unable to initialize jq - @error = " & @error & @CRLF) $sJson = '{"Apple":{"color":"Red"}, "Banana":{"color":"Yellow","season":"Summer"}}' $sFilter = 'keys | .[]' $sCmdOutput = _jqExec($sJson, $sFilter) ConsoleWrite("List all top-level keys (fruits)" & @CRLF) ConsoleWrite("Input : " & $sJson & @CRLF) ConsoleWrite("Filter : " & $sFilter & @CRLF) ConsoleWrite("Output : " & @CRLF & $sCmdOutput & @CRLF) Calculate the sum of all of the objects' price * qty #include "jq.au3" ;Initialize jq environment _jqInit() If @error Then Exit ConsoleWrite("ERROR: Unable to initialize jq - @error = " & @error & @CRLF) $sJson = '[{"id":1,"price":20.00,"qty":10},{"id":2,"price":15.00,"qty":20.25},{"id":3,"price":10.50,"qty":30}]' $sFilter = 'map(.price * .qty) | add' $sCmdOutput = _jqExec($sJson, $sFilter) ConsoleWrite("Calculate the sum of all of the objects' price * qty" & @CRLF) ConsoleWrite("Input : " & $sJson & @CRLF) ConsoleWrite("Filter : " & $sFilter & @CRLF) ConsoleWrite("Output : " & $sCmdOutput & @CRLF) The examples above, and the ones in the example files, merely scratch the surface of what jq can do. It may look intimidating at first but it really isn't that bad once you start playing with it. You can find several more examples and play around with them or create your own using jqPlayground. If you have any questions regarding the UDF, or how to perform a certain task using jq, I'll try my best to answer them. Since jq has been around for a while now, there's also several jq-related questions and answers on StackOverflow.
    1 point
  3. Version v1.3.5

    305 downloads

    Create / Test / Learn JSON Processing jqPlayground is an interactive, jq-based, tool created using AutoIt. The purpose of the tool is to help in the creation, testing, and understanding of JSON filters/queries used in the processing of JSON datasets. Internally, it uses the jq UDF for all JSON processing. The dot and bracket notation access in jq are similar to other existing AutoIt JSON parsing UDFs and tools. Therefore, jqPlayground can be used as a general purpose testing & learning tool, regardless of the ultimate UDF or utility you choose to use. jqPlayground comes with numerous examples to help you see and understand how it can be used for simple parsing and much more advanced JSON processing. You can modify and play with the example filters or you can create and test your own. CONFIGURATION The only requirement needed to run jqPlayground is that it can find a jq executable. JQ executables can be found on the JQ website on the home page, its download section, or as a part of my JQ UDF in the AutoIt Downloads section. The latest jq executables have been included in the zip file. jqPlayground will look for the jq executable in the following order of precedence: 1. If a jqPlayground.ini file exists in the script directory, it will get the path to the jq executable under to following section and key: [CONFIG] JqExePath=<full path to jq exe> 2. A jq-win32.exe or jq-win64.exe, depending on the OS, in the script directory. 3. A jq.exe in the script directory. USAGE The interface is pretty simple and straight forward. Paste, load or write whatever JSON you want to play with in the INPUT section. Paste or write whatever parsing or processing filter(s) you want to test in the FILTER section. If necessary, you can select or enter any jq-specific flags you want. Then, either press the RUN button, F5 or CTRL+ENTER to execute your filter. You will see the output in the OUTPUT section. If your command was not successful, you will see the error message generated by JQ in the output section. There are also numerous examples that can be selected from EXAMPLES dropdown list. Upon selecting an example, it populates the filter, flags, and input as necessary. It then executes the example, showing the output in the OUTPUT section. The examples use one of 2 JSON datasets. BOOKS is a small, simple, JSON dataset that contains a catalog of book information. The NFL JSON dataset is much larger and complex. It is a snapshot of NFL game information during week 1 of the 2018 regular season. Some of the NFL JSON dataset examples really show off the speed and processing capabilities of JQ. If you want to dump the full path of every scalar JSON value in your JSON dataset, you can type "dump" in the FILTER section and press F5, CTRL+ENTER or the RUN button. The output is the same as the jqDump() function in the jq UDF. "Dump" is not a jq filter command. It is a special command that I added to help those new to JSON understand how to access a given JSON value using dot-notation. Lastly, right below the output section, you will see the time it took to execute your filter. This can be useful to those in which timimg is a major concern. jqPlayground HotKeys -------------------- Open the online jq manual - F1 Run the jq filter - F5 or Ctrl+Enter Clear/reset all fields - Alt+C Load a JSON from a file - Alt+L Save your current session - Ctrl+S Load a saved session - Ctrl+L Special Commands (Enter and run in filter) ------------------------------------------ dump - List full path of every scalar JSON value clear - Clear/reset all fields (same as Alt+C) USEFUL LINKS jq Home Page: https://jqlang.github.io/jq/ jq Manual: https://jqlang.github.io/jq/manual/ jq Downloads: https://jqlang.github.io/jq/download/ jq Tutorial: https://jqlang.github.io/jq/tutorial/ jq Wiki: https://github.com/jqlang/jq/wiki
    1 point
  4. AZJIO

    FindAllReferences

    FindAllReferencesSciTE screenshot Tool for SciTE to show all lines of code containing the selected keyword. Working with the program: 1. Select a function, variable, keyword or something else, or simply put the cursor on the word without selecting anything and press the hot key. 2. In the window that appears, there will be a table of all found lines with this word and the line number. Clicking on a line scrolls the SciTE code to the position of that line and you can edit at that point. Clicking in the header returns to its original position. 3. You can choose one of the ready-made regular expressions, for example "find all cycles", etc. and navigate through these elements. You can enter your regular expression and press Enter. 4. The window retains its dimensions, so drag to the right and increase in height. Download: yandex, upload.ee
    1 point
  5. I think it does work if you use the updated version by @AutoBert. I have not done much testing but everything seems to be working.
    1 point
  6. Two fingers on a trackpad doesn't create 2 sets of coordinates that AutoIt can read/access as far as I know. I'm pretty sure that all of that multi-finger gesturing is handled by the trackpads drivers, and converts the gestures into events/messages for the OS to handle. I would imagine you'd need do some pretty advanced things to get any usable data from multi-point gesturing on a trackpad/screen. Something like https://www.autoitscript.com/autoit3/docs/libfunctions/_WinAPI_SetWindowsHookEx.htm Or:
    1 point
  7. I know, @jacky998877, the purpose of the code was to show "a example" and I thought you will be able to adjust the rest on your own. Just remove _IsWindowActive() and this should be it 🤞 . #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #AutoIt3Wrapper_AU3Check_Stop_OnWarning=y #AutoIt3Wrapper_Run_Au3Stripper=y #AutoIt3Wrapper_UseUpx=n #Au3Stripper_Parameters=/sf /sv /mo /rm /rsln Global $sTargetWindowTitle = 'Downloads' While True Sleep(100) If _IsMouseOnWindow($sTargetWindowTitle) Then MsgBox('', 'Mouse on window', 'Handle: ' & WinGetHandle($sTargetWindowTitle)) ExitLoop EndIf WEnd Func _IsMouseOnWindow($sWindowTitle) Local $aMouse = MouseGetPos() Local $aWindow = WinGetPos($sWindowTitle) If $aMouse[0] >= $aWindow[0] And _ $aMouse[1] >= $aWindow[1] And _ $aMouse[0] <= $aWindow[0] + $aWindow[2] And _ $aMouse[1] <= $aWindow[1] + $aWindow[3] Then Return True EndIf Return False EndFunc Best regards Sven
    1 point
  8. Recently somebody asked how it could possible to manage the new feature of Virtual Desktop under Windows 10. With the incentive of @KaFu I started to get something together that could be useful. Since this code was never released under AutoIt, I felt it could serve as a good example. Let me know what you think. Version 2021-09-19 * Added support to IApplicationView and IVirtualDesktopPinnedApps interfaces (see example 2) Example 1. The documented interface of IVirtualDesktopManager offers a very limited list of methods. Someone may ask WTF is it useful for ? Well, I don't have an answer for that. #include <Constants.au3> #include <GUIConstants.au3> If @OSVersion <> "WIN_10" Then Exit MsgBox($MB_SYSTEMMODAL, "", "This script only runs on Win 10") ; VirtualDesktopManager object Local $CLSID_VirtualDesktopManager = "{aa509086-5ca9-4c25-8f95-589d3c07b48a}" Local $IID_IVirtualDesktopManager = "{a5cd92ff-29be-454c-8d04-d82879fb3f1b}" Local $tagIVirtualDesktopManager = _ "IsWindowOnCurrentVirtualDesktop hresult(hwnd;bool*);" & _ "GetWindowDesktopId hresult(hwnd;clsid*);" & _ "MoveWindowToDesktop hresult(hwnd;clsid);" ; object creation Local $oVDM = ObjCreateInterface($CLSID_VirtualDesktopManager, $IID_IVirtualDesktopManager, $tagIVirtualDesktopManager) ConsoleWrite(IsObj($oVDM) & @CRLF) ; create process owned window Local $hWnd = GUICreate("Test"), $bActive GUISetState() ; check if window is on current desktop (not mandatory to own the window) Local $iHresult = $oVDM.IsWindowOnCurrentVirtualDesktop($hWnd, $bActive) ConsoleWrite($iHresult & "/" & $bActive & @CRLF) ; returns the CLSID of the desktop where the window resides Local $sCLSID $iHresult = $oVDM.GetWindowDesktopId($hWnd, $sCLSID) ConsoleWrite($iHresult & "/" & $sCLSID & @CRLF) Local $hNote = WinGetHandle("[CLASS:Notepad]") $iHresult = $oVDM.GetWindowDesktopId($hNote, $sCLSID) ; (not mandatory to own the window) ConsoleWrite($iHresult & "/" & $sCLSID & @CRLF) ; moves the window to a specific desktop (mandatory to own the window) $iHresult = $oVDM.MoveWindowToDesktop($hWnd, $sCLSID) ConsoleWrite($iHresult & @CRLF) While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd To perform this example you need to work a bit. Create a second Desktop, start Notepad, go back to the first, and run this script: the GUI window will be transferred from the first desktop to the second. Warning : you cannot use this method if you do not own the window (process-wise). Example 2 : The "undocumented" interface of IVirtualDesktopManagerInternal has a lot more methods and resolves all the requests someone could have using Virtual Desktops. #include <Constants.au3> Opt("MustDeclareVars", True) If @OSVersion <> "WIN_10" Then Exit MsgBox($MB_SYSTEMMODAL, "", "This script only runs on Win 10") ; Instanciation objects Local $CLSID_ImmersiveShell = "{c2f03a33-21f5-47fa-b4bb-156362a2f239}" Local $IID_IUnknown = "{00000000-0000-0000-c000-000000000046}" Local $IID_IServiceProvider = "{6D5140C1-7436-11CE-8034-00AA006009FA}" Local $tIID_IServiceProvider = __uuidof($IID_IServiceProvider) Local $tagIServiceProvider = _ "QueryService hresult(struct*;struct*;ptr*);" ; VirtualDesktopManagerInternal object Const Enum $eLeftDirection = 3, $eRightDirection Local $CLSID_VirtualDesktopManagerInternal = "{C5E0CDCA-7B6E-41B2-9FC4-D93975CC467B}" Local $tCLSID_VirtualDesktopManagerInternal = __uuidof($CLSID_VirtualDesktopManagerInternal) Local $IID_IVirtualDesktopManagerInternal = "{F31574D6-B682-4CDC-BD56-1827860ABEC6}" Local $tIID_IVirtualDesktopManagerInternal = __uuidof($IID_IVirtualDesktopManagerInternal) Local $tagIVirtualDesktopManagerInternal = _ "GetCount hresult(int*);" & _ "MoveViewToDesktop hresult(ptr;ptr);" & _ "CanViewMoveDesktops hresult(ptr;bool*);" & _ "GetCurrentDesktop hresult(ptr*);" & _ "GetDesktops hresult(ptr*);" & _ "GetAdjacentDesktop hresult(ptr;int;ptr*);" & _ "SwitchDesktop hresult(ptr);" & _ "CreateDesktopW hresult(int*);" & _ "RemoveDesktop hresult(ptr;ptr);" & _ "FindDesktop hresult(struct*;ptr*);" ; ApplicationViewCollection object Local $CLSID_IApplicationViewCollection = "{1841C6D7-4F9D-42C0-AF41-8747538F10E5}" Local $tCLSID_IApplicationViewCollection = __uuidof($CLSID_IApplicationViewCollection) Local $IID_IApplicationViewCollection = "{1841C6D7-4F9D-42C0-AF41-8747538F10E5}" Local $tIID_IApplicationViewCollection = __uuidof($IID_IApplicationViewCollection) Local $tagIApplicationViewCollection = _ "GetViews hresult(struct*);" & _ "GetViewsByZOrder hresult(struct*);" & _ "GetViewsByAppUserModelId hresult(wstr;struct*);" & _ "GetViewForHwnd hresult(hwnd;ptr*);" & _ "GetViewForApplication hresult(ptr;ptr*);" & _ "GetViewForAppUserModelId hresult(wstr;int*);" & _ "GetViewInFocus hresult(ptr*);" ; ApplicationView object Local $IID_IApplicationView = "{372E1D3B-38D3-42E4-A15B-8AB2B178F513}" Local $tagIApplicationView = _ "GetIids hresult(ulong*;ptr*);" & _ "GetRuntimeClassName hresult(str*);" & _ "GetTrustLevel hresult(int*);" & _ "SetFocus hresult();" & _ "SwitchTo hresult();" & _ "TryInvokeBack hresult(ptr);" & _ "GetThumbnailWindow hresult(hwnd*);" & _ "GetMonitor hresult(ptr*);" & _ "GetVisibility hresult(int*);" & _ "SetCloak hresult(int;int);" & _ "GetPosition hresult(clsid;ptr*);" & _ "SetPosition hresult(ptr);" & _ "InsertAfterWindow hresult(hwnd);" & _ "GetExtendedFramePosition hresult(struct*);" & _ "GetAppUserModelId hresult(wstr*);" & _ "SetAppUserModelId hresult(wstr);" & _ "IsEqualByAppUserModelId hresult(wstr;int*);" & _ "GetViewState hresult(uint*);" & _ "SetViewState hresult(uint);" & _ "GetNeediness hresult(int*);" ; VirtualDesktopPinnedApps object Local $CLSID_VirtualDesktopPinnedApps = "{b5a399e7-1c87-46b8-88e9-fc5747b171bd}" Local $tCLSID_VirtualDesktopPinnedApps = __uuidof($CLSID_VirtualDesktopPinnedApps) Local $IID_IVirtualDesktopPinnedApps = "{4ce81583-1e4c-4632-a621-07a53543148f}" Local $tIID_IVirtualDesktopPinnedApps = __uuidof($IID_IVirtualDesktopPinnedApps) Local $tagIVirtualDesktopPinnedApps = _ "IsAppIdPinned hresult(wstr;bool*);" & _ "PinAppID hresult(wstr);" & _ "UnpinAppID hresult(wstr);" & _ "IsViewPinned hresult(ptr;bool*);" & _ "PinView hresult(ptr);" & _ "UnpinView hresult(ptr);" ; Miscellaneous objects Local $IID_IObjectArray = "{92ca9dcd-5622-4bba-a805-5e9f541bd8c9}" Local $tagIObjectArray = _ "GetCount hresult(int*);" & _ "GetAt hresult(int;ptr;ptr*);" Local $IID_IVirtualDesktop = "{FF72FFDD-BE7E-43FC-9C03-AD81681E88E4}" Local $tIID_IVirtualDesktop = __uuidof($IID_IVirtualDesktop) Local $tagIVirtualDesktop = _ "IsViewVisible hresult(ptr;bool*);" & _ "GetId hresult(clsid*);" ; objects creation Local $pService Local $oImmersiveShell = ObjCreateInterface($CLSID_ImmersiveShell, $IID_IUnknown, "") ConsoleWrite("Immersive shell = " & IsObj($oImmersiveShell) & @CRLF) $oImmersiveShell.QueryInterface($tIID_IServiceProvider, $pService) ConsoleWrite("Service pointer = " & $pService & @CRLF) Local $oService = ObjCreateInterface($pService, $IID_IServiceProvider, $tagIServiceProvider) ConsoleWrite("Service = " & IsObj($oService) & @CRLF) Local $pApplicationViewCollection, $pVirtualDesktopManagerInternal, $pVirtualDesktopPinnedApps $oService.QueryService($tCLSID_IApplicationViewCollection, $tIID_IApplicationViewCollection, $pApplicationViewCollection) ConsoleWrite("View collection pointer = " & $pApplicationViewCollection & @CRLF) Local $oApplicationViewCollection = ObjCreateInterface($pApplicationViewCollection, $IID_IApplicationViewCollection, $tagIApplicationViewCollection) ConsoleWrite("View collection = " & IsObj($oApplicationViewCollection) & @CRLF) $oService.QueryService($tCLSID_VirtualDesktopManagerInternal, $tIID_IVirtualDesktopManagerInternal, $pVirtualDesktopManagerInternal) ConsoleWrite("Virtual Desktop pointer = " & $pVirtualDesktopManagerInternal & @CRLF) Local $oVirtualDesktopManagerInternal = ObjCreateInterface($pVirtualDesktopManagerInternal, $IID_IVirtualDesktopManagerInternal, $tagIVirtualDesktopManagerInternal) ConsoleWrite("Virtual Desktop = " & IsObj($oVirtualDesktopManagerInternal) & @CRLF) $oService.QueryService($tCLSID_VirtualDesktopPinnedApps, $tIID_IVirtualDesktopPinnedApps, $pVirtualDesktopPinnedApps) ConsoleWrite("Virtual Desktop Pinned Apps = " & $pVirtualDesktopPinnedApps & @CRLF) Local $oVirtualDesktopPinnedApps = ObjCreateInterface($pVirtualDesktopPinnedApps, $IID_IVirtualDesktopPinnedApps, $tagIVirtualDesktopPinnedApps) ConsoleWrite("Virtual Desktop Pinned Apps = " & IsObj($oVirtualDesktopPinnedApps) & @CRLF) Local $iCount, $pCurrent, $pLeft, $pNew, $iHresult, $hWnd, $pView, $pArray, $pDesktop, $oArray, $oView, $sView, $bValue ; gives the number of virtual desktops $iHresult = $oVirtualDesktopManagerInternal.GetCount($iCount) ConsoleWrite("Number of Desktop = " & $iCount & "/" & $iHresult & @CRLF) If $iCount > 1 Then Exit MsgBox($MB_SYSTEMMODAL, "", "Please close all additional Virtual Desktops") ; creates a new virtual desktop $iHresult = $oVirtualDesktopManagerInternal.CreateDesktopW($pNew) ConsoleWrite("Create = " & $pNew & "/" & $iHresult & @CRLF) $iHresult = $oVirtualDesktopManagerInternal.SwitchDesktop($pNew) ConsoleWrite("Switch = " & $iHresult & @CRLF) Run("Notepad.exe") WinWait("[CLASS:Notepad]") ; enumerates all desktops $iHresult = $oVirtualDesktopManagerInternal.GetDesktops($pArray) $oArray = ObjCreateInterface($pArray, $IID_IObjectArray, $tagIObjectArray) ConsoleWrite("Array = " & IsObj($oArray) & @CRLF) $oArray.GetCount($iCount) ConsoleWrite("Count = " & $iCount & @CRLF) $oArray.GetAt(0, DllStructGetPtr($tIID_IVirtualDesktop), $pDesktop) ConsoleWrite("Desktop 0 = " & $pDesktop & @CRLF) $oArray.GetAt(1, DllStructGetPtr($tIID_IVirtualDesktop), $pCurrent) ConsoleWrite("Desktop 1 = " & $pCurrent & @CRLF) ; gives the current desktop id $iHresult = $oVirtualDesktopManagerInternal.GetCurrentDesktop($pCurrent) ConsoleWrite("Current = " & $pCurrent & "/" & $iHresult & @CRLF) ; returns the adjacent desktop id $iHresult = $oVirtualDesktopManagerInternal.GetAdjacentDesktop($pCurrent, $eLeftDirection, $pLeft) ConsoleWrite("Get Left = " & $pLeft & "/" & $iHresult & @CRLF) ; switches to a specific desktop MsgBox ($MB_SYSTEMMODAL,"","Now it will return to previous desktop") Sleep(500) ; gives time for the msg box to close $iHresult = $oVirtualDesktopManagerInternal.SwitchDesktop($pLeft) ConsoleWrite("Switch = " & $iHresult & @CRLF) ; get pointer to a view based on hwnd and create an application view $hWnd = WinGetHandle("[CLASS:Notepad]") $iHresult = $oApplicationViewCollection.GetViewForHwnd($hWnd, $pView) ConsoleWrite("View from handle = " & $pView & "/" & $iHresult & @CRLF) $oView = ObjCreateInterface($pView, $IID_IApplicationView, $tagIApplicationView) ConsoleWrite("Application view = " & IsObj($oView) & @CRLF) $iHresult = $oView.GetAppUserModelId($sView) ConsoleWrite("Get App ID = " & $sView & "/" & $iHresult & @CRLF) ; verify if app is pinned with ptr and string $iHresult = $oVirtualDesktopPinnedApps.IsViewPinned($pView, $bValue) ConsoleWrite("Is View Pinned = " & $bValue & "/" & $iHresult & @CRLF) $iHresult = $oVirtualDesktopPinnedApps.IsAppIdPinned($sView, $bValue) ConsoleWrite("Is AppId Pinned = " & $bValue & "/" & $iHresult & @CRLF) ; move application to a specific desktop $iHresult = $oVirtualDesktopManagerInternal.MoveViewToDesktop($pView, $pDesktop) ConsoleWrite("Move = " & $iHresult & @CRLF) Sleep(2000) ; deletes an existing desktop $iHresult = $oVirtualDesktopManagerInternal.RemoveDesktop($pNew, $pDesktop) ConsoleWrite("Delete = " & $iHresult & @CRLF) Func __uuidof($sGUID) Local $tGUID = DllStructCreate("ulong Data1;ushort Data2;ushort Data3;byte Data4[8]") DllCall("ole32.dll", "long", "CLSIDFromString", "wstr", $sGUID, "struct*", $tGUID) If @error Then Return SetError(@error, @extended, 0) Return $tGUID EndFunc ;==>__uuidof Enjoy.
    1 point
  9. Thanks and welcome @OvisMaximus 👍 . I will review your code when I have the time - thanks for sharing. Btw.: I added you to this list. Best regards Sven
    1 point
  10. Just started with AutoIt scripting to simplify my daily login routine. Move the windows to the appropriate desktop, correct monitor and resize them accordingly. To move the windows to an other desktop it needs the results of the discussion here. Sadly, the code is posted and scattered across this thread, so it took me some time to pull the threads together. Although I'm deeply convinced that I missed one or two things, one may find the result useful. https://github.com/OvisMaximus/WindowsDesktopAutomation/blob/main/VirtDsktLibrary.au3
    1 point
  11. Look at this thread. We have been largely discussing about your request (although a tad in different way). All you need is in there :
    1 point
  12. Hi @jacky998877, I would do this: get a list (handles) of visible windows (or only for your target window) get window position/size of these windows (or only of your target window) listen on to the mouse position (cursor) event calculate the mouse position in comparison to the target window position/size in case the mouse hover over your target window, bring that window in front Best regards Sven
    1 point
  13. Just modifying that code? #include <WindowsConstants.au3> #include <WinAPI.au3> #Include <GDIPlus.au3> _GDIPlus_Startup () $hDC = _WinAPI_GetWindowDC(0) $hGraphic = _GDIPlus_GraphicsCreateFromHDC($hDC) $Color = 0xFF000000 $hPen = _GDIPlus_PenCreate($Color,2) _GDIPlus_GraphicsDrawLine($hGraphic, 0, @DesktopHeight/2, @DesktopWidth, @DesktopHeight/2, $hPen) _WinAPI_RedrawWindow(_WinAPI_GetDesktopWindow(), 0, 0, $RDW_INVALIDATE+$RDW_ALLCHILDREN) _WinAPI_ReleaseDC(0, $hDC) _GDIPlus_Shutdown() However there's some issues with it, such that anything that updates on the screen will remove your painted line. If you want to create a presistent overlay, check out this thread/post from Melba:
    1 point
  14. Well... maybe we can fill it with a Personal Tab. In this Tab, we can place stuff we want to keep as long as we wish (alternative patterns etc...) it's a sort of personal backup saved between sessions in the ini file. This Tab content will never interfere with StringRegExp Results. If you guys think it's interesting, then I'll add it in the code. Have a great day
    1 point
  15. have you try the MouseClickDrag() ? for Excel It has another safer way Local $oExcel = ObjCreate("Excel.Application") ; Create an Excel Object $oExcel.Visible = 1 ; Let Excel show itself $oExcel.WorkBooks.Add ; Add a new workbook Local $ColWidth = $oExcel.Worksheets("Sheet1").Columns("A").ColumnWidth Sleep(1000) ; Display the results $oExcel.ActiveWorkBook.ActiveSheet.Cells(2, 1).Value = "ColWidth" $oExcel.ActiveWorkBook.ActiveSheet.Cells(2, 2).Value = $ColWidth Sleep(1000) ; Display the results $oExcel.Worksheets("Sheet1").Columns("A").ColumnWidth = $ColWidth * 3 $ColWidth = $oExcel.Worksheets("Sheet1").Columns("A").ColumnWidth $oExcel.ActiveWorkBook.ActiveSheet.Cells(3, 1).Value = "ColWidth" $oExcel.ActiveWorkBook.ActiveSheet.Cells(3, 2).Value = $ColWidth ;~ $oExcel.ActiveWorkBook.Saved = 1 ; Simulate a save of the Workbook ;~ $oExcel.Quit ; Quit Excel
    1 point
  16. SOLVE-SMART

    AutoIt Cheat Sheet

    Hi folks, 💡 I completed a "draft" version of my AutoIt (en) Cheat Sheet 😀 . The draft as website on cheatography => a website which is made to create and publish cheat sheets by the help of templates. The draft as PDF => generated by cheatography. May I ask you folks now for a review and an assessment please 🤞 ? In case it's fine, I will publish it. Don't get confused please, if you expected way more. This content represents basically what a common Cheat Sheet does, nothing more No additional sources (next to the help), because there is no special information, only static things of the language. Best regards Sven
    1 point
  17. IniWrite uses CreatePreferences. This is wrong, as CreatePreferences creates an empty file and will destroy all preferences, leaving only one. MsgBox - you are using WinAPI, but you can use the original MessageRequester() function, then you get cross-platform code. StringIsDigit uses PCRE for you, but I gave you a function without using PCRE. Using PCRE adds 150 KB to the size of the executable. In this case, your file size will be almost the same as that of AutoIt3. FindPartialWindow() - why are you creating the t$=Space(999) variable inside the loop. This can be done 1 time outside the loop. Run() EnableExplicit Structure String2 key.s exec.s EndStructure ; modified function by reference to extract parameters and executable ; https://www.cyberforum.ru/pure-basic/thread3028721.html#post16492165 Procedure.s CmdLineRaw(*res.String2) Protected pos, Char.s pos = FindString(*res\exec, Chr(34), 1) If pos = 1 ; if you find a quote in the first character, then Char=quote, it means the path with spaces Char = Chr(34) Else Char = " " EndIf pos = FindString(*res\exec, Char, 2) ; looking for separator Char from the second character If pos > 0 pos + 1 If Mid(*res\exec, pos, 1) = " " pos + 1 EndIf ; found "pos" - the real position of the beginning of the com line *res\key = Right(*res\exec, Len(*res\exec) - pos + 1) ; options *res\exec = Left(*res\exec, pos - 1) ; executable EndIf EndProcedure Procedure Run(program.s, workdir.s = "", show_flag = 0, opt_flag = 0) Protected res.String2 res\exec = program res\key = "" CmdLineRaw(@res) show_flag & opt_flag ; I didn't check the flags ProcedureReturn RunProgram(res\exec, res\key, workdir, show_flag) EndProcedure ; Run(~"Explorer.exe /Select,\"C:\\Windows\\INF\"") Run("notepad.exe C:\Windows\system.ini") ; Run("cmd.exe /c (@Echo off & @Echo. & Color 1e & chkdsk.exe Z: /F /X& set /p Ok=^>^>)")
    1 point
  18. argumentum

    GuiChildTabUDF

    Version 1.2020.7.6

    485 downloads

    An example with Parent / child / child / children ... . It show examples of use GUIRegisterMsg(), etc. Read more about it on the thread.
    1 point
  19. Here is a idispatch object with all the base code written in assembly and is setup in a way so that it can be easily modified to integrate your own custom methods with minimal overhead code. Credits to @genius257 (and @trancexx for helping him) for his AutoitObject udf. I learned a tremendous amount from his code and a lot of the assembly is based of his work so many many thanks! Credits also to @LarsJ for his Accessing Autoit Variables thread showing us that we can expose the autoit variables via objects and how to work with the autoit variants/safearrays within assembly code. As mentioned above this is setup for you to modify so there's not a lot of functions you'll be calling directly and a good amount of code you should not have to touch but I'm going to explain the parts that your expected modify and how that code links to the functions you should not have to mess with. There's really only two spots. The first part is your function table. At the top of the IDispatchASM() function you will find a variable like code below called $sFunctions and will get used in two functions; _CreateFuncTable() and _AsmFuncTable(). You don't call these functions but that's where it gets used. One function gathers all the addresses of the functions and the other generates the assembly code allowing you to easily call these functions within your assembly code. The format is one dll per line with a comma separated list of functions for that dll. There is also one line included for autoit functions and will handle registering and releasing the callbacks so its all nicely in one spot. Local $sFunctions = 'kernel32.dll:HeapAlloc,GlobalAlloc,GlobalFree,GlobalLock,GlobalHandle,RtlMoveMemory' & @LF & _ 'oleaut32.dll:VariantInit,VariantCopy,VariantClear,' & @LF & _ 'au3:' & _RegisterAu3Callbacks('_CreateArray,ptr,dword|_GetKeys,ptr,ptr') To call any of function in the list, you just need to first load up a register with the current memory position and call that register with the function name added to it. Here's some small snips from the code showing what I mean: _('getmempos ebx'); load ebx with memory pos ..code... _('stdcall [ebx+_CreateArray], [esi+tObj.count]'); call autoit function to create an array for us to fill ..code... _('stdcall [ebx+VariantClear], [pVarResult]') _('stdcall [ebx+VariantCopy], [pVarResult],[edx+tProp.Variant]'); copy array to result _('stdcall [ebx+_CreateArray],0'); release object The second area that you will modify is the _invoke function and you would do this to add your own methods. All the methods that are currently included are completely optional and can be replaced/removed if you choose. Whats there right now is more or less practice. All you have to do to add your own method is create a new .elseif statement with the ID your assigning and name of method. Just follow the pattern like below. The _DefineDispID() function works hand in hand with the _AsmDispIDChecks() to automatically generate the lookup code needed to lookup the ID's. The only important part to remember when creating your own methods is that they MUST begin with characters "__" and you must use a negative ID starting at -2. I've written the lookup code to only check if this is one of our methods being called when the first 2 characters begin with "__" - this saves a lot of extra checking going on when its not a method being called. ;===================================== _(' .elseif dword[dispIdMember] = ' & _DefineDispID(-5,'__keys')); .. _(' getmempos ebx') ...code... _(' stdcall [ebx+_CreateArray],0'); release object ;===================================== _(' .elseif dword[dispIdMember] = ' & _DefineDispID(-6,'__fill')); _(' mov esi, [pDispParams]') ...code... _(' xor eax,eax'); set return S_OK ;===================================== _(' .elseif dword[dispIdMember] = ' & _DefineDispID(-7,'__reverse')) ; _(' mov esi, [pDispParams]') ...code... _(' xor eax,eax'); set return S_OK ;===================================== Let me know if you have issues, questions or comments. Thanks for looking Update 05/24/2020: I got x64 support working for this now. I didn't get all the methods converted but all the base code is there it looks to be stable (fingers crossed). It should be able to run this portion of the example either 32bit or 64bit. Example: Local $aArray = [111, 222, 333] $oIDispatch = IDispatchASM() $oIDispatch.string = "string test" $oIDispatch.__string = "__string test2" $oIDispatch.float = 12.345145 $oIDispatch.array = $aArray $oIDispatch.binary = Binary(12345678) $oIDispatch.bool = True $oIDispatch.dllStruct = DllStructCreate("BYTE t") $oIDispatch.dllStruct.t = 99 ConsoleWrite('-Direct get test:' & @CRLF & _ '$oIDispatch.string = ' & $oIDispatch.string & @CRLF & _ '$oIDispatch.__string = ' & $oIDispatch.__string & @CRLF & _ '$oIDispatch.float = ' & $oIDispatch.float & @CRLF & _ '$oIDispatch.array[1] = ' & $oIDispatch.array[1] & @CRLF) ConsoleWrite('-method __keysau3 test:' & @CRLF) Local $aKeyAU3s = $oIDispatch.__keysau3() ConsoleWrite('$aKeyAU3s = ' & _ArrayToString($aKeyAU3s) & @CRLF) ConsoleWrite('-method __get test:' & @CRLF) For $k In $oIDispatch.__keysau3() $val = $oIDispatch.__get($k) ConsoleWrite('$oIDispatch.' & $k & ' = ' & (IsArray($val) ? _ArrayToString($val) : (IsDllStruct($val) ? DllStructGetData($val, 1) : $val)) & @CRLF) Next ConsoleWrite('-method __set test:' & @CRLF) Local $i = 0 For $k In $oIDispatch.__keysau3() $oIDispatch.__set($k) = $i ConsoleWrite('$oIDispatch.' & $k & ' = ' & $oIDispatch.__get($k) & @CRLF) $i += 1 Next Output: -Direct get test: $oIDispatch.string = string test $oIDispatch.__string = __string test2 $oIDispatch.float = 12.345145 $oIDispatch.array[1] = 222 -method __keysau3 test: $aKeyAU3s = string|__string|float|array|binary|bool|dllStruct -method __get test: $oIDispatch.string = string test $oIDispatch.__string = __string test2 $oIDispatch.float = 12.345145 $oIDispatch.array = 111|222|333 $oIDispatch.binary = 0x4E61BC00 $oIDispatch.bool = True $oIDispatch.dllStruct = 99 -method __set test: $oIDispatch.string = 0 $oIDispatch.__string = 1 $oIDispatch.float = 2 $oIDispatch.array = 3 $oIDispatch.binary = 4 $oIDispatch.bool = 5 $oIDispatch.dllStruct = 6 I also added 2 more methods to the 32bit part. __PrintAllParms shows how to check the number of parms that were passed and then prints each one to the console. The second is __search and is generic (1D) array search method demonstrating the use of VarCmp function. That would be a key function in creating a arraysort as well. Let me know if you have any issues. Thanks! Edit: Fixed issue with beta versions of autoit not working IDispatchASM 5-24-2020.zip Previous versions:
    1 point
  20. Thanks, mannworks, looks pretty complicated. I am already running the following script very successfull for some years: (background-mode makes indeed more sense) HotKeySet("{F9}", "GoogleSearch") HotKeySet("{F10}", "DictSearch") HotKeySet("{F11}", "InsertActDate") While 1 Sleep(10) WEnd Func GoogleSearch() Send("^c") Sleep(80) ShellExecute("https://www.google.com/search?q=" & ClipGet()) EndFunc Func DictSearch() Send("^c") Sleep(80) ShellExecute("https://www.dict.cc/?s=" & ClipGet()) EndFunc Func InsertActDate() $date = @YEAR & "-" & @MON & "-" & @MDAY Send($date) EndFunc
    1 point
×
×
  • Create New...