Leaderboard
Popular Content
Showing content with the highest reputation on 02/21/2023 in Posts
-
If Then Else GUI Delete Problem
Ilounah and one other reacted to mistersquirrle for a topic
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 -
FindAllReferences
argumentum reacted to AZJIO for a topic
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.ee1 point -
Change titlebar colors of AutoIt gui
SOLVE-SMART reacted to ahmet for a topic
1 point -
Two fingers scrolling
SOLVE-SMART reacted to mistersquirrle for a topic
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 -
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 Sven1 point
-
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
-
Virtual Desktop Manager under Windows 10
OvisMaximus reacted to SOLVE-SMART for a topic
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 Sven1 point -
Virtual Desktop Manager under Windows 10
mLipok reacted to OvisMaximus for a topic
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.au31 point -
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
-
how to active a window that is under the mouse, not by clicking it?
jacky998877 reacted to SOLVE-SMART for a topic
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 Sven1 point -
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
-
RegExpQuickTester 2.5r
ioa747 reacted to pixelsearch for a topic
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 day1 point -
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 Excel1 point
-
AutoIt Cheat Sheet
Marc reacted to SOLVE-SMART for a topic
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 Sven1 point -
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
-
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
-
Google Search Shortcut Script
mannworks00 reacted to BlueRabbit for a topic
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) EndFunc1 point