Leaderboard
Popular Content
Showing content with the highest reputation on 01/07/2021 in all areas
-
_IEGetObjById not works all time on wordpress ??
FrancescoDiMuro and one other reacted to Danp2 for a topic
Where do you come up with these crazy incorrect syntax examples? 😲🙄2 points -
Automate all windows and browser applications with one UDF function library. Based on the microsoft automation API this library high level supports Recognition of conttrols from EDGE, Chrome, FF, Opera, Safari and Windows native apps Small testing framework to split object repository from coding away Introduction Quickstart - Getting started quickly Simple scripts With this module you can automate all applications/programs that support ui automation and/or accesibility api from microsoft you can recognize more controls than AutoIT can recognize "out of the box" you can use concepts from other testing frameworks like http://download.freedesktop.org/ldtp/doc/ldtp-tutorial.pdf http://safsdev.sourceforge.net/Default.htm coded ui testing from microsoft Some of those controls / applications are chrome browser (partly mainwindow has to be done with MSAA for navigating) chrome://accessibility in the adress bar of chrome or start with "--force-renderer-accessibility" silverlight controls Ribbon control controlbars of Excel/Word IE and FF browsers Windows Media Player Windows clock AFX .. controls (partly) .... Based on the initial AIO Object I now have made the interface file to work with objCreateInterface function which is in the latest beta's automate clicking and querying basic information It gives you a lot of basic information to be able to automate clicking, querying basic information where it goes further in certain situations than AutoIt is identifying Starting threads for background on the ui automation api of microsoft (not for starters) http://en.wikipedia.org/wiki/Microsoft_UI_Automation http://msdn.microsoft.com/en-us/library/ms747327.aspx Previous threads in general help/support Interface AutoItObject IUIAutomation ObjCreateInterface and struct tagPoint in method ElementFromPoint Be aware that API is not allways installed under XP/Vista see http://support.microsoft.com/kb/971513 Within Windows 7 and Windows 8 it should be preinstalled by default. Be aware on 32 and 64 bits way of running your script #AutoIt3Wrapper_UseX64=Y or N Basic example of usage / showing and retrieving the default information, will post multiple examples later Hover your mouse to an area of interest and press ctrl+w and information will be shown in the edit box of the form Simple spy demo (see simplespy.au3 or use latest ZIP attachment for latest version) Main features Recognize windows and html controls for the major browsers Logical and physical description for controls (UI mapping, Application map) Simple repository logic to abstract logical and physical descriptions Store Runtime Type Information in RTI. variables Rubberbanding/highlighting of objects Simple spy to help in making / identifying the physical description Support of regular expression(s) in identifying objects recognize objects on multiple properties supported properties: name ,title, automationid, classname, class, iaccessiblevalue, iaccessiblechildId, controltype, processid, acceleratorkey The actions provided so far "leftclick", "left", "click", "leftdoubleclick", "leftdouble", "doubleclick", _ "rightclick", "right", "rightdoubleclick", "rightdouble", _ "middleclick", "middle", "middledoubleclick", "middledouble", "mousemove", "movemouse" "setvalue","settextvalue" "setvalue using keys" "setValue using clipboard" "getvalue" "sendkeys", "enterstring", "type", "typetext" "invoke" "focus", "setfocus", "activate" "close" "move","setposition" "resize" "minimize", "maximize", "normal", "close", "exist", "exists" "searchcontext", "context" "highlight" "getobject","object" "attach" "capture","screenshot", "takescreenshot" "dump", "dumpthemall" "propertyvalue", "property" match on multiple properties like: name:=((Zoeken.*)|(Find.*)); ControlType:=Button; acceleratorkey:=Ctrl+F Support for 117 different properties see $UIA_propertiesSupportedArray in uiawrappers like for example title, regexptitle, class, regexpclass, iaccessiblevalue, iaccessiblechildid, name, accesskey, automationid, classname IAccessible, IAccessible2, ISimpleDom interfaces debuglogging to a file log.txt (no output in scitewindow) Examples Example 1 Iterating thru the different ways of representing the objects in the tree (#comment-1105548) Example 2 Finding the taskbar and clicking on the start menu button (#comment-1105680) Example 3 Clicking a litlle more and in the end displaying all items from the clock (thats not directly possible with AU3Info) (#comment-1108849) Example 4 that demonstrates the calculator Example 5 Automating chrome Example 6 Demonstrates all stuff within chrome to navigate html pages, find hyperlink, click hyperlink, find picture, click picture, enter data in inputbox Example 7 The chrome example modified to a firefox example Example 8 The other major browser Internet Explorer automated (made on Example 6 and 7) Example 9 Windows media player Example 10 Automating mach 3 (AFX windows and other hard to get recognized by AutoIT) Lot of links are broken due to forum upgrade just search for the text like "Example 11 Demonstrate Word, Notepad and Calculator actions" Example 11 Demonstrate Word, Notepad and Calculator actions ... Example 13 Details 1 about the right pane of the windows explorer Example 14 Details 2 about the right pane of the windows explorer Example 15 Details 3 about the right pane of the windows explorer Example 16 Details 4 about the right pane of the windows explorer Example 17 Details 5 about the right pane of the windows explorer WITH CACHING Example 18 Details 6 about the right pane of the windows explorer WITH VIRTUAL ITEMS Example 19 Eventhandling examples Example 20 Eventhandling examples Example 21a Eventhandling examples Internet Explorer Example 21b Eventhandling examples Internet Explorer Example 22 Eventhandling examples Follow focus Example 23 Eventhandling examples structure changed Example 24 Eventhandling examples IUIAutomationEventHandler Example 25 SAFEARRAYS Example 26 IACCESSIBLE / MSAA Example 27 IACCESSIBLE2 / MSAA Example 28 IACCESSIBLE / MSAA events Example 29 IACCESSIBLE2 events Example 30 ISimpleDOM Example 31 Notepad window move, maximize, minimize Example 32 Three browsers doing the same stuff with small differences in scripting only .. TODO Build recorder Enhance the spy with a nicer UI UI for the repository (now in the script with dot notation) Enhance mapping / identifying on multiple properties instead of 1 combined with index If speed becomes an issue use the caching logic of the MS UIA framework Add the other patterns later Generalize the concept of System Under Test of starting the SUT (for testing framework purposes) Remote running of scripts Fix issue on finding within dynamic context ... edit august 18th 2013 initial post Only zip files are needed to download , just unzip in 1 directory edit july 2016 Made V0_63 and examples works with AutoIt v3.3.14 Windows 10 tested Simple spy gives some basic code as a present Chrome latest versions seems to be having issues with IUIAutomation on tabs/buttons of mainwindow use MSAA for accessing tabsheets / buttons more cleanup to be in UDF style More comments in the source see changelog.txt for previous changes edit september 2017 All examples fixed for the IE, Firefox and Chrome browser Some small but essential fixes in UIAWrappers edit april 2018 Enhanced logic on fallback / dynamic search, still not perfect, to slow Retested with latest Chrome, FF, Edge and IE11 and some extensions to show how to get text from the webpage (examples 5,6,7) Some small bugfixes Some comments as given in forum incorporated edit may 2019 Speed enhancements on especially fallback searching UIA.CFG works now in a better way to turn on/off debug, highlighting, debug2file More stable and consistent behavior Internal cleanup and refactoring of bigger functions Checked with W10 (not tested on W7) Added some W10 properties Run with 3.3.14.5 on W10 UIA_V0_51.zip EXAMPLES_V0_5.zip UIA_V0_63.zip EXAMPLES_V0_63.zip UIA_V0_64.zip EXAMPLES_V0_64.zip EXAMPLES_V0_66.zip UIA_V0_66.zip EXAMPLES_V0_70.zip UIA_V0_70.zip1 point
-
Are my AutoIt exes really infected?
Leendert-Jan reacted to JSThePatriot for a topic
If you have been using AutoIt for any length of time you will know that it is a great, and powerful scripting language. As with all powerful languages there comes a downside. Virus creation by those that are malicious. AutoIt has no virii installed on your system, and if a script you have created has been marked as a virus, (and you're not malicious) then this is a false positive. They found a set of instructions in an AutoIt EXE out there somewhere, took the general signature of the file, and now all AutoIt EXE's are marked (or most of them). This can be due to several reasons. AutoIt is packed with UPX. UPX is an open source software compression packer. It is used with many virii (to make them smaller). Malicious scripter got the AutoIt script engine recognized as a virus. And I am sure there are more ways your executable could be marked, but that covers the basics. Now I am sure you are wanting to know what you can do to get back up and running without being recognized as a virus. You have to send in a report to the offending AV company alerting them to the false positive they have made. It never hurts to send in your source code along with a compiled exe, to help them realize their mistake. You may have to wait up to 24 hours for them to release an update. The time it takes really depends on the offending AV company. Anti-Virus Links AntiVir Website Contact Avast! Website Contact McAfee Website Contact (email address) Symantec (Norton) Website Contact AVG Website Contact (It says sales or other ?'s I assume this will work) ClamWin Website Contact ClamAV Website Contact (I would only contact the ones with "virusdb maintainer or virus submission management") BitDefender Website Contact ZoneLabs Website Contact Norman Website Contact (email address) eSafe Website Contact (login required) A2 (A-Squared) Website Contact (email address) Edit: Added Website links and Contact links. I hope this helps you understand why your AutoIt executables are marked as virii. JS1 point -
Based on the Outlook UDF written by wooltown, we (wooltown and I) decided to extend the functionality of the Outlook UDF. As the OutlookEX UDF ("EX" like "extended") has a completely different approach compared to the Outlook UDF it's a complete rewrite. We would like to discuss the design of the UDF with the community. Every feedback, function request etc. is highly welcome. As soon as the discussion shows that we are on the right track we would like to release an alpha version for everyone to test. So please don't be shy and post what you think of this UDF or what functions you need! Every item in Outlook is uniquely identified by EntryID and StoreID. The default StoreID is your inbox Every item has properties to describe the item (subject, startdate ..) and methods to act upon the item (move, delete …) The search and action functions are now separated. As an example the user first searches for the items to be deleted and then calls the delete function If a method can be used for more than one item type (e.g. mail, calendar and notes) the function is called _OL_ItemXXX else the function is called _OL_CalendarXXX The number of properties you can get or pass to most functions is not limited by the number of parameters defined for the function. Properties can be passed as parameters (up to 10) or in an unlimited array as parameter 1 The UDF allows to access all kind of folders (see the following listing). Folders can be passed by name or as an object to a function A lot of testing is still needed as we have written and tested the functions using Outlook 2002 SP3 and Outlook 2010 "wrapper" or "shortcut" functions will be available to let you do all tasks in one go e.g. _OL_Wrapper_SendMail for all functions above. Documentation: The documentation for this UDF (aside from the docu in the UDF itself) will be placed in the AutoIt Wiki. So we can easily modify the docu without releasing a new version each time. There will be pages describing the UDF in general and pages for individual item types (like mail) with detailed information and a lot of tips & tricks. Tested with Outlook 2003 and 2010. Some users reported that it works with Outlook 2013 as well. Starting point: http://www.autoitscript.com/wiki/OutlookEX_UDF_-_General Download1 point
-
Get All Window's Controls
vergil250493 reacted to jdelaney for a topic
I've wanted to post this for a while. It's a great script to help debug control data....perfect scenario, when you have a 'Button' grouping, and spy tools cannot focus on those controls within the button bounds (groups). I also use it to verify that a given ID is not present more than once...if not, that's how I identify the control in future scripts. Output can be filtered by: 1) Filter by IsVisible 2) Filter by matching class (ex Button, Label, Static) 3) Filter by containing text #include <Array.au3> #include <WinAPI.au3> ConsoleWrite("Make your window active!" & @CRLF) Sleep(5000) GetAllWindowsControls(WinGetHandle("[ACTIVE]")) Func GetAllWindowsControls($hCallersWindow, $bOnlyVisible=Default, $sStringIncludes=Default, $sClass=Default) If Not IsHWnd($hCallersWindow) Then ConsoleWrite("$hCallersWindow must be a handle...provided=[" & $hCallersWindow & "]" & @CRLF) Return False EndIf ; Get all list of controls If $bOnlyVisible = Default Then $bOnlyVisible = False If $sStringIncludes = Default Then $sStringIncludes = "" If $sClass = Default Then $sClass = "" $sClassList = WinGetClassList($hCallersWindow) ; Create array $aClassList = StringSplit($sClassList, @CRLF, 2) ; Sort array _ArraySort($aClassList) _ArrayDelete($aClassList, 0) ; Loop $iCurrentClass = "" $iCurrentCount = 1 $iTotalCounter = 1 If StringLen($sClass)>0 Then For $i = UBound($aClassList)-1 To 0 Step - 1 If $aClassList[$i]<>$sClass Then _ArrayDelete($aClassList,$i) EndIf Next EndIf For $i = 0 To UBound($aClassList) - 1 If $aClassList[$i] = $iCurrentClass Then $iCurrentCount += 1 Else $iCurrentClass = $aClassList[$i] $iCurrentCount = 1 EndIf $hControl = ControlGetHandle($hCallersWindow, "", "[CLASSNN:" & $iCurrentClass & $iCurrentCount & "]") $text = StringRegExpReplace(ControlGetText($hCallersWindow, "", $hControl), "[\n\r]", "{@CRLF}") $aPos = ControlGetPos($hCallersWindow, "", $hControl) $sControlID = _WinAPI_GetDlgCtrlID($hControl) $bIsVisible = ControlCommand($hCallersWindow, "", $hControl, "IsVisible") If $bOnlyVisible And Not $bIsVisible Then $iTotalCounter += 1 ContinueLoop EndIf If StringLen($sStringIncludes) > 0 Then If Not StringInStr($text, $sStringIncludes) Then $iTotalCounter += 1 ContinueLoop EndIf EndIf If IsArray($aPos) Then ConsoleWrite("Func=[GetAllWindowsControls]: ControlCounter=[" & StringFormat("%3s", $iTotalCounter) & "] ControlID=[" & StringFormat("%5s", $sControlID) & "] Handle=[" & StringFormat("%10s", $hControl) & "] ClassNN=[" & StringFormat("%19s", $iCurrentClass & $iCurrentCount) & "] XPos=[" & StringFormat("%4s", $aPos[0]) & "] YPos=[" & StringFormat("%4s", $aPos[1]) & "] Width=[" & StringFormat("%4s", $aPos[2]) & "] Height=[" & StringFormat("%4s", $aPos[3]) & "] IsVisible=[" & $bIsVisible & "] Text=[" & $text & "]." & @CRLF) Else ConsoleWrite("Func=[GetAllWindowsControls]: ControlCounter=[" & StringFormat("%3s", $iTotalCounter) & "] ControlID=[" & StringFormat("%5s", $sControlID) & "] Handle=[" & StringFormat("%10s", $hControl) & "] ClassNN=[" & StringFormat("%19s", $iCurrentClass & $iCurrentCount) & "] XPos=[winclosed] YPos=[winclosed] Width=[winclosed] Height=[winclosed] Text=[" & $text & "]." & @CRLF) EndIf If Not WinExists($hCallersWindow) Then ExitLoop $iTotalCounter += 1 Next EndFunc ;==>GetAllWindowsControls1 point -
From MiniMax to Machine Learning ... Tic Tac Toe is a good game for studying AI algorithm because it's simple! I use Tabular Q Learning to implement this game, Every time a game finished, it will use the Q function to update the score of each steps it played. Q(S,A) = Q(S,A) + α ∗ (γ ∗ maxaQ(S′,a) − Q(S,A)) S being the current state, A the current action, S′ the state after doing A, α being the learning rate, γ being the discount factor, and maxaQ(S′,a) the highest Q value of any move in the next state S′, i.e. the Q value of the best move in the following state. It's funny to see that it plays better and better. That's why people were charmed by Machine Learning! Thank you! Download: tic_tac_toe.zip1 point
-
Silent Installation (To software there is no silent switch)
PHAK reacted to JLogan3o13 for a topic
Goldwave used to accept -s for silent, but this was many moons ago. If it no longer supports that method (as the site seems to indicate) AutoIt can't magically force it to support one. You could go the and manipulate each install screen perhaps, but if you truly want it silent you would have to look into wrapping the install into an MSI. There are a number of free and low-cost tools out there for doing this.1 point -
Datavalue, Please read the sticky, which like so many others you appear to have missed: M231 point
-
If you want to create your own environment without the use of external apps, then your choice should go with the following interface : https://docs.microsoft.com/en-us/windows/win32/coreaudio/wasapi Search the forum for examples and UDF using the interfaces IMMDevice and WASApi.1 point
-
Not sure how you expect this to work either. 1. _IEGetObjById sets @error to 3 / 7, not the returned value 2. Even if the above wasn't true, you reset the value of the variables to Null at the bottom of the loop so there's no way any of them will equal 3 or 71 point
-
if you need this for the problem of your other post, then I don't think that the non-referencing to an object on the web page could be due to the absence of the link, maybe it could be caused by a delay on creating that object on the page web, and maybe the script tries to reference it before this is created on the web page. Better checking could be done by making sure the object has been referenced before continuing with the rest of the script. for example more or less with something like this: Do $title = _IEGetObjById($oIE, "title") Until IsObj($title)1 point
-
furthermore, even if he intended to use _IEaction instead, there is also another problem, and that is, by "refreshing" the page, you lose all references to the objects you created before the refresh .....1 point
-
Global $title, $oText, $chkbx, $oTag, $oSubmit, $oIE For $i = 0 To UBound($url_arr) - 1 $oIE = _IECreate($url_arr[$i]) _RefreshPageIfError ($oIE) _IEFormElementSetValue($title, $Post_ttl) _IEFormElementSetValue($oText, $cntnt) _IEFormElementSetValue($oTag, $Tags) _IEAction($chkbx, "click") _IEAction($oSubmit, "click") _IEQuit($oIE) _ResetVar () Next Func _RefreshPageIfError ($oIE) _IELoadWait($oIE) $title = _IEGetObjById($oIE, "title") If @error Then _IELoadWait($oIE) $title = _IEGetObjById($oIE, "title") EndIf $oText = _IEGetObjById($oIE, "content") If @error Then _IELoadWait($oIE) $oText = _IEGetObjById($oIE, "content") EndIf $chkbx = _IEGetObjById($oIE, "in-category-1") If @error Then _IELoadWait($oIE) $chkbx = _IEGetObjById($oIE, "in-category-1") EndIf $oTag = _IEGetObjById($oIE, "new-tag-post_tag") If @error Then _IELoadWait($oIE) $oTag = _IEGetObjById($oIE, "new-tag-post_tag") EndIf $oSubmit = _IEGetObjById($oIE, "publish") If @error Then _IELoadWait($oIE) $oSubmit = _IEGetObjById($oIE, "publish") EndIf EndFunc Func _ResetVar () $title = Null $oText = Null $chkbx = Null $oTag = Null $oSubmit= Null EndFunc Or : Global $title, $oText, $chkbx, $oTag, $oSubmit, $oIE For $i = 0 To UBound($url_arr) - 1 $oIE = _IECreate($url_arr[$i]) _RefreshPageIfError ($oIE) _IEFormElementSetValue($title, $Post_ttl) _IEFormElementSetValue($oText, $cntnt) _IEFormElementSetValue($oTag, $Tags) _IEAction($chkbx, "click") _IEAction($oSubmit, "click") _IEQuit($oIE) _ResetVar () Next Func _RefreshPageIfError ($oIE) _IELoadWait($oIE) Do $title = _IEGetObjById($oIE, "title") $oText = _IEGetObjById($oIE, "content") $chkbx = _IEGetObjById($oIE, "in-category-1") $oTag = _IEGetObjById($oIE, "new-tag-post_tag") $oSubmit = _IEGetObjById($oIE, "publish") _IELoadWait($oIE) _ResetVar () Until $title <> 3 Or $title <> 7 And $oText <> 3 Or $oText <> 7 And $chkbx <> 3 Or $chkbx <> 7 And $oTag <> 3 Or $oTag <> 7 And $oSubmit <> 3 Or $oSubmit <> 7 EndFunc Func _ResetVar () $title = Null $oText = Null $chkbx = Null $oTag = Null $oSubmit= Null EndFunc1 point
-
In the last versions of Windows, it has been difficult to automate Windows Explorer. But there are many examples of code like this to extract the selected items: ; Windows Explorer on XP, Vista, 7, 8 $hExplorer = WinGetHandle( "[REGEXPCLASS:^(Cabinet|Explore)WClass$]" ) If Not $hExplorer Then Exit ; Shell object $oShell = ObjCreate( "Shell.Application" ) ; Find window For $oWindow In $oShell.Windows() If $oWindow.HWND() = $hExplorer Then ExitLoop Next ; Selected items For $oItem In $oWindow.Document.SelectedItems() ConsoleWrite( $oItem.Path() & @CRLF ) Next It's possible to create these objects with ObjCreateInterface. More precisely, create an IShellBrowser interface for the top level browser of an open Windows Explorer. Plan and code This is the plan: Create an IShellWindows interface to get a list of shell windows Get an IWebBrowserApp object for each window. This is done in two steps: Get an IDispatch object for the window Get the IWebBrowserApp interface Identify the proper shell window with get_HWND of IWebBrowserApp Get an IServiceProvider interface with QueryInterface of IWebBrowserApp Get the IShellBrowser interface with QueryService of IServiceProvider This is the code: Func GetIShellBrowser( $hExplorer ) ; IShellWindows interface Local $pIShellWindows, $oIShellWindows CoCreateInstance( $tCLSID_ShellWindows, $NULL, $CLSCTX_ALL, $tRIID_IShellWindows, $pIShellWindows ) $oIShellWindows = ObjCreateInterface( $pIShellWindows, $sIID_IShellWindows, $dtag_IShellWindows ) ; Number of shell windows Local $iWindows $oIShellWindows.get_Count( $iWindows ) ; Get an IWebBrowserApp object for each window ; This is done in two steps: ; 1. Get an IDispatch object for the window ; 2. Get the IWebBrowserApp interface ; Check if it's the right window Local $pIDispatch, $oIDispatch Local $pIWebBrowserApp, $oIWebBrowserApp, $hWnd For $i = 0 To $iWindows - 1 $oIShellWindows.Item( $i, $pIDispatch ) If $pIDispatch Then $oIDispatch = ObjCreateInterface( $pIDispatch, $sIID_IDispatch, $dtag_IDispatch ) $oIDispatch.QueryInterface( $tRIID_IWebBrowserApp, $pIWebBrowserApp ) If $pIWebBrowserApp Then $oIWebBrowserApp = ObjCreateInterface( $pIWebBrowserApp, $sIID_IWebBrowserApp, $dtag_IWebBrowserApp ) $oIWebBrowserApp.get_HWND( $hWnd ) If $hWnd = $hExplorer Then ExitLoop EndIf EndIf Next ; IServiceProvider interface Local $pIServiceProvider, $oIServiceProvider $oIWebBrowserApp.QueryInterface( $tRIID_IServiceProvider, $pIServiceProvider ) $oIServiceProvider = ObjCreateInterface( $pIServiceProvider, $sIID_IServiceProvider, $dtag_IServiceProvider ) ; IShellBrowser interface Local $pIShellBrowser $oIServiceProvider.QueryService( $tRIID_STopLevelBrowser, $tRIID_IShellBrowser, $pIShellBrowser ) $oIShellBrowser = ObjCreateInterface( $pIShellBrowser, $sIID_IShellBrowser, $dtag_IShellBrowser ) EndFunc Now it's easy to create the shell interfaces. The main interfaces are: Func GetShellInterfaces() Local $pIFolderView, $pIFolderView2, $pIPersistFolder2, $pIShellFolder, $pPidlFolder, $pPidlRel, $i = 0 ; IShellView interface $oIShellBrowser.QueryActiveShellView( $pIShellView ) $oIShellView = ObjCreateInterface( $pIShellView, $sIID_IShellView, $dtag_IShellView ) ; IFolderView interface $oIShellView.QueryInterface( $tRIID_IFolderView, $pIFolderView ) $oIFolderView = ObjCreateInterface( $pIFolderView, $sIID_IFolderView, $dtag_IFolderView ) If @OSVersion <> "WIN_XP" Then ; IFolderView2 interface (Vista and later) $oIShellView.QueryInterface( $tRIID_IFolderView2, $pIFolderView2 ) $oIFolderView2 = ObjCreateInterface( $pIFolderView2, $sIID_IFolderView2, $dtag_IFolderView2 ) EndIf ; IPersistFolder2 interface $oIFolderView.GetFolder( $tRIID_IPersistFolder2, $pIPersistFolder2 ) $oIPersistFolder2 = ObjCreateInterface( $pIPersistFolder2, $sIID_IPersistFolder2, $dtag_IPersistFolder2 ) $oIPersistFolder2.GetCurFolder( $pPidlFolder ) ; IShellFolder interface If ILIsEqual( $pPidlFolder, $pPidlAbsDesktop ) Then SHGetDesktopFolder( $pIShellFolder ) Else Local $pIParentFolder, $oIParentFolder, $pPidlRel SHBindToParent( $pPidlFolder, DllStructGetPtr( $tRIID_IShellFolder ), $pIParentFolder, $pPidlRel ) $oIParentFolder = ObjCreateInterface( $pIParentFolder, $sIID_IShellFolder, $dtag_IShellFolder ) $oIParentFolder.BindToObject( $pPidlRel, $NULL, $tRIID_IShellFolder, $pIShellFolder ) EndIf $oIShellFolder = ObjCreateInterface( $pIShellFolder, $sIID_IShellFolder, $dtag_IShellFolder ) ; Free memory used by $pPidlFolder _WinAPI_CoTaskMemFree( $pPidlFolder ) ; Wait for Explorer to refresh $pPidlRel = GetFocusedItem() While Not $pPidlRel And $i < 10 Sleep( 25 ) $pPidlRel = GetFocusedItem() $i += 1 WEnd ; Free memory used by $pPidlRel If $pPidlRel Then _ _WinAPI_CoTaskMemFree( $pPidlRel ) EndFunc Features The methods of the interfaces supports the following features: You can handle items in Windows Explorer: Get current folder, get all items, get/set selected items and get/set focused item. A selected file is opened by executing the InvokeCommand for the default item in the context menu. You can browse to a specific folder or a parent/child folder. You can set icon view mode. Functions AutomatingWindowsExplorer.au3 contains the two functions above. And it contains a number of functions to implement the features: GetCurrentFolder SetCurrentFolder CountItems GetItems GetFiles GetFolders GetPidls GetFocusedItem SetFocusedItem SetSelectedItem GetIconView SetIconView When the interfaces are created, the functions can be implemented with a few lines of code. This is the code for GetCurrentFolder and SetCurrentFolder: Func GetCurrentFolder() Local $pPidlAbs $oIPersistFolder2.GetCurFolder( $pPidlAbs ) Return $pPidlAbs EndFunc ; After this command $oIShellBrowser is the only valid interface object. To ; be able to use the other interfaces you must execute GetShellInterfaces(). Func SetCurrentFolder( $pPidl, $fFlag ) $oIShellBrowser.BrowseObject( $pPidl, BitOR( $SBSP_DEFBROWSER, $fFlag ) ) EndFunc For examples search the functions in Example.au3 and Example*.au3. Depending on parameters most functions can return PIDLs. Some functions return only PIDLs. In these cases you must free memory (_WinAPI_CoTaskMemFree) used by the PIDLs, when you have finished using the PIDLs. There are many more methods that are not implemented in these functions, and there are available interfaces that have not been created. Example Example.au3 demonstrates the features. Example folder contains scripts with functions used in the example. It's important that there is consistency between the interfaces, and the current folder in Windows Explorer. If the GUI loses and gets focus, it's checked if the current folder is changed. In that case the interfaces are updated to match the new folder. This is a picture of the GUI: Items and selected items are shown with _ArrayDisplay. The number of rows in the listview to the right is limited to 100. The listview can only be used for the buttons in the lower right group. The buttons in the lower left group are disabled, if there are more than 100 items in the folder. There is also a listview on the second tab item. It's limited to 100 rows, and can only be used for the Child folder button. You can also double click a child folder in the listview, to browse to this folder. Control Panel The example does not work for the Control Panel. The reason is that the child windows which are created for the Control Panel, are different from the child windows which are created for other folders. You can verify that with the UI Automation framework. Zipfile Example - include files used in example Includes - include files used for Automating Windows Explorer Example.au3 - Example For AutoIt 3.3.10 and later. Testet on Windows XP 32 bit and Windows 7 32/64 bit. Automating Windows Explorer.7z Examples in posts below Post 7 is a collection of small examples. Post 15 shows how to automate a search with UI Automation code. Post 31 shows how to execute a function on a double-click in empty space of the right pane window (the listview). The code contains UI Automation code. Post 38 is UI Automation code to make a selected item visible by scrolling the listview up or down.1 point
-
Probably reinventing the wheel in quite a few cases, but oh well... Got the basic idea from some thread, figured I could use something like that on my crappy screen. Wasn't happy with a few bugs, CPU use and the looks though, so rewrote one myself. Figured I could use some pixel color/position and basic window/control info tool, so added that too. Feats: Resizeable and draggable main window, magnifier x1-x10. Pixel precision 5x5, hex color and coords. Window/control title, class, handle. Configuration options. None of those features are very sophisticated, but good enough for me. To do - resampling for better quality magnify, using GDI+ or whateva. Source: ;##################################################### #cs Screen Magnifier, Pixel pos and Window info tool all-in-one, by Siao Usage: Main window resizeable Left click drags window Right click brings up options etc. #ce ;##################################################### #include <GUIConstants.au3> #NoTrayIcon Opt("WinWaitDelay", 0) Opt("GUICloseOnESC", 0) Opt("GUIOnEventMode", 1) Global Const $WM_MOVING = 0x0216 ;~ Global Const $WM_SIZING = 0x0214 ;cursors Global Const $IDC_SIZEALL = 32646 Global Const $IDC_ARROW = 32512 ;~ Global Const $WM_SETCURSOR = 0x0020 ;Drag constants Global Const $HTCAPTION = 2 Global Const $WM_NCLBUTTONDOWN = 0xA1 ;raster opcodes ;normal: Global Const $SRCCOPY = 0xCC0020 Global Const $MERGECOPY = 0xC000CA ;inverted: Global Const $NOTSRCCOPY = 0x330008 ;text constants: Global Const $DT_RIGHT = 0x2 Global $nZoomFactor = 2, $aMPosOld[2], $nTrans = 200 Global $iSleepTime = 90, $nTimer = 0, $bShowMini = 1, $bShowText = 1, $bAlwaysCenter = 0, $bInvert = 0, $bMouseUpdate = 1, $bSave = 0 ;Main view GUI $hGuiMain = GUICreate("Magnifier by Siao", 400, 300, -1, -1, _ BitOR($WS_POPUP,$WS_BORDER,$WS_SIZEBOX+$WS_CLIPCHILDREN), _ $WS_EX_TOPMOST _ );+$WS_EX_LAYERED+$WS_EX_TRANSPARENT ;Mini view GUI $hGuiMini = GUICreate("Aimpoint 5x5", 128,128,400-130,0,$WS_CHILD+$WS_BORDER, -1, $hGuiMain) ;Options GUI #Region ### START Koda GUI section ### Form=d:\miniprojects\autoit3\magnifier\guioptions.kxf $hGuiOpt = GUICreate("Magnifier Options", 305, 230, -1, -1, BitOR($WS_SYSMENU,$WS_POPUP,$WS_POPUPWINDOW,$WS_BORDER,$WS_CLIPSIBLINGS), -1, $hGuiMain) $btnMin = GUICtrlCreateButton("Minimize", 5, 5, 145, 25, 0) GUICtrlSetOnEvent(-1, "OptionsEvents") $btnQuit = GUICtrlCreateButton("Quit Program", 155, 5, 145, 25, 0) GUICtrlSetOnEvent(-1, "OptionsEvents") $SliderTrans = GUICtrlCreateSlider(6, 54, 19, 165, BitOR($TBS_VERT,$TBS_AUTOTICKS)) GUICtrlSetCursor (-1, 11) GUICtrlSetOnEvent(-1, "OptionsEvents") $grp1 = GUICtrlCreateGroup("View options", 60, 40, 235, 147) $SliderZoom = GUICtrlCreateSlider(126, 60, 161, 19);, $TBS_AUTOTICKS) GUICtrlSetLimit(-1, 100, 1) GUICtrlSetData(-1, 2) GUICtrlSetCursor (-1, 13) GUICtrlSetOnEvent(-1, "OptionsEvents") $cbInvert = GUICtrlCreateCheckbox("Invert colors", 76, 90, 93, 21) GUICtrlSetOnEvent(-1, "OptionsEvents") $cbCenter = GUICtrlCreateCheckbox("Always center", 76, 108, 93, 21) GUICtrlSetOnEvent(-1, "OptionsEvents") $Label1 = GUICtrlCreateLabel("Zoom:", 74, 60, 50, 17) $cbInfoPix = GUICtrlCreateCheckbox("Show pixel info", 182, 108, 93, 21) GUICtrlSetOnEvent(-1, "OptionsEvents") $cbInfoWin = GUICtrlCreateCheckbox("Show win info", 182, 90, 93, 21) GUICtrlSetOnEvent(-1, "OptionsEvents") $inTimer = GUICtrlCreateInput("", 192, 136, 37, 21, $ES_NUMBER) GUICtrlSetOnEvent(-1, "OptionsEvents") $Label3 = GUICtrlCreateLabel("Update time (ms):", 106, 138, 86, 17) $cbMouseUpdate = GUICtrlCreateCheckbox("Update only on mouse move", 104, 159, 161, 21) GUICtrlSetOnEvent(-1, "OptionsEvents") GUICtrlCreateGroup("", -99, -99, 1, 1) $Label2 = GUICtrlCreateLabel("Trans:", 6, 40, 34, 17) $Label4 = GUICtrlCreateLabel("(c) Siao, 2007", 300, 226, 1, 1, BitOR($SS_CENTER,$SS_CENTERIMAGE,$WS_BORDER)) GUICtrlSetCursor (-1, 0) $Label5 = GUICtrlCreateLabel("0", 30, 204, 10, 17) $Label6 = GUICtrlCreateLabel("255", 30, 57, 22, 17) $cbSave = GUICtrlCreateCheckbox("Remember options", 70, 194, 113, 30) GUICtrlSetOnEvent(-1, "OptionsEvents") $btnOK = GUICtrlCreateButton("OK", 198, 194, 87, 29, 0) GUICtrlSetOnEvent(-1, "OptionsEvents") GUISetState(@SW_DISABLE) GUISetState(@SW_HIDE) #EndRegion ### END Koda GUI section ### _LoadOptions() GUISwitch($hGuiMain) GUISetOnEvent($GUI_EVENT_CLOSE, "SystemEvents") GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "SystemEvents") GUISetOnEvent($GUI_EVENT_SECONDARYDOWN, "SystemEvents") GUIRegisterMsg($WM_MOVING, "WindowEvents") GUIRegisterMsg($WM_SIZING, "WindowEvents") GUISetState() ;=== Main loop ========================================= While 1 Sleep($iSleepTime) If BitAnd(WinGetState($hGuiMain), 16) Then ContinueLoop If BitAnd(WinGetState($hGuiOpt), 2) Then ContinueLoop _Zoom($nZoomFactor, _ZoomGetOptions()) WEnd ;======================================================== Func OptionsEvents() Switch @GUI_CtrlId Case $btnOK WinToggle(@GUI_WinHandle) Case $btnMin WinToggle(@GUI_WinHandle) GUISetState(@SW_MINIMIZE, $hGuiMain) Case $btnQuit _CloseProgram() Case $cbInvert $bInvert = BitXOR($bInvert, 1) Case $cbInfoPix $bShowMini =BitXOR($bShowMini, 1) WinToggle($hGuiMini) Case $cbInfoWin $bShowText = BitXOR($bShowText, 1) Case $cbCenter $bAlwaysCenter = BitXOR($bAlwaysCenter, 1) Case $SliderZoom $nZoomFactor = GUICtrlRead($SliderZoom) GUICtrlSetData($Label1, "Zoom: x" & $nZoomFactor) Case $SliderTrans $nTrans = 0-GUICtrlRead($SliderTrans) WinSetTrans($hGuiMain, "", $nTrans) ;~ GUICtrlSetTip($SliderTrans, $nTrans) Case $inTimer $iSleepTime = Int(GUICtrlRead($inTimer)) Case $cbMouseUpdate $bMouseUpdate = BitXOR($bMouseUpdate, 1) Case $cbSave $bSave = BitXOR($bSave, 1) ;_SaveOptions() EndSwitch EndFunc Func WindowEvents($hWnd, $Msg, $wParam, $lParam) Switch $Msg Case $WM_MOVING ;zoom while moving If TimerDiff($nTimer) > $iSleepTime Then _Zoom($nZoomFactor, _ZoomGetOptions()) $nTimer = TimerInit() EndIf Case $WM_SIZING Local $tRECT = DllStructCreate("long; long; long; long", $lParam) $aTmp = WinGetPos($hGuiMini) DllCall("user32.dll", "int", "MoveWindow", "hwnd", $hGuiMini, _ "int", DllStructGetData($tRECT, 3)-DllStructGetData($tRECT, 1)-$aTmp[2]-8, _ "int", 0, _ "int", $aTmp[2], "int", $aTmp[3], "int", False) EndSwitch EndFunc Func SystemEvents() Switch @GUI_CtrlId Case $GUI_EVENT_CLOSE _CloseProgram() Case $GUI_EVENT_PRIMARYDOWN _ChangeCursor($IDC_SIZEALL) Drag($hGuiMain) Case $GUI_EVENT_PRIMARYUP ; Case $GUI_EVENT_SECONDARYDOWN If Not BitAnd(WinGetState($hGuiOpt), 2) Then If Not IsDeclared("aMPosOld") Then Global $aMPosOld[2] = [0,0] ;Options gui size - 305,230 WinMove($hGuiOpt, "", Min(Max($aMPosOld[0]-50, 0), @DesktopWidth-305), _ Min(Max($aMPosOld[1]-50, 0), @DesktopHeight-230)) WinToggle($hGuiOpt) EndIf EndSwitch EndFunc Func _CloseProgram() If BitAND(GUICtrlRead($cbSave), $GUI_CHECKED) Then _SaveOptions() Else _ClearOptions() EndIf Exit EndFunc ;by Zedna Func Drag($h) ;~ dllcall("user32.dll","int","ReleaseCapture") DllCall("user32.dll","int","SendMessage","hWnd", $h,"int",$WM_NCLBUTTONDOWN,"int", $HTCAPTION,"int", 0) EndFunc Func WinToggle($hWin) If BitAND(WinGetState($hWin), 6) Then GUISetState(@SW_DISABLE, $hWin) GUISetState(@SW_HIDE, $hWin) Else GUISetState(@SW_ENABLE, $hWin) GUISetState(@SW_SHOW, $hWin) EndIf EndFunc Func _SaveOptions() $aPos = WinGetPos($hGuiMain) RegWrite("HKCU\SOFTWARE\SiaoSoft\Magnifier v1", "WindowPos", "REG_SZ", $aPos[0] & ";" & $aPos[1] & ";" & $aPos[2] & ";" & $aPos[3]) $sOptions = $nTrans & ";" & $nZoomFactor & ";" & $bInvert & ";" & $bAlwaysCenter & ";" & _ $bShowText & ";" & $bShowMini & ";" & $iSleepTime & ";" & $bMouseUpdate & ";" & $bSave RegWrite("HKCU\SOFTWARE\SiaoSoft\Magnifier v1", "Options", "REG_SZ", $sOptions) EndFunc Func _LoadOptions() $aWinPos = StringSplit(RegRead("HKCU\SOFTWARE\SiaoSoft\Magnifier v1", "WindowPos"), ";") If $aWinPos[0] = 4 Then WinMove($hGuiMain, "", Int($aWinPos[1]), Int($aWinPos[2]), Int($aWinPos[3]), Int($aWinPos[4])) $aTmp = WinGetPos($hGuiMini) WinMove($hGuiMini, "", Int($aWinPos[3])-$aTmp[2]-8, 0) EndIf $aOpts = StringSplit(RegRead("HKCU\SOFTWARE\SiaoSoft\Magnifier v1", "Options"), ";") If $aOpts[0] = 9 Then $nTrans = Int($aOpts[1]) $nZoomFactor = Int($aOpts[2]) $bInvert = Int($aOpts[3]) $bAlwaysCenter = Int($aOpts[4]) $bShowText = Int($aOpts[5]) $bShowMini = Int($aOpts[6]) $iSleepTime = Int($aOpts[7]) $bMouseUpdate = Int($aOpts[8]) $bSave = Int($aOpts[9]) EndIf If $bShowMini Then GUICtrlSetState($cbInfoPix, $GUI_CHECKED) If $bShowText Then GUICtrlSetState($cbInfoWin, $GUI_CHECKED) If $bMouseUpdate Then GUICtrlSetState($cbMouseUpdate, $GUI_CHECKED) If $bInvert Then GUICtrlSetState($cbInvert, $GUI_CHECKED) If $bAlwaysCenter Then GUICtrlSetState($cbCenter, $GUI_CHECKED) If $bSave Then GUICtrlSetState($cbSave, $GUI_CHECKED) GUICtrlSetLimit($SliderZoom, 10, 1) GUICtrlSetLimit($SliderTrans, 0, -255) DllCall("user32.dll","int","SendMessage","hWnd", ControlGetHandle($hGuiOpt, "", $SliderZoom),"int",$TBM_SETTICFREQ,"int", 1,"int", 0) DllCall("user32.dll","int","SendMessage","hWnd", ControlGetHandle($hGuiOpt, "", $SliderTrans),"int",$TBM_SETTICFREQ,"int", 16,"int", 0) GUICtrlSetData($SliderZoom, $nZoomFactor) GUICtrlSetData($Label1, "Zoom: x" & $nZoomFactor) GUICtrlSetData($SliderTrans, 0-$nTrans) GUICtrlSetData($inTimer, $iSleepTime) WinSetTrans($hGuiMain, "", $nTrans) GUICtrlSetState($btnOK, $GUI_FOCUS) If $bShowMini Then GUISetState(@SW_SHOW, $hGuiMini) EndFunc Func _ClearOptions() $sRegRoot = "HKCU\SOFTWARE\SiaoSoft" RegDelete($sRegRoot & "\Magnifier v1") RegEnumKey($sRegRoot, 1) $err = @error RegEnumVal($sRegRoot, 1) If @error <> 0 And $err <> 0 Then RegDelete($sRegRoot) EndFunc Func _ChangeCursor($lpCursorName = 0) If $lpCursorName <> 0 Then $aRet = DllCall("user32.dll","long","LoadCursor","long",0,"long",$lpCursorName) $hCurs = $aRet[0] Else $hCurs = 0 EndIf $aRet = DllCall("user32.dll","long","SetCursor","hwnd",$hCurs) Return $aRet[0] EndFunc Func _ZoomGetOptions() $nOptions = 0 If $bShowMini Then $nOptions += 1 If $bShowText Then $nOptions += 2 If $bMouseUpdate Then $nOptions += 4 If $bAlwaysCenter Then $nOptions += 8 If $bInvert Then $nOptions += 16 Return $nOptions EndFunc Func _Zoom($zf, $dwOptions) ;=============================================================================== ; Parameter(s): $zf - zoom factor ; $dwOptions - Can be a combination of the following: ; 1 = Show mini window ; 2 = Show window info ; 4 = Update on mouse move only ; 8 = Always center view (on screen edges) ; 16 = Invert colors ;=============================================================================== Local $aMPos, $aMainSize, $aMiniSize, $aMyMainDC, $aMyMiniDC, $aScreenDC, $aPen, $aPenOld, $aMiniFont, $aMiniFontOld Local $tRECT, $srcW, $srcH, $srcX, $srcY, $sPixel, $sWinInfo $aMPos = MouseGetPos() If Not IsDeclared("aMPosOld") Then Global $aMPosOld[2] = [0,0] If BitAND($dwOptions, 4) And $aMPos[0] = $aMPosOld[0] And $aMPos[1] = $aMPosOld[1] Then Return $aMPosOld = $aMPos $aMainSize = WinGetClientSize($hGuiMain) $aMiniSize = WinGetClientSize($hGuiMini) $aMyMainDC = DLLCall("user32.dll","int","GetDC","hwnd",$hGuiMain) $aMyMiniDC = DLLCall("user32.dll","int","GetDC","hwnd",$hGuiMini) $aScreenDC = DLLCall("user32.dll","int","GetDC","hwnd",0) $tRECT = DllStructCreate("long; long; long; long") $srcW = $aMainSize[0] / $zf $srcH = $aMainSize[1] / $zf If BitAND($dwOptions, 8) Then $srcX = $aMPos[0] - $aMainSize[0] / (2 * $zf) $srcY = $aMPos[1] - $aMainSize[1] / (2 * $zf) $dwRop = $MERGECOPY Else $srcX = Min(Max($aMPos[0] - $aMainSize[0] / (2 * $zf), 0), @DesktopWidth-$srcW) $srcY = Min(Max($aMPos[1] - $aMainSize[1] / (2 * $zf), 0), @DesktopHeight-$srcH) $dwRop = $SRCCOPY EndIf If BitAND($dwOptions, 16) Then $dwRop = $NOTSRCCOPY DLLCall("gdi32.dll","int","StretchBlt", _ "int",$aMyMainDC[0],"int", 0,"int",0,"int",$aMainSize[0],"int",$aMainSize[1], _ "int",$aScreenDC[0],"int", $srcX,"int",$srcY,"int",$srcW,"int",$srcH, _ "long", $dwRop) If BitAND($dwOptions, 1) Then ; strech 5x5 area around cursor into Mini gui DLLCall("gdi32.dll","int","StretchBlt", _ "int",$aMyMiniDC[0],"int", 0,"int",0,"int",$aMiniSize[0],"int",$aMiniSize[1], _ "int",$aScreenDC[0],"int", $aMPos[0]-2,"int",$aMPos[1]-2,"int",5,"int",5, _ "long", $dwRop) ;draw crosshair on top of it DLLCall("gdi32.dll","int","Arc", "hwnd", $aMyMiniDC[0], _ "int", 0, "int", 0, "int", $aMiniSize[0], "int", $aMiniSize[1], _ "int", 0, "int", $aMiniSize[1]/2, "int", 0, "int", $aMiniSize[1]/2) $aPen = DLLCall("gdi32.dll","hwnd","CreatePen", "int", 3, "int", 0, "int", 0x00000000) $aPenOld = DLLCall("gdi32.dll","hwnd","SelectObject", "hwnd", $aMyMiniDC[0], "hwnd", $aPen[0]) DLLCall("gdi32.dll","int","MoveToEx", "hwnd", $aMyMiniDC[0], "int", 0, "int", $aMiniSize[1]/2, "ptr", 0) DLLCall("gdi32.dll","int","LineTo", "hwnd", $aMyMiniDC[0], "int", $aMiniSize[0], "int", $aMiniSize[1]/2) DLLCall("gdi32.dll","int","MoveToEx", "hwnd", $aMyMiniDC[0], "int", $aMiniSize[0]/2, "int", 0, "ptr", 0) DLLCall("gdi32.dll","int","LineTo", "hwnd", $aMyMiniDC[0], "int", $aMiniSize[0]/2, "int", $aMiniSize[1]) ;draw pixel color/pos text DllStructSetData($tRECT, 1, 0) DllStructSetData($tRECT, 2, 0) DllStructSetData($tRECT, 3, $aMiniSize[0]) DllStructSetData($tRECT, 4, 14) $aMiniFont = DLLCall("gdi32.dll","int","CreateFont", "int", 14, "int", 0, "int", 0, "int", 0, "int", 700, _ "dword", 0, "dword", 0, "dword", 0, "dword", 0, "dword", 0, "dword", 0, "dword", 0, _ "dword", 0, "str", "") $aMiniFontOld = DLLCall("gdi32.dll","hwnd","SelectObject", "hwnd", $aMyMiniDC[0], "hwnd", $aMiniFont[0]) $sPixel = " 0x" & Hex(PixelGetColor($aMPos[0],$aMPos[1]),6) & " at " & $aMPos[0] & "," & $aMPos[1] & " " DLLCall("user32.dll","int","DrawText", "hwnd", $aMyMiniDC[0], _ "str", $sPixel, "int", StringLen($sPixel), "ptr", DllStructGetPtr($tRECT), "uint", 0) DLLCall("gdi32.dll","hwnd","SelectObject", "hwnd", $aMyMiniDC[0], "hwnd", $aMiniFontOld[0]) DLLCall("gdi32.dll","int","DeleteObject", "hwnd", $aMiniFont[0]) DLLCall("gdi32.dll","hwnd","SelectObject", "hwnd", $aMyMiniDC[0], "hwnd", $aPenOld[0]) DLLCall("gdi32.dll","int","DeleteObject", "hwnd", $aPen[0]) EndIf If BitAND($dwOptions, 2) Then ;get and show window/control info $sWinInfo = _WinInfoFromPoint($aMPos[0], $aMPos[1]) DllStructSetData($tRECT, 1, 0) DllStructSetData($tRECT, 2, $aMainSize[1]-48) DllStructSetData($tRECT, 3, $aMainSize[0]) DllStructSetData($tRECT, 4, $aMainSize[1]) DLLCall("user32.dll","int","DrawText", "hwnd", $aMyMainDC[0], _ "str", $sWinInfo, "int", StringLen($sWinInfo), "ptr", DllStructGetPtr($tRECT), "uint", $DT_RIGHT) EndIf DLLCall("user32.dll","int","ReleaseDC","hwnd",0,"hwnd",$aScreenDC[0]) DLLCall("user32.dll","int","ReleaseDC","hwnd",$hGuiMain,"hwnd",$aMyMainDC[0]) DLLCall("user32.dll","int","ReleaseDC","hwnd",$hGuiMini,"hwnd",$aMyMiniDC[0]) EndFunc ;Gets window/control info from cursor pos, returns formatted string Func _WinInfoFromPoint($nX, $nY) Local $tStrBuff, $pStrBuff, $aRet, $hWnd, $hOwnerWnd, $sClassName, $sOwnerClass, $sWinText $tStrBuff = DllStructCreate("char[100]") $pStrBuff = DllStructGetPtr($tStrBuff) $aRet = DllCall("user32.dll", "hwnd", "WindowFromPoint", "uint", $nX, "uint", $nY) $hWnd = $aRet[0] $aRet = DllCall("user32.dll", "int", "GetClassName", "hwnd", $hWnd, "ptr", $pStrBuff, "int", 100) $sClassName = DllStructGetData($tStrBuff, 1) DllStructSetData($tStrBuff, 1, "") DllCall("user32.dll", "int", "GetWindowText", "hwnd", $hWnd, "ptr", $pStrBuff, "int", 100) ;~ DllCall("user32.dll", "int", "SendMessage", "hwnd", $hWnd, "uint", $WM_GETTEXT, "uint", 100, "ptr", $pStrBuff) $sWinText = DllStructGetData($tStrBuff, 1) DllStructSetData($tStrBuff, 1, "") $aRet = DllCall("user32.dll", "hwnd", "GetAncestor", "hwnd", $hWnd, "uint", 2) ;$GA_ROOT = 2 $hOwnerWnd = $aRet[0] $aRet = DllCall("user32.dll", "int", "GetClassName", "hwnd", $hOwnerWnd, "ptr", $pStrBuff, "int", 100) $sOwnerClass = DllStructGetData($tStrBuff, 1) DllStructSetData($tStrBuff, 1, "") Return $sWinText & @CRLF & "[ Class: " & $sClassName & "; hWnd: " & $hWnd & " ]" & @CRLF & _ "( Owner: " & $sOwnerClass & "; " & $hOwnerWnd & " )" EndFunc Func Min($n1, $n2) If $n1 < $n2 Then Return $n1 Return $n2 EndFunc Func Max($n1, $n2) If $n1 > $n2 Then Return $n1 Return $n2 EndFunc ;================or attachment... screen_magnifier_v1.au31 point
-
An oldie, but a goodie. This is a modified version of Siao's script of post #1 for easy download and run/compile. Changes made in this copy are:- - Commenting out the Global Const lines that are already been declared; - Added $iScale, for use when Desktop (right mouse click) > "Display settings" > "Scale and Layout" is other than 100%. - Added arrow keys movement. (When scale is not 100%, pixel movement is not always one pixel at a time.) - Add colour and position of pixel to clipboard when Ctrl-c is pressed. I liked using this pixel viewer (magnifier) until it stopped being accurate on my new laptop with a desktop display scale of 125%. The thread in AutoIt Example Scripts Forum which is also inaccurate because my desktop scale is not 100%, motivated me to resurrect Siao's magnifier. ;##################################################### #cs Screen Magnifier, Pixel pos and Window info tool all-in-one, by Siao Usage: Main window resizeable Left click drags window Right mouse click on GUI brings up options. <----------------- Note well <--------- etc. Modified: Malkey - Added $iScale, for use when on clear Desktop (right mouse click) > "Display settings" > "Scale and Layout" is other than 100%. - Added arrow keys movement. When scale is not 100%, pixel movement is not always one pixel at a time. - Added colour and position of pixel to clipboard when Ctrl-c is pressed. See - https://www.autoitscript.com/forum/topic/54776-yet-another-screen-magnifier-and-info-tool/?do=findComment&comment=1361170 #ce ;########################################################## #include <GUIConstants.au3> #include <WinAPIGdi.au3>; Added #include <Misc.au3>; Added #NoTrayIcon Opt("WinWaitDelay", 0) Opt("GUICloseOnESC", 0) Opt("GUIOnEventMode", 1) ;Global Const $WM_MOVING = 0x0216 ;~ Global Const $WM_SIZING = 0x0214 ;cursors ;Global Const $IDC_SIZEALL = 32646 ;Global Const $IDC_ARROW = 32512 ;~ Global Const $WM_SETCURSOR = 0x0020 ;Drag constants ;Global Const $HTCAPTION = 2 ;Global Const $WM_NCLBUTTONDOWN = 0xA1 ;raster opcodes ;normal: ;Global Const $SRCCOPY = 0xCC0020 ;Global Const $MERGECOPY = 0xC000CA ;inverted: ;Global Const $NOTSRCCOPY = 0x330008 ;text constants: ;Global Const $DT_RIGHT = 0x2 HotKeySet("^c", "HotKeyCopy") ; Control c Global $iScale = _WinAPI_EnumDisplaySettings('', $ENUM_CURRENT_SETTINGS)[0] / @DesktopWidth ; Added Global $iXMove = 0, $iYMove = 0, $sPixel Global $nZoomFactor = 2, $aMPosOld[2], $nTrans = 200 Global $iSleepTime = 90, $nTimer = 0, $bShowMini = 1, $bShowText = 1, $bAlwaysCenter = 0, $bInvert = 0, $bMouseUpdate = 1, $bSave = 0 ;Main view GUI $hGuiMain = GUICreate("Magnifier by Siao", 400, 300, -1, -1, _ BitOR($WS_POPUP, $WS_BORDER, $WS_SIZEBOX + $WS_CLIPCHILDREN), _ $WS_EX_TOPMOST _ ) ;+$WS_EX_LAYERED+$WS_EX_TRANSPARENT ;Mini view GUI $hGuiMini = GUICreate("Aimpoint 5x5", 128, 128, 400 - 130, 0, $WS_CHILD + $WS_BORDER, -1, $hGuiMain) ;Options GUI #Region ### START Koda GUI section ### Form=d:\miniprojects\autoit3\magnifier\guioptions.kxf $hGuiOpt = GUICreate("Magnifier Options", 305, 230, -1, -1, BitOR($WS_SYSMENU, $WS_POPUP, $WS_POPUPWINDOW, $WS_BORDER, $WS_CLIPSIBLINGS), -1, $hGuiMain) $btnMin = GUICtrlCreateButton("Minimize", 5, 5, 145, 25, 0) GUICtrlSetOnEvent(-1, "OptionsEvents") $btnQuit = GUICtrlCreateButton("Quit Program", 155, 5, 145, 25, 0) GUICtrlSetOnEvent(-1, "OptionsEvents") $SliderTrans = GUICtrlCreateSlider(6, 54, 19, 165, BitOR($TBS_VERT, $TBS_AUTOTICKS)) GUICtrlSetCursor(-1, 11) GUICtrlSetOnEvent(-1, "OptionsEvents") $grp1 = GUICtrlCreateGroup("View options", 60, 40, 235, 147) $SliderZoom = GUICtrlCreateSlider(126, 60, 161, 19) ;, $TBS_AUTOTICKS) GUICtrlSetLimit(-1, 100, 1) GUICtrlSetData(-1, 2) GUICtrlSetCursor(-1, 13) GUICtrlSetOnEvent(-1, "OptionsEvents") $cbInvert = GUICtrlCreateCheckbox("Invert colors", 76, 90, 93, 21) GUICtrlSetOnEvent(-1, "OptionsEvents") $cbCenter = GUICtrlCreateCheckbox("Always center", 76, 108, 93, 21) GUICtrlSetOnEvent(-1, "OptionsEvents") $Label1 = GUICtrlCreateLabel("Zoom:", 74, 60, 50, 17) $cbInfoPix = GUICtrlCreateCheckbox("Show pixel info", 182, 108, 93, 21) GUICtrlSetOnEvent(-1, "OptionsEvents") $cbInfoWin = GUICtrlCreateCheckbox("Show win info", 182, 90, 93, 21) GUICtrlSetOnEvent(-1, "OptionsEvents") $inTimer = GUICtrlCreateInput("", 192, 136, 37, 21, $ES_NUMBER) GUICtrlSetOnEvent(-1, "OptionsEvents") $Label3 = GUICtrlCreateLabel("Update time (ms):", 106, 138, 86, 17) $cbMouseUpdate = GUICtrlCreateCheckbox("Update only on mouse move", 104, 159, 161, 21) GUICtrlSetOnEvent(-1, "OptionsEvents") GUICtrlCreateGroup("", -99, -99, 1, 1) $Label2 = GUICtrlCreateLabel("Trans:", 6, 40, 34, 17) $Label4 = GUICtrlCreateLabel("(c) Siao, 2007", 300, 226, 1, 1, BitOR($SS_CENTER, $SS_CENTERIMAGE, $WS_BORDER)) GUICtrlSetCursor(-1, 0) $Label5 = GUICtrlCreateLabel("0", 30, 204, 10, 17) $Label6 = GUICtrlCreateLabel("255", 30, 57, 22, 17) $cbSave = GUICtrlCreateCheckbox("Remember options", 70, 194, 113, 30) GUICtrlSetOnEvent(-1, "OptionsEvents") $btnOK = GUICtrlCreateButton("OK", 198, 194, 87, 29, 0) GUICtrlSetOnEvent(-1, "OptionsEvents") GUISetState(@SW_DISABLE) GUISetState(@SW_HIDE) #EndRegion ### END Koda GUI section ### _LoadOptions() GUISwitch($hGuiMain) GUISetOnEvent($GUI_EVENT_CLOSE, "SystemEvents") GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "SystemEvents") GUISetOnEvent($GUI_EVENT_SECONDARYDOWN, "SystemEvents") GUIRegisterMsg($WM_MOVING, "WindowEvents") GUIRegisterMsg($WM_SIZING, "WindowEvents") GUISetState() ;=== Main loop ========================================= While 1 Sleep($iSleepTime) If BitAND(WinGetState($hGuiMain), 16) Then ContinueLoop If BitAND(WinGetState($hGuiOpt), 2) Then ContinueLoop If _IsPressed("26") Then ; UP ARROW key While _IsPressed("26") WEnd $iXMove = 0.00 $iYMove = -1.00 ElseIf _IsPressed("28") Then ; DOWN ARROW key While _IsPressed("28") WEnd $iXMove = 0.00 $iYMove = 1.00 ElseIf _IsPressed("25") Then ; LEFT ARROW key While _IsPressed("25") WEnd $iXMove = -1.00 $iYMove = 0.00 ElseIf _IsPressed("27") Then ; RIGHT ARROW key While _IsPressed("27") WEnd $iXMove = 1.00 $iYMove = 0.00 Else $iXMove = 0.00 $iYMove = 0.00 EndIf _Zoom($nZoomFactor, _ZoomGetOptions()) WEnd ;======================================================== Func OptionsEvents() Switch @GUI_CtrlId Case $btnOK WinToggle(@GUI_WinHandle) Case $btnMin WinToggle(@GUI_WinHandle) GUISetState(@SW_MINIMIZE, $hGuiMain) Case $btnQuit _CloseProgram() Case $cbInvert $bInvert = BitXOR($bInvert, 1) Case $cbInfoPix $bShowMini = BitXOR($bShowMini, 1) WinToggle($hGuiMini) Case $cbInfoWin $bShowText = BitXOR($bShowText, 1) Case $cbCenter $bAlwaysCenter = BitXOR($bAlwaysCenter, 1) Case $SliderZoom $nZoomFactor = GUICtrlRead($SliderZoom) GUICtrlSetData($Label1, "Zoom: x" & $nZoomFactor) Case $SliderTrans $nTrans = 0 - GUICtrlRead($SliderTrans) WinSetTrans($hGuiMain, "", $nTrans) ;~ GUICtrlSetTip($SliderTrans, $nTrans) Case $inTimer $iSleepTime = Int(GUICtrlRead($inTimer)) Case $cbMouseUpdate $bMouseUpdate = BitXOR($bMouseUpdate, 1) Case $cbSave $bSave = BitXOR($bSave, 1) ;_SaveOptions() EndSwitch EndFunc ;==>OptionsEvents Func WindowEvents($hWnd, $Msg, $wParam, $lParam) Switch $Msg Case $WM_MOVING ;zoom while moving If TimerDiff($nTimer) > $iSleepTime Then _Zoom($nZoomFactor, _ZoomGetOptions()) $nTimer = TimerInit() EndIf Case $WM_SIZING Local $tRECT = DllStructCreate("long; long; long; long", $lParam) $aTmp = WinGetPos($hGuiMini) DllCall("user32.dll", "int", "MoveWindow", "hwnd", $hGuiMini, _ "int", DllStructGetData($tRECT, 3) - DllStructGetData($tRECT, 1) - $aTmp[2] - 8, _ "int", 0, _ "int", $aTmp[2], "int", $aTmp[3], "int", False) EndSwitch EndFunc ;==>WindowEvents Func SystemEvents() Switch @GUI_CtrlId Case $GUI_EVENT_CLOSE _CloseProgram() Case $GUI_EVENT_PRIMARYDOWN _ChangeCursor($IDC_SIZEALL) Drag($hGuiMain) Case $GUI_EVENT_PRIMARYUP ; Case $GUI_EVENT_SECONDARYDOWN If Not BitAND(WinGetState($hGuiOpt), 2) Then If Not IsDeclared("aMPosOld") Then Global $aMPosOld[2] = [0, 0] ;Options gui size - 305,230 WinMove($hGuiOpt, "", Min(Max($aMPosOld[0] - 50, 0), @DesktopWidth - 305), _ Min(Max($aMPosOld[1] - 50, 0), @DesktopHeight - 230)) WinToggle($hGuiOpt) EndIf EndSwitch EndFunc ;==>SystemEvents Func _CloseProgram() If BitAND(GUICtrlRead($cbSave), $GUI_CHECKED) Then _SaveOptions() Else _ClearOptions() EndIf Exit EndFunc ;==>_CloseProgram ;by Zedna Func Drag($h) ;~ dllcall("user32.dll","int","ReleaseCapture") DllCall("user32.dll", "int", "SendMessage", "hWnd", $h, "int", $WM_NCLBUTTONDOWN, "int", $HTCAPTION, "int", 0) EndFunc ;==>Drag Func WinToggle($hWin) If BitAND(WinGetState($hWin), 6) Then GUISetState(@SW_DISABLE, $hWin) GUISetState(@SW_HIDE, $hWin) Else GUISetState(@SW_ENABLE, $hWin) GUISetState(@SW_SHOW, $hWin) EndIf EndFunc ;==>WinToggle Func _SaveOptions() $aPos = WinGetPos($hGuiMain) RegWrite("HKCU\SOFTWARE\SiaoSoft\Magnifier v1", "WindowPos", "REG_SZ", $aPos[0] & ";" & $aPos[1] & ";" & $aPos[2] & ";" & $aPos[3]) $sOptions = $nTrans & ";" & $nZoomFactor & ";" & $bInvert & ";" & $bAlwaysCenter & ";" & _ $bShowText & ";" & $bShowMini & ";" & $iSleepTime & ";" & $bMouseUpdate & ";" & $bSave RegWrite("HKCU\SOFTWARE\SiaoSoft\Magnifier v1", "Options", "REG_SZ", $sOptions) EndFunc ;==>_SaveOptions Func _LoadOptions() $aWinPos = StringSplit(RegRead("HKCU\SOFTWARE\SiaoSoft\Magnifier v1", "WindowPos"), ";") If $aWinPos[0] = 4 Then WinMove($hGuiMain, "", Int($aWinPos[1]), Int($aWinPos[2]), Int($aWinPos[3]), Int($aWinPos[4])) $aTmp = WinGetPos($hGuiMini) WinMove($hGuiMini, "", Int($aWinPos[3]) - $aTmp[2] - 8, 0) EndIf $aOpts = StringSplit(RegRead("HKCU\SOFTWARE\SiaoSoft\Magnifier v1", "Options"), ";") If $aOpts[0] = 9 Then $nTrans = Int($aOpts[1]) $nZoomFactor = Int($aOpts[2]) $bInvert = Int($aOpts[3]) $bAlwaysCenter = Int($aOpts[4]) $bShowText = Int($aOpts[5]) $bShowMini = Int($aOpts[6]) $iSleepTime = Int($aOpts[7]) $bMouseUpdate = Int($aOpts[8]) $bSave = Int($aOpts[9]) EndIf If $bShowMini Then GUICtrlSetState($cbInfoPix, $GUI_CHECKED) If $bShowText Then GUICtrlSetState($cbInfoWin, $GUI_CHECKED) If $bMouseUpdate Then GUICtrlSetState($cbMouseUpdate, $GUI_CHECKED) If $bInvert Then GUICtrlSetState($cbInvert, $GUI_CHECKED) If $bAlwaysCenter Then GUICtrlSetState($cbCenter, $GUI_CHECKED) If $bSave Then GUICtrlSetState($cbSave, $GUI_CHECKED) GUICtrlSetLimit($SliderZoom, 10, 1) GUICtrlSetLimit($SliderTrans, 0, -255) DllCall("user32.dll", "int", "SendMessage", "hWnd", ControlGetHandle($hGuiOpt, "", $SliderZoom), "int", $TBM_SETTICFREQ, "int", 1, "int", 0) DllCall("user32.dll", "int", "SendMessage", "hWnd", ControlGetHandle($hGuiOpt, "", $SliderTrans), "int", $TBM_SETTICFREQ, "int", 16, "int", 0) GUICtrlSetData($SliderZoom, $nZoomFactor) GUICtrlSetData($Label1, "Zoom: x" & $nZoomFactor) GUICtrlSetData($SliderTrans, 0 - $nTrans) GUICtrlSetData($inTimer, $iSleepTime) WinSetTrans($hGuiMain, "", $nTrans) GUICtrlSetState($btnOK, $GUI_FOCUS) If $bShowMini Then GUISetState(@SW_SHOW, $hGuiMini) EndFunc ;==>_LoadOptions Func _ClearOptions() $sRegRoot = "HKCU\SOFTWARE\SiaoSoft" RegDelete($sRegRoot & "\Magnifier v1") RegEnumKey($sRegRoot, 1) $err = @error RegEnumVal($sRegRoot, 1) If @error <> 0 And $err <> 0 Then RegDelete($sRegRoot) EndFunc ;==>_ClearOptions Func _ChangeCursor($lpCursorName = 0) If $lpCursorName <> 0 Then $aRet = DllCall("user32.dll", "long", "LoadCursor", "long", 0, "long", $lpCursorName) $hCurs = $aRet[0] Else $hCurs = 0 EndIf $aRet = DllCall("user32.dll", "long", "SetCursor", "hwnd", $hCurs) Return $aRet[0] EndFunc ;==>_ChangeCursor Func _ZoomGetOptions() $nOptions = 0 If $bShowMini Then $nOptions += 1 If $bShowText Then $nOptions += 2 If $bMouseUpdate Then $nOptions += 4 If $bAlwaysCenter Then $nOptions += 8 If $bInvert Then $nOptions += 16 Return $nOptions EndFunc ;==>_ZoomGetOptions Func _Zoom($zf, $dwOptions) ;=============================================================================== ; Parameter(s): $zf - zoom factor ; $dwOptions - Can be a combination of the following: ; 1 = Show mini window ; 2 = Show window info ; 4 = Update on mouse move only ; 8 = Always center view (on screen edges) ; 16 = Invert colors ;=============================================================================== Local $aMPos, $aMainSize, $aMiniSize, $aMyMainDC, $aMyMiniDC, $aScreenDC, $aPen, $aPenOld, $aMiniFont, $aMiniFontOld Local $tRECT, $srcW, $srcH, $srcX, $srcY, $sWinInfo $aMPos = MouseGetPos() If $iXMove Or $iYMove Then MouseMove(Int($aMPos[0] + ($iXMove * $iScale)), Int($aMPos[1] + ($iYMove * $iScale)), 0) $aMPos = MouseGetPos() EndIf $aMPos[0] = Int($aMPos[0] * $iScale) ; Added $aMPos[1] = Int($aMPos[1] * $iScale) ; Added If Not IsDeclared("aMPosOld") Then Global $aMPosOld[2] = [0, 0] If BitAND($dwOptions, 4) And $aMPos[0] = $aMPosOld[0] And $aMPos[1] = $aMPosOld[1] Then Return $aMPosOld = $aMPos $aMainSize = WinGetClientSize($hGuiMain) $aMiniSize = WinGetClientSize($hGuiMini) $aMyMainDC = DllCall("user32.dll", "int", "GetDC", "hwnd", $hGuiMain) $aMyMiniDC = DllCall("user32.dll", "int", "GetDC", "hwnd", $hGuiMini) $aScreenDC = DllCall("user32.dll", "int", "GetDC", "hwnd", 0) $tRECT = DllStructCreate("long; long; long; long") $srcW = $aMainSize[0] / $zf $srcH = $aMainSize[1] / $zf If BitAND($dwOptions, 8) Then $srcX = $aMPos[0] - $aMainSize[0] / (2 * $zf) $srcY = $aMPos[1] - $aMainSize[1] / (2 * $zf) $dwRop = $MERGECOPY Else $srcX = Min(Max($aMPos[0] - $aMainSize[0] / (2 * $zf), 0), @DesktopWidth - $srcW) $srcY = Min(Max($aMPos[1] - $aMainSize[1] / (2 * $zf), 0), @DesktopHeight - $srcH) $dwRop = $SRCCOPY EndIf If BitAND($dwOptions, 16) Then $dwRop = $NOTSRCCOPY DllCall("gdi32.dll", "int", "StretchBlt", _ "int", $aMyMainDC[0], "int", 0, "int", 0, "int", $aMainSize[0], "int", $aMainSize[1], _ "int", $aScreenDC[0], "int", $srcX, "int", $srcY, "int", $srcW, "int", $srcH, _ "long", $dwRop) If BitAND($dwOptions, 1) Then ; strech 5x5 area around cursor into Mini gui DllCall("gdi32.dll", "int", "StretchBlt", _ "int", $aMyMiniDC[0], "int", 0, "int", 0, "int", $aMiniSize[0], "int", $aMiniSize[1], _ "int", $aScreenDC[0], "int", $aMPos[0] - 2, "int", $aMPos[1] - 2, "int", 5, "int", 5, _ "long", $dwRop) ;draw crosshair on top of it DllCall("gdi32.dll", "int", "Arc", "hwnd", $aMyMiniDC[0], _ "int", 0, "int", 0, "int", $aMiniSize[0], "int", $aMiniSize[1], _ "int", 0, "int", $aMiniSize[1] / 2, "int", 0, "int", $aMiniSize[1] / 2) $aPen = DllCall("gdi32.dll", "hwnd", "CreatePen", "int", 3, "int", 0, "int", 0x00000000) $aPenOld = DllCall("gdi32.dll", "hwnd", "SelectObject", "hwnd", $aMyMiniDC[0], "hwnd", $aPen[0]) DllCall("gdi32.dll", "int", "MoveToEx", "hwnd", $aMyMiniDC[0], "int", 0, "int", $aMiniSize[1] / 2, "ptr", 0) DllCall("gdi32.dll", "int", "LineTo", "hwnd", $aMyMiniDC[0], "int", $aMiniSize[0], "int", $aMiniSize[1] / 2) DllCall("gdi32.dll", "int", "MoveToEx", "hwnd", $aMyMiniDC[0], "int", $aMiniSize[0] / 2, "int", 0, "ptr", 0) DllCall("gdi32.dll", "int", "LineTo", "hwnd", $aMyMiniDC[0], "int", $aMiniSize[0] / 2, "int", $aMiniSize[1]) $aPenOld = DllCall("gdi32.dll", "hwnd", "SelectObject", "hwnd", $aMyMainDC[0], "hwnd", $aPen[0]) DllCall("gdi32.dll", "int", "MoveToEx", "hwnd", $aMyMainDC[0], "int", 0, "int", $aMainSize[1] / 2, "ptr", 0) DllCall("gdi32.dll", "int", "LineTo", "hwnd", $aMyMainDC[0], "int", $aMainSize[0], "int", $aMainSize[1] / 2) DllCall("gdi32.dll", "int", "MoveToEx", "hwnd", $aMyMainDC[0], "int", $aMainSize[0] / 2, "int", 0, "ptr", 0) DllCall("gdi32.dll", "int", "LineTo", "hwnd", $aMyMainDC[0], "int", $aMainSize[0] / 2, "int", $aMainSize[1]) ;draw pixel color/pos text DllStructSetData($tRECT, 1, 0) DllStructSetData($tRECT, 2, 0) DllStructSetData($tRECT, 3, $aMiniSize[0]) DllStructSetData($tRECT, 4, 14) $aMiniFont = DllCall("gdi32.dll", "int", "CreateFont", "int", 14, "int", 0, "int", 0, "int", 0, "int", 700, _ "dword", 0, "dword", 0, "dword", 0, "dword", 0, "dword", 0, "dword", 0, "dword", 0, _ "dword", 0, "str", "") $aMiniFontOld = DllCall("gdi32.dll", "hwnd", "SelectObject", "hwnd", $aMyMiniDC[0], "hwnd", $aMiniFont[0]) $sPixel = " 0x" & Hex(PixelGetColor($aMPos[0], $aMPos[1]), 6) & " at " & $aMPos[0] & "," & $aMPos[1] & " " DllCall("user32.dll", "int", "DrawText", "hwnd", $aMyMiniDC[0], _ "str", $sPixel, "int", StringLen($sPixel), "ptr", DllStructGetPtr($tRECT), "uint", 0) DllCall("gdi32.dll", "hwnd", "SelectObject", "hwnd", $aMyMiniDC[0], "hwnd", $aMiniFontOld[0]) DllCall("gdi32.dll", "int", "DeleteObject", "hwnd", $aMiniFont[0]) DllCall("gdi32.dll", "hwnd", "SelectObject", "hwnd", $aMyMiniDC[0], "hwnd", $aPenOld[0]) DllCall("gdi32.dll", "int", "DeleteObject", "hwnd", $aPen[0]) EndIf If BitAND($dwOptions, 2) Then ;get and show window/control info $sWinInfo = _WinInfoFromPoint($aMPos[0], $aMPos[1]) DllStructSetData($tRECT, 1, 0) DllStructSetData($tRECT, 2, $aMainSize[1] - 48) DllStructSetData($tRECT, 3, $aMainSize[0]) DllStructSetData($tRECT, 4, $aMainSize[1]) DllCall("user32.dll", "int", "DrawText", "hwnd", $aMyMainDC[0], _ "str", $sWinInfo, "int", StringLen($sWinInfo), "ptr", DllStructGetPtr($tRECT), "uint", $DT_RIGHT) EndIf DllCall("user32.dll", "int", "ReleaseDC", "hwnd", 0, "hwnd", $aScreenDC[0]) DllCall("user32.dll", "int", "ReleaseDC", "hwnd", $hGuiMain, "hwnd", $aMyMainDC[0]) DllCall("user32.dll", "int", "ReleaseDC", "hwnd", $hGuiMini, "hwnd", $aMyMiniDC[0]) EndFunc ;==>_Zoom ;Gets window/control info from cursor pos, returns formatted string Func _WinInfoFromPoint($nX, $nY) Local $tStrBuff, $pStrBuff, $aRet, $hWnd, $hOwnerWnd, $sClassName, $sOwnerClass, $sWinText $tStrBuff = DllStructCreate("char[100]") $pStrBuff = DllStructGetPtr($tStrBuff) $aRet = DllCall("user32.dll", "hwnd", "WindowFromPoint", "uint", $nX, "uint", $nY) $hWnd = $aRet[0] $aRet = DllCall("user32.dll", "int", "GetClassName", "hwnd", $hWnd, "ptr", $pStrBuff, "int", 100) $sClassName = DllStructGetData($tStrBuff, 1) DllStructSetData($tStrBuff, 1, "") DllCall("user32.dll", "int", "GetWindowText", "hwnd", $hWnd, "ptr", $pStrBuff, "int", 100) ; DllCall("user32.dll", "int", "SendMessage", "hwnd", $hWnd, "uint", $WM_GETTEXT, "uint", 100, "ptr", $pStrBuff) $sWinText = DllStructGetData($tStrBuff, 1) DllStructSetData($tStrBuff, 1, "") $aRet = DllCall("user32.dll", "hwnd", "GetAncestor", "hwnd", $hWnd, "uint", 2) ;$GA_ROOT = 2 $hOwnerWnd = $aRet[0] $aRet = DllCall("user32.dll", "int", "GetClassName", "hwnd", $hOwnerWnd, "ptr", $pStrBuff, "int", 100) $sOwnerClass = DllStructGetData($tStrBuff, 1) DllStructSetData($tStrBuff, 1, "") Return $sWinText & @CRLF & "[ Class: " & $sClassName & "; hWnd: " & $hWnd & " ]" & @CRLF & _ "( Owner: " & $sOwnerClass & "; " & $hOwnerWnd & " )" EndFunc ;==>_WinInfoFromPoint Func Min($n1, $n2) If $n1 < $n2 Then Return $n1 Return $n2 EndFunc ;==>Min Func Max($n1, $n2) If $n1 > $n2 Then Return $n1 Return $n2 EndFunc ;==>Max ;================ Func HotKeyCopy() ClipPut($sPixel) EndFunc ;==>HotKeyCopy1 point