Leaderboard
Popular Content
Showing content with the highest reputation on 05/02/2014 in all areas
-
The simple answer is: You don't get a CLSID from a IID. A CLSID is a GUID identifying a COM class. An IID is a GUID identifying a COM interface. A COM class (or object) typically implements several COM interfaces. When using a COM class you must both specify an identifier for the COM class, and an identifier for the actual COM interface. The most common way to create a COM interface, is to use QueryInterface to get a pointer for the interface object, and then create the interface with ObjCreateInterface. Here's a random example: $oIShellView.QueryInterface( $tRIID_IFolderView, $pIFolderView ) $oIFolderView = ObjCreateInterface( $pIFolderView, $sIID_IFolderView, $dtag_IFolderView ) I think IPersistFile is mostly used in connection with other interfaces, and it would probably be created with QueryInterface.3 points
-
File Name: AutoIt v3.3.11.5 Beta File Submitter: Jon File Submitted: 01 May 2014 File Category: Beta AutoIt: - Fixed #2648: FileSaveDialog() not adding extension when user types manually. UDFs: - Changed: _FileReadToArray() now returns a 1D/2D array depending on parameters used. - Fixed: sqlite3.* downloading if running in Admin mode. - Fixed #2693: _GUICtrListView_GetItemTextArray() return value doc. - Fixed #2697: missing $GW_ENABLEDPOPUP constant. - Fixed #2698: _ArrayAdd() wrong return value. - Fixed #2699: _ArrayAdd() 6th parameter doc. - Fixed: _ArraySearch() searching backward. - Fixed #2700: _GUICtrlRichEdit_SetCharBkColor() not at insertpoint. Au3Check: - Fixed #2612: Function reference ByRef. Click here to download this file2 points
-
Implementing Windows Explorer right pane
pixelsearch reacted to LarsJ for a topic
Note that this is a real Windows Explorer. But only the right pane. All functionality of Windows Explorer is working. E.g. keyboard shortcuts, the context (right click) menu, cut, copy, paste, drag & drop and automatic update of the window. Implementations There are three implementations: An implementation for Vista, 7 and 8, an implementation for Windows XP, and a SysListView32 based implementation for Vista, 7 and 8. The latter is named SysLv32.au3 in the examples. This is more or less the Windows XP implementation adapted for Vista, 7 and 8. Functionality The implementations are based on Shell interfaces. This means that most functionality of Windows Explorer is working automatically without any additional code. Other features: Position Explorer window in GUISpecify root and start foldersSpecify an initial icon view modeSpecify an icon view mode for the DesktopSpecify a file filter to filter files by extensionUse folder flags $FWF_NOBACKBROWSING, $FWF_SINGLESEL and $FWF_NOSUBFOLDERSBrowse to child/parent folder with Enter/Backspace keysDelete, disable and insert items in the context menuExecute context menu commands in codeDocumentation Use ExplorerWindowCreate() to create the right pane window. This function is located in Explorer\<Implementation>\WindowsExplorer.au3. You find documentation for the function in top of the file. Documentation for the Vista, 7, 8 implementation is included in the Examples section below. Ini file To handle Rename, New and View in the context menu, it's necessary to be able to identify these items. This seems only to be possible to do, by identifying the names. Because the names are localized, an ini file is used to store the names. Especially the View command depends on the ini file. If the View command isn't recognized, the icon view modes are not set properly. Rename and New commands are depending on the ini file, when the commands are selected with the keyboard. More information in the sections below. First release 2013-11-28 In first release Explorer right pane windows are created with enough functionality to get it to work. There are two implementations: One for Vista, 7 and 8, and one for Windows XP. First update 2014-03-14 This update consists primarily of bug fixes in first release. Because both APIConstants.au3 and WinAPIEx.au3 are included, the scripts can't run on AutoIt 3.3.10 without modifications. A new implementation for Vista, 7 and 8 is added. This implementation is based on a SysListView32 control. This is more or less the Windows XP implementation adapted for Vista, 7 and 8. Second update 2014-04-23 The implementations are based on Shell interfaces, and most functionality of Windows Explorer is working automatically. But you still have to integrate that functionality into your script. Especially you have to take care of keystrokes in combination with various controls and windows. E.g. the rename edit box, the context menu and dialog boxes. This update introduces an ini file: Explorer\Inifiles\ContextMenu.ini Third update 2014-05-02 The third update is mostly about the context menu. It's divided into two parts. The first part is about manipulating the context menu. The example shows how to delete, disable and add custom menu items. The second part shows how to execute context menu commands in code. The example implements Cut, Copy and Paste buttons. The spoiler section starts with an explanation of the message flow and message handlers. Final release 2014-05-10 Left, top, width and height parameters are added to the ExplorerWindowCreate() function. This makes it easier to position the Explorer window in the GUI. When the GUI is resized, the Explorer window is resized so that margins are retained. The margins can be used for buttons or other controls. The new parameters are implemented in the examples. Redundant code is moved from example files to common files. Some minor bug fixes. This is the final release of the small examples. It should not be too difficult to reuse the examples and code. I'm currently working on a large example where an address bar, a toolbar, a left pane and a status bar is implemented besides the right pane. This is a much bigger example, and it'll be more difficult to reuse the code. I'll probably add this example to a new thread. Final release, Vista update 2014-06-21 The Vista, 7, 8 example in first release dated 2013-11-28 was based on Vista code. The XP example was based on XP code. But most of the additional code in the next updates was XP code (see post 40). This meant that some functionality wasn't implemented completely under Vista and later. E.g. icon view modes. Examples The zip contains seven folders at the top level: 1. Basic example2. Position and size3. Navigation buttons4. Toolbar example5. Context menu6. Cut-copy-pasteExplorerThe first six folders are examples. The Explorer folder contains common files and includes. Resources specific for a particular example are contained in the example folder. There are three scripts for each example: Vista, 7, 8.au3, SysLv32.au3 and Windows XP.au3. Other examples (Vista and later) in posts below: Three examples where all panes are implemented (not just the right pane)You can find an example which implements the other panes in this post.This example shows how to merge all include files into a single Include folder.Implement proper tab order between LV and TV, and update LV on up/down keys in TV here.An example that shows how to cancel drag/drop operations can be found here. AutoIt 3.3.8 If you want to run the scripts on AutoIt 3.3.8 you need APIConstants.au3 and WinAPIEx.au3 by Yashied. The UDFs are not included in the zip. You must enable the UDFs in top of ShellFunctions.au3. The UDFs are already added, but commented out. And you must comment out the 3.3.10 UDFs in ShellFunctions.au3 and WERPFuncs.au3. Testet on XP 32 bit and Win 7 32/64 bit. The scripts can be run as both 32 and 64 bit programs. If you are running a 64 bit Windows you should run the scripts as 64 bit programs. Windows Explorer right pane.7z1 point -
Multiprocessing UDF that likes same name of module in Python
argumentum reacted to oceanwaves for a topic
We all know Autoit has no threading concept. And I searched the forums, some peoples have written multiple process framework, but they look not very popular. Python support threading, but Python also have a module, it names multiprocessing. According to Python PEP: Python's GIL causes only one threading can be run at same time (CPython interpreter). So Python provide multiprocessing module, it is real parallel running. So I decide to simulate the Python's module and import into Autoit. It also my first UDF in forums. In shortly, I write 4 UDFs, Multiprocessing.au3, SimpleQueue.au3, SimpleSemaphore.au3 and SimpleLock.au3. Multiprocessing.au3 provides method that let your function will run in another process rather than main process. SimpleQueue.au3 provides a queue (FIFO) that can be used in IPC. SimpleLock.au3 as its name, if you familiar threading concept. Limitation: Pass Autoit type data into other process or queue, I use JSMN.au3 to data serialization. According to JSMN, multiple dimensions array, COM object and Dll struct etc. You can check at '?do=embed' frameborder='0' data-embedContent>> The UDFs has added at main script head also must add at Multiprocessing.au3. Another attention is please place Multiprocessing.au3 to end of #include, then Multiprocessing.au3 can find your what UDF need to use. Detailed information in these UDFs: When you include a UDF in your script, actually the UDF will run before your main script running. So I just determine the current process is main process or not (according to CmdLine[]). If it is main process, it will do some prepare action, pass your function parameter into memory then call the same script or exe --------child process. When child process startup, the Multiprocessing.au3 also running first and get parameter from memory, then use Autoit function Call(). This UDF also provide some methods to manger child process, it used MS jobs object to manager them. You can see the information at http://msdn.microsoft.com/en-us/library/windows/desktop/ms684161%28v=vs.85%29.aspx But interesting for this, A include B, B can find function in A but can't find other UDFs that are referred by A, so must add these UDF at B head. In attention, interpreters for 3.3.10.2 and 3.3.11.4 are different. Perhaps Autoit develop team can explain it, For SimpleQueue.au3, just using file mapping concept of MS, it also used JSMN.au3 to data serialization. Support data are limited by JSMN.au3. The queue is stored in file mapping. Set up a specific size memory and a lock, then each process can access it without conflict. SimpleLock.au3 and SimpleSemaphore.au3 can get detail information at MSDN. At last, I hope Autoit has own data serialization UDF that can support multiple dimension array and other can’t be supported by current JSMN.au3. If you find any bug, please point out to me, I’ll do my best to fix it. Sorry for my poor English. -----------------------History---------------------------------------- 2014.5.21. Update Multiprocessing.au3 ---- add new function AllSubProcess_Close Update SimpleSemaphore.au3 ---- add function head for each function and rewrite some function, remove redundant virables. Upload SimpleSemaphore_testing.au3 example. The example shows it has 3 semaphores and 6 child process wants to connect to a sqlite database, but I limit in same time maximum connection is 3, so if one child process has not gotten a semaphore, it must be waiting unless other child process release a semaphore. When you run the example script, maybe must know some standard SQLite UDF, you can check it on the Autoit help file. Multiprocessing.zip Multiprocessing_testing.zip Multiprocessing.au3 SimpleSemaphore.au3 SimpleSemaphore_testing.au31 point -
Spotlight + Focus GUI's This is the latest experiment dealing with screen-dimming and focus. The spotlight effect works by dimming the entire screen except the small 'spotlight' area where the mouse is, so that you can focus on and read/work on that area with less eyestrain. Its a work in progress, however I've added some tweaks to it to make it a bit more interesting (and potentially useful!). In my experiments, the Spotlight and Focus GUI's are pretty nice when used in combination with RedShiftGUI (portable version here), an eyestrain-relieving color temperature shifter, or my >Windows Dimmer project. Also, a previous, separate, version of the Focus-GUI can be located within the Windows Dimmer zip file. Currently the spotlight + focus script has these features: Spotlight-GUI effect: A circular, rounded-square or rounded-rectangle area of the screen is set to 'full-brightness', while everything around it is dimmed. Locked-Spotlight GUI: Press CTRL+SHIFT+DOWN-ARROW when your have the spotlight area positioned, and it will remain locked in that position until released via the same key (or the Tray menu). Focus-GUI effect: The currently Active window is set to 'full-brightness', while everything around it is dimmed. Locked-Focus GUI: Press CTRL+SHIFT+SPACEBAR to keep the currently active window highlighted. Note this only keeps the rectangle visible, so any other windows overlapping the Focused GUI will have partial highlighting. Crosshair Mouse Cursor: All mouse cursors (save for resize-window cursors) are replaced with a simple crosshair. This provides a nice aesthetic compliment to the spotlight effect. (An optional diagonal X-hair is available, as well as no mouse icons at all - see source) Tweaks via the Tray that are persistent on NTFS systems (see below). Much more can be done here with tweaks - dimming percentages, focus-area sizes, etc Current control-focus following is not implemented: The Spotlight GUI only tracks mouse movement at the moment. Tracking the 'active' control focus (using mouse or keyboard) like Windows Magnifier does requires a bit more work; initial experiments indicate that GetGUIThreadInfo on 'Active' window can often make this possible but some apps don't report info correctly and need something like MSAA or UIAutomation (see >IUIAutomation MS framework by junkew). In the extreme, one can also hook the Mouse and Keyboard events but it still won't give the accurate keyboard focus information for different programs. Settings as adjusted in the tray will be persisted only on NTFS file systems. This can easily be changed, but its there to show one use of NTFS's Alternate Data Streams. The INI idea was inspired by nullscrhitt's '>Save INI data to exe. (while open)' thread. Also check out trancexx's '>Alternate Data Streams Viewer' if you'd like to see 'what lies beneath', or install a shell extension such as 'AltStreamOverlay' which lets you view it in the Windows properties dialog. For a list of ADS info on all files in a folder, check out AlternateStreamView @ Nirsoft. Things to note with this code: Certain windows will fight for topmost status. This is an annoying problem with Windows which there isn't any easy workaround. Its only temporary though; it will restore itself within another iteration of the Main loop. CTRL+SHIFT+DOWN-ARROW will toggle locking the Spotlight GUI in place. Also available in the Tray menu. CTRL+SHIFT+SPACEBAR will toggle locking the Focus GUI to a specific Window. Also available in the Tray menu. CTRL+ALT+Q will exit the program. 'Exit' in the Tray menu will do the same. Anyway, here's the codes! Changelog: #include <WinAPI.au3> #include <WinAPIGdi.au3> #include <WinAPISys.au3> ;#include <_MouseFunctions.au3> ; (Functions embedded) ; =============================================================================================================================== ; <WindowsSpotlightFocusGUI.au3> ; ; Spotlight/Focus GUI: Choose from 2 different styles of GUI 'focus': ; 1. 'Spotlight' GUI: Everything but a circular (or rounded-rect) 'hole' is dimmed, creating a spotlight effect on ; the screen where the mouse is focused. (created using a GUI 2x the size of the screen with a 'hole' Region) ; 2. 'Focus' GUI: Everything except the Active Window is dimmed. This is like a dynamically sized version of ; a 'Rect' Spotlight GUI which resizes/moves itself to the current Active window. ; ; Note the Spotlight GUI doesn't take into account keyboard focus, which would actually round out this script! ; ; To DO: ; - Make spotlight also follow keyboard focus when appropriate (when typing) ; ; To lock/unlock Spotlight GUI: ; - Ctrl+Shift+DOWN hotkey (Ctrl+Alt+Down won't work for some reason) ; To lock/unlock Focus GUI (to a specific window): ; - Ctrl+Shift+SPACE hotkey ; ; To Exit: ; - Use Tray menu or Ctrl+Alt+Q hotkey code ; ; Tweakables: ; - STYLE / COLOR / TRANSPARENCY Settings ; $nSpotlightStyle: 0 = Circle Spotlight, 1 = Rounded-Rect, 2 = Wide-Rect ; $nSpotlightDiameter: the size of the circular spotlight 'hole' surrounding the mouse (mouse is centered in this area) ; $nSpotlightSqDiameter: Rounded-rect width/height ; $nSpotlightRectWidth/Height: Wide-Rect width/height ; $nShadeColor: color of the 'shade' GUI. Seems anything grayscale works well (RGB: 0x000000, 0x111111, 0xFFFFFF) ; $n{..}Transparency: level of transparency. From 0-255, with 0 = invisible and 255 = solid (BAD!) ; $nRoundRectCornerWidth: Rounded-Rect corners' circle width/height ; ; NTFS ADS Info: ; "Alternate Data Streams Viewer" by trancexx ; @ http://www.autoitscript.com/forum/topic/149659-alternate-data-streams-viewer/ ; "Save INI data to exe. (while open)" by nullschritt ; @ http://www.autoitscript.com/forum/topic/155669-save-ini-data-to-exe-while-open/ ; ; See also: ; <WindowsDimlightShadedFocusGUI.au3> ; Basically the reverse of this - a dimmed circle GUI follows the mouse, ; ; creating a reverse-spotlight effect (or a dim-light affect if u will) ; Author: Ascend4nt ; =============================================================================================================================== ; Singleton code: Global Const $sSINGLETON_STRING = "Spotlight[0bc53fe0-59c2-11e2-bcfd-0800200c9a66]" If WinExists($sSINGLETON_STRING) Then Exit AutoItWinSetTitle($sSINGLETON_STRING) ; ==================================================================================================== ; STYLE / COLOR / TRANSPARENCY Settings ; ==================================================================================================== Global Const $nSpotlightStyle = 1 ; 0 = Circle, 1 = Rounded Rect, 2 = Wide Rect Global Const $nSpotlightDiameter = 500 Global Const $nSpotlightSqDiameter = 450 Global Const $nSpotlightRectWidth = 800, $nSpotlightRectHeight = 320 Global Const $nShadeColor = 0 Global Const $nSpotlightTransparency = 110, $nFocusTransparency = 110 Global Const $nRoundRectCornerWidth = 16 Global Const $nSpotlightXHairState = 0 ; 0 = No Spotlight-XHair, 1 = Full, 2 = Horizontal ( - ), 3 = Vertical ( | ) Global Const $nSpotlightXHairDiameter = 4 ; This is divided by 2 and the Spotlight X-Hair will be offset by this from center (use even #'s) Global Const $nSpotlightXHairYOffset = 0 ; 8-10 is nice for hovering under most lines of text ; Global Const $nSpotlightXHairXOffset = 0 ; ?? offseting X seems a bit odd and not very useful ; ==================================================================================================== ; GLOBAL VARIABLES ; ==================================================================================================== Global $g_bHKPressed = False Global $g_aINISettings = 0 Global $g_bFocusOn = 0, $g_bSpotlightOn = 1 Global $g_nSpotlightStyle = $nSpotlightStyle ; 0 = Circle, 1 = Rounded Rect, 2 = Wide Rect Global $g_nMouseCursorState = 1 ; -1 = Default Cursors, 0 = Hidden Cursors, 1 = CrossHair Cursor Global $g_aCursorStateSelect[3] ; Cursor State Tray ID's Global $g_nSpotlightXHairState = $nSpotlightXHairState ; 0 = No Spotlight-XHair, 1 = Full, 2 = Horizontal ( - ), 3 = Vertical ( | ) Global $g_aSpotlightXHairSelect[4] ; Spotlight-XHair State Tray ID's Global $g_hSpotlightGUI = 0, $g_hFocusGUI = 0, $g_nTransitions = 0, $g_nActiveGUICount = 0, $g_hLastActiveWin = 0 Global $g_aSpotLockDown[4] = [0, 0, 0, 0] ; Spotlight Lockdown: toggle, Center-X, Center-Y location, Tray ID # Global $g_ctFocusLock = 0, $g_hFocusLockDown = -1 Global $g_iResolutionChangeMsg = 0 ; This array will be updated with resolution changes, as well as some GUI rebuilds Global $g_aVScrRect[4] = [0, 0, @DesktopWidth, @DesktopHeight] Global $g_hGDI32DLL = DllOpen("gdi32.dll"), $g_hUSER32DLL = DllOpen("user32.dll") ; Global Vars quick-exit test If ($g_hGDI32DLL = -1 Or $g_hUSER32DLL = -1) Then Exit ; ############################################### #Region MOUSE_FUNCTIONS_PARTIAL_UDF_DATA ; Mouse-Replace Cursor handles (associative with Cursor ID's). See 'Standard Cursor IDs' in _MouseFunctions UDF Global $MCF_aSysCursors[16][2] = [ _ [32512, 0],[32513, 0],[32514, 0],[32515, 0],[32516, 0],[32640, 0],[32641, 0],[32647, 0],[32648, 0],[32649, 0],[32650, 0], _ [32642, 0],[32643, 0],[32644, 0],[32645, 0],[32646, 0]] ; Sizing cursors Global $MCF_bCursorsReplaced = False #EndRegion MOUSE_FUNCTIONS_PARTIAL_UDF_DATA ; ############################################### ; /**************************************************************************************************/ #Region MAIN_CODE _WinMain() Func _WinMain() ; Initialize Global Width/Height vars _VirtualScreenSizeUpdate() ;AutoItWinSetTitle("WindowSpotlightFocusGUI("&@AutoItPID&")") ; would cancel out or Singleton test ; Move the invisible window off-screen (mostly). This was mainly because in tests, the AutoIt invisible window ; would *actually* beomme the ACTIVE window. (Mainly when the tray icon is clicked and loses focus in some way) WinMove(AutoItWinGetTitle(), "", $g_aVScrRect[0]+$g_aVScrRect[2]-1, $g_aVScrRect[1]+$g_aVScrRect[3]-1) Opt("TrayAutoPause", 0) Opt("TrayOnEventMode", 1) Opt("TrayMenuMode", 1) ;+2) ; We want toggled and radio button automatic behavior Opt("GUIOnEventMode", 1) ; Logic check (before reading INI) If $g_nMouseCursorState And $g_nSpotlightXHairState Then $g_nMouseCursorState = 0 ; Restore INI data (and save on program exit) if this script is compiled ; (and the folder is writable) - uses NTFS ADS (Alternate Data Streams) If @Compiled Then _INI_UpdateDataFromExeINI() OnAutoItExitRegister("_INI_SaveDataToExeINI") EndIf ; #--------- TRAY MENU SETUP --------------# ;TraySetClick(9) ; 9 is Default (left or right mouse-click) TrayCreateItem("Rounded-Rect Spotlight", -1, -1, 1) TrayItemSetOnEvent(-1, "_RoundRectSpotlight_TEvt") If $g_nSpotlightStyle = 1 Then TrayItemSetState(-1, 1) TrayCreateItem("Wide-Rect Spotlight", -1, -1, 1) TrayItemSetOnEvent(-1, "_WideRectSpotlight_TEvt") If $g_nSpotlightStyle = 2 Then TrayItemSetState(-1, 1) TrayCreateItem("Circle Spotlight", -1, -1, 1) TrayItemSetOnEvent(-1, "_CircleSpotlight_TEvt") If $g_nSpotlightStyle = 0 Then TrayItemSetState(-1, 1) TrayCreateItem("") $g_aSpotlightXHairSelect[0] = TrayCreateItem("Spotlight Crosshair - NONE", -1, -1, 1) $g_aSpotlightXHairSelect[1] = TrayCreateItem("Spotlight Crosshair - FULL (+)", -1, -1, 1) $g_aSpotlightXHairSelect[2] = TrayCreateItem("Spotlight Crosshair - Horizontal (-)", -1, -1, 1) $g_aSpotlightXHairSelect[3] = TrayCreateItem("Spotlight Crosshair - Vertical ( | )", -1, -1, 1) TrayItemSetState($g_aSpotlightXHairSelect[$g_nSpotlightXHairState], 1) For $i = 0 To 3 TrayItemSetOnEvent($g_aSpotlightXHairSelect[$i], "_SpotlightXHairSelect_TEvt") Next TrayCreateItem("") $g_aSpotLockDown[3] = TrayCreateItem("Lock Spotlight Position (CTRL+SHIFT+DOWN)") TrayItemSetOnEvent(-1, "_LockUnlockSpotlight") If $g_aSpotLockDown[0] Then TrayItemSetState(-1, 1) $g_ctFocusLock = TrayCreateItem("Lock Focus GUI to Window (CTRL+SHIFT+SPACE)") TrayItemSetOnEvent(-1, "_LockUnlockFocus") ; Saving Focus Lockdown windows between runs is iffy, as we obviously can't save the HWND ; We CAN save Classname, Title (not wise as titles change), and Window Styles (also can change), ; but as there can be more than 1 window of a given Class, and Titles & Windows Styles can change ; it really doesn't make much sense ;If IsHWnd($g_hFocusLockDown) Then TrayItemSetState(-1, 1) TrayCreateItem("") $g_aCursorStateSelect[0] = TrayCreateItem("Mouse Cursor - Defaults", -1, -1, 1) $g_aCursorStateSelect[1] = TrayCreateItem("Mouse Cursor - Hidden", -1, -1, 1) $g_aCursorStateSelect[2] = TrayCreateItem("Mouse Cursor - CrossHair", -1, -1, 1) TrayItemSetState($g_aCursorStateSelect[$g_nMouseCursorState + 1], 1) For $i = 0 To 2 TrayItemSetOnEvent($g_aCursorStateSelect[$i], "_MouseCursorSelect_TEvt") Next TrayItemSetOnEvent(-1, "_MouseCursorSelect_TEvt") TrayCreateItem("") TrayCreateItem("Toggle Spotlight") TrayItemSetOnEvent(-1, "_ToggleSpotlight_TEvt") If $g_bSpotlightOn Then TrayItemSetState(-1, 1) TrayCreateItem("Toggle Window-Focus") TrayItemSetOnEvent(-1, "_ToggleFocus_TEvt") If $g_bFocusOn Then TrayItemSetState(-1, 1) TrayCreateItem("") TrayCreateItem("Exit") TrayItemSetOnEvent(-1, "_Exit_TEvt") TraySetState() TraySetToolTip("Windows Spotlight GUI (click for options)") ; #----------------- X ---------------------# ; CTRL-ALT-Q Exit Hotkey HotKeySet("!^q", "_HotKeyPressed") ; CTRL-SHIFT-DOWN Lock/Release Spotlight Hotkey HotKeySet("+^{DOWN}", "_LockUnlockSpotlight") ; CTRL-SHIFT-SPACE Lock/Release Focus-Window Hotkey HotKeySet("+^{SPACE}", "_LockUnlockFocus") ; ----------------------------------------------------------------------------------------------------| ; Register Display-Mode changes to our function. ; NOTE that a GUI (*any* GUI) MUST be created or else the WM_DISPLAYCHANGE message won't be received ; UPDATE: Can't do it this way - we need to know exactly how many GUI's area active ; (hence a global count and the _GUICountChange() function. ; ----------------------------------------------------------------------------------------------------| ;GUIRegisterMsg(0x007E, "_ResolutionChanged") ; WM_DISPLAYCHANGE 0x007E ; Update GUI Count and register Rez-Chg message if any active _GUICountChange() ; Cursor State ;~ If $g_nMouseCursorState < 0 Then ; Normal Cursors ;Else If $g_nMouseCursorState = 0 Then _MouseHideAllCursors() Else _MouseReplaceAllCursors(True) EndIf ; Setup mouse cursor restore function on exit (regarldess of setting): OnAutoItExitRegister("_MouseRestoreAllCursors") ; Not necessary, but can free some memory by flushing data to disk DllCall("psapi.dll", "bool", "EmptyWorkingSet", "handle", -1) Local $iRezChg = 0, $hTopMostWnd = 0 ; Main loop While 1 If $g_bHKPressed Then ExitLoop ; Exit on 'ESC' keypress (BitAND() test for down-state) ;If BitAND(_WinAPI_GetAsyncKeyState(0x1B), 0x8000) Then ExitLoop ; Reset RezChg Message to be sent $iRezChg = 0 ; Rez change? Update metrics if necessary amount of Rez-Change Messages received (1 per GUI) If $g_iResolutionChangeMsg And $g_iResolutionChangeMsg = $g_nActiveGUICount Then ConsoleWrite("Main Loop WM_DISPLAYCHANGE detected, $g_iResolutionChangeMsg = " & $g_iResolutionChangeMsg & @LF) _VirtualScreenSizeUpdate() $g_iResolutionChangeMsg = 0 $iRezChg = 1 EndIf ; Mouse/Keyboard-Cursor Spotlight GUI Active? ; *Note: Call this FIRST as it gets the current Mouse position* If $g_bSpotlightOn Then _SpotlightGUIUpdate($iRezChg) EndIf ; Window-Focus GUI active? If $g_bFocusOn Then _FocusGUIUpdate($iRezChg) EndIf ; Check the topmost status and reset our GUI's if necessary ; This was taken out of main Update loops, as there can be a bit of flashing when moving windows $hTopMostWnd = _WinAPI_GetTopWindow(0) If $g_hSpotlightGUI <> $hTopMostWnd And $g_hFocusGUI <> $hTopMostWnd Then ;ConsoleWrite("WinOnTop hWnd = " & $hTopMostWnd & ", Title = " & WinGetTitle($hTopMostWnd) & @LF) If $g_bSpotlightOn Then WinSetOnTop($g_hSpotlightGUI, "", 1) If $g_bFocusOn Then WinSetOnTop($g_hFocusGUI, "", 1) EndIf Sleep(20) WEnd ; Unregister Display Mode change function ;GUIRegisterMsg(0x007E, "") ; WM_DISPLAYCHANGE 0x007E ; And restore all system cursors back to normal (called automatically via OnAutoItExitRegister) ;_MouseRestoreAllCursors() EndFunc #EndRegion MAIN_CODE ; /**************************************************************************************************/ ; ############################################### #Region MISC_FUNCTIONS ; _GUICountChange() -> adjust counts and set/unset DisplayChange Messages Func _GUICountChange() Local $iTotalActiveGUIs = 0 ; Maximum 2 GUI's If $g_bFocusOn Then $iTotalActiveGUIs += 1 If $g_bSpotlightOn Then $iTotalActiveGUIs += 1 If $iTotalActiveGUIs = 0 Then ; Was there previously GUI's active? If $g_nActiveGUICount Then ; UnRegister Rez-Chg message GUIRegisterMsg(0x007E, "") ; WM_DISPLAYCHANGE 0x007E ConsoleWrite("0 GUI's active, WM_DISPLAYCHANGE unregistered" & @LF) EndIf Else ; Were no GUI's active previously? If $g_nActiveGUICount = 0 Then ; Register Rez-Chg message GUIRegisterMsg(0x007E, "_ResolutionChanged") ; WM_DISPLAYCHANGE 0x007E ConsoleWrite($iTotalActiveGUIs & " GUI's active, WM_DISPLAYCHANGE registered" & @LF) EndIf WinSetTrans($g_hFocusGUI, "", $g_bSpotlightOn ? ($nFocusTransparency / 2) : $nFocusTransparency) WinSetTrans($g_hSpotlightGUI, "", $g_bFocusOn ? ($nSpotlightTransparency / 2) : $nSpotlightTransparency) EndIf ; Update global count now that we've compared states $g_nActiveGUICount = $iTotalActiveGUIs EndFunc Func _VirtualScreenSizeUpdate() ; Set up VScreen Coords: 0, 1 = Upper Left X, Y (CAN be negative!!!), 2, 3 = Virtual Width, Height ; SM_XVIRTUALSCREEN = 76, SM_YVIRTUALSCREEN = 77, SM_CXVIRTUALSCREEN = 78, SM_CYVIRTUALSCREEN = 79 Dim $g_aVScrRect[4] = [_WinAPI_GetSystemMetrics(76), _WinAPI_GetSystemMetrics(77), _WinAPI_GetSystemMetrics(78), _WinAPI_GetSystemMetrics(79)] If $g_aVScrRect[2] = 0 Then $g_aVScrRect[2] = @DesktopWidth If $g_aVScrRect[3] = 0 Then $g_aVScrRect[3] = @DesktopHeight ConsoleWrite("VirtualScreen X: " & $g_aVScrRect[0] & ", Y: " & $g_aVScrRect[1] & ", Width = " & $g_aVScrRect[2] & ", Height = " & $g_aVScrRect[3] & @LF) ; Alternative Way to get Virtual Screen Width/Height: CreateDC with 'DISPLAY', GetDeviceCape(8) [HORZRES] and (10) [VERTRES], DeleteDC() EndFunc #EndRegion MISC_FUNCTIONS ; ############################################### ; ############################################### #Region HOTKEY_FUNCTIONS Func _HotKeyPressed() ; CTRL-ALT-Q Key Pressed: $g_bHKPressed = True EndFunc ;==>_HotKeyPressed Func _LockUnlockSpotlight() ; Off? Turn Lockdown on then If Not $g_aSpotLockDown[0] Then Local $aMousePos = MouseGetPos() $g_aSpotLockDown[1] = $aMousePos[0] $g_aSpotLockDown[2] = $aMousePos[1] TrayItemSetState($g_aSpotLockDown[3], 1) Else TrayItemSetState($g_aSpotLockDown[3], 4) EndIf $g_aSpotLockDown[0] = Not $g_aSpotLockDown[0] ;ConsoleWrite("Lock/Unlock Spotlight Hotkey Pressed (or Menu item selected)" & @LF) EndFunc Func _LockUnlockFocus() ; Off? Turn Lockdown on then If $g_hFocusLockDown <= 0 Then ; Set the active window even when Focus window isn't on If Not $g_bFocusOn Then $g_hLastActiveWin = WinGetHandle("[ACTIVE]") $g_hFocusLockDown = $g_hLastActiveWin TrayItemSetState($g_ctFocusLock, 1) Else $g_hFocusLockDown = -1 ;$g_hLastActiveWin = -1 TrayItemSetState($g_ctFocusLock, 4) EndIf ;ConsoleWrite("Lock/Unlock Focus GUI Hotkey pressed" & @LF) EndFunc #EndRegion HOTKEY_FUNCTIONS ; ############################################### ; ############################################### #Region WINDOWS_MESSAGE_HANDLER_FUNCTIONS ; ==================================================================================================== ; Func _ResolutionChanged($hWnd,$iMsg,$wParam,$lParam) ; ; Note this registers multiple-monitor settings changes too, but will only report on the primary monitor's resolution ; This is why we would need to call _WinAPI_GetSystemMetrics() to get the Virtual width/height ; ==================================================================================================== Func _ResolutionChanged($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam, $lParam ; Apparently under certain circumstances, we can receive more messages than GUI's!! If $g_iResolutionChangeMsg < $g_nActiveGUICount Then $g_iResolutionChangeMsg += 1 ;~ ConsoleWrite("_ResolutionChanged msg recieved, $g_iResolutionChangeMsg = " & $g_iResolutionChangeMsg & @LF) Return 'GUI_RUNDEFMSG' ; From <GUIConstantsEx.au3> Global Const $GUI_RUNDEFMSG = 'GUI_RUNDEFMSG' EndFunc ;==>_ResolutionChanged #EndRegion WINDOWS_MESSAGE_HANDLER_FUNCTIONS ; ############################################### ; ############################################### #Region TRAY_EVENT_HANDLER_FUNCS Func _RoundRectSpotlight_TEvt() If $g_nSpotlightStyle <> 1 Then $g_nSpotlightStyle = 1 If $g_bSpotlightOn Then _SpotlightGUIUpdate(1) EndIf EndFunc Func _WideRectSpotlight_TEvt() If $g_nSpotlightStyle <> 2 Then $g_nSpotlightStyle = 2 If $g_bSpotlightOn Then _SpotlightGUIUpdate(1) EndIf EndFunc Func _CircleSpotlight_TEvt() If $g_nSpotlightStyle Then $g_nSpotlightStyle = 0 If $g_bSpotlightOn Then _SpotlightGUIUpdate(1) EndIf EndFunc Func _MouseCursorSelect_TEvt() Switch @TRAY_ID Case $g_aCursorStateSelect[0] $g_nMouseCursorState = -1 _MouseRestoreAllCursors() Case $g_aCursorStateSelect[1] $g_nMouseCursorState = 0 _MouseHideAllCursors() Case $g_aCursorStateSelect[2] $g_nMouseCursorState = 1 _MouseReplaceAllCursors(True) EndSwitch ; This will remain in effect regardless of Mouse Cursor state (harmless): ;OnAutoItExitRegister("_MouseRestoreAllCursors") EndFunc Func _SpotlightXHairSelect_TEvt() Local $nPrevState = $g_nSpotlightXHairState Switch @TRAY_ID Case $g_aSpotlightXHairSelect[0] ; NO X-Hair Spotlight $g_nSpotlightXHairState = 0 Case $g_aSpotlightXHairSelect[1] ; FULL X-Hair Spotlight $g_nSpotlightXHairState = 1 Case $g_aSpotlightXHairSelect[2] ; Horizontal X-Hair Spotlight $g_nSpotlightXHairState = 2 Case $g_aSpotlightXHairSelect[3] ; Vertical X-Hair Spotlight $g_nSpotlightXHairState = 3 EndSwitch If $nPrevState <> $g_nSpotlightXHairState And $g_bSpotlightOn Then GUIDelete($g_hSpotlightGUI) ; Force re-initialization $g_hSpotlightGUI = 0 ; For the sake of sanity, adjust mouse cursors based on FULL/No X-Hair toggles ; If SpotlightXHairState is now disabled, and all Mouse Cursors are currently hidden, reenable at least the crosshair cursor If $g_nSpotlightXHairState = 0 And $g_nMouseCursorState = 0 Then ConsoleWrite("X-HAIR - MOUSE SANITY: Spotlight XHair Turned OFF, Mouse Cursors Hidden! ACTION: Enabling Crosshair cursors" & @LF) $g_nMouseCursorState = 1 _MouseReplaceAllCursors(True) TrayItemSetState($g_aCursorStateSelect[0], 4) TrayItemSetState($g_aCursorStateSelect[1], 4) TrayItemSetState($g_aCursorStateSelect[2], 1) ; If SpotlightXHairState is now fully enabled, and Mouse Cursors are currently the Crosshair cursor, choose to hide all cursors ElseIf $g_nSpotlightXHairState = 1 And $g_nMouseCursorState = 1 Then ConsoleWrite("X-HAIR - MOUSE SANITY: Spotlight XHair Turned FULLY ON, Mouse Cursors CrossHair is Active! ACTION: Disabling Crosshair cursors.. too presumptive?" & @LF) $g_nMouseCursorState = 0 _MouseHideAllCursors() TrayItemSetState($g_aCursorStateSelect[1], 1) TrayItemSetState($g_aCursorStateSelect[0], 4) TrayItemSetState($g_aCursorStateSelect[2], 4) EndIf _SpotlightGUIUpdate() EndIf EndFunc Func _ToggleSpotlight_TEvt() If $g_bSpotlightOn Then GUIDelete($g_hSpotlightGUI) ; Force re-initialization next time $g_hSpotlightGUI = 0 ; For the sake of sanity, adjust mouse cursors based on FULL/No X-Hair toggles ; If SpotlightXHairState was on, but now the GUI is disabled, and if all Mouse Cursors are currently hidden, reenable at least the crosshair cursor If $g_nSpotlightXHairState And $g_nMouseCursorState = 0 Then ConsoleWrite("X-HAIR - MOUSE SANITY: Spotlight GUI being turned OFF, Mouse Cursors Hidden! ACTION: Enabling Crosshair cursors" & @LF) $g_nMouseCursorState = 1 _MouseReplaceAllCursors(True) TrayItemSetState($g_aCursorStateSelect[0], 4) TrayItemSetState($g_aCursorStateSelect[1], 4) TrayItemSetState($g_aCursorStateSelect[2], 1) EndIf Else _SpotlightGUIUpdate() EndIf $g_bSpotlightOn = Not $g_bSpotlightOn ; Update GUI Counts, and Rez-Chg handler if necessary _GUICountChange() EndFunc Func _ToggleFocus_TEvt() If $g_bFocusOn Then GUIDelete($g_hFocusGUI) ; Force re-initialization next time $g_hFocusGUI = 0 ; Prevent sticky situations where transitions are confused with GUI re-init's $g_nTransitions = 0 Else _FocusGUIUpdate() EndIf $g_bFocusOn = Not $g_bFocusOn ; Update GUI Counts, and Rez-Chg handler if necessary _GUICountChange() EndFunc Func _Exit_TEvt() Exit EndFunc #EndRegion TRAY_EVENT_HANDLER_FUNCS ; ############################################### ; ############################################### #Region INI_IN_EXE_FUNCS ; ================================================================================================================= ; Func _INI_SaveDataToExeINI() ; ; Writes settings to NTFS ADS Stream INI file (NTFS file systems only) ; NOTE: Write access to folder is required (I think this type of write is the same as regular file access) ; ; Author: Ascend4nt, based nullschritt's 'Save INI data to exe' functions ; ================================================================================================================= Func _INI_SaveDataToExeINI() ;If 1 Then If @Compiled Then Local $sNTFS_ADS_File = @ScriptFullPath&':'&"INI_DATA" ;IniWrite($sNTFS_ADS_File, "Settings", "SpotlightStyle", $g_nSpotlightStyle) ; Build array (Number casts for True->1 and False->0 conversions) Local $aINISettingsOut[6][2] = [ [5, 0], _ ["FocusOn", Number($g_bFocusOn)], ["SpotlightOn", Number($g_bSpotlightOn)], ["SpotlightStyle", Number($g_nSpotlightStyle)], _ ["MouseCursorsState", Number($g_nMouseCursorState)], ["SpotlightXHairState", Number($g_nSpotlightXHairState)] ] ; Prevent unnecessary write by comparing IN settings vs OUT settings: Local $bSame = False ; Both arrays, both equal element counts? If IsArray($g_aINISettings) And $g_aINISettings[0][0] = $aINISettingsOut[0][0] Then Local $iMatches = 0 For $i = 1 To $aINISettingsOut[0][0] If $g_aINISettings[$i][0] = $aINISettingsOut[$i][0] And _ $g_aINISettings[$i][1] = $aINISettingsOut[$i][1] Then $iMatches += 1 Next If $iMatches = $aINISettingsOut[0][0] Then $bSame = True EndIf If Not $bSame Then ;ConsoleWrite("Determined settings have changed! Writing INI data.." & @CRLF) IniWriteSection($sNTFS_ADS_File, "Settings", $aINISettingsOut) EndIf EndIf EndFunc ; ================================================================================================================= ; Func _INI_UpdateDataFromExeINI() ; ; Reads settings from NTFS ADS Stream INI file (NTFS file systems only) ; ; Author: Ascend4nt, based nullschritt's 'Save INI data to exe' functions ; ================================================================================================================= Func _INI_UpdateDataFromExeINI() ;If 1 Then If @Compiled Then Local $sNTFS_ADS_File = @ScriptFullPath&':'&"INI_DATA" If FileExists($sNTFS_ADS_File) Then ;$g_nSpotlightStyle = IniRead($sNTFS_ADS_File, "Settings", "SpotlightStyle", 1) $g_aINISettings = IniReadSection($sNTFS_ADS_File, "Settings") If @error Or $g_aINISettings[0][0] < 5 Then $g_aINISettings = 0 Return Else ;ConsoleWrite("FocusOn Key = " & $g_aINISettings[1][0] & ", value = " & $g_aINISettings[1][1] & @LF) $g_bFocusOn = Number($g_aINISettings[1][1]) ;ConsoleWrite("Spotlight Key = " & $g_aINISettings[2][0] & ", value = " & $g_aINISettings[2][1] & @LF) $g_bSpotlightOn = Number($g_aINISettings[2][1]) $g_nSpotlightStyle = Abs(Number($g_aINISettings[3][1])) ; 0 = Circle, 1 = Rounded Rect, 2 = Wide Rect ; Sanity Check If $g_nSpotlightStyle > 2 Then $g_nSpotlightStyle = 2 $g_nMouseCursorState = Number($g_aINISettings[4][1]) ; Sanity Check If $g_nMouseCursorState < 0 Then $g_nMouseCursorState = -1 ElseIf $g_nMouseCursorState > 0 Then $g_nMouseCursorState = 1 EndIf $g_nSpotlightXHairState = Abs(Number($g_aINISettings[5][1])) ; Sanity Check If $g_nSpotlightXHairState > 3 Then $g_nSpotlightXHairState = 0 EndIf EndIf EndIf EndFunc #Region INI_IN_EXE_FUNCS ; ############################################### ; ############################################### #Region SPOTLIGHT_FUNCTIONS ; ================================================================================================================= ; Func _SpotlightGUIUpdate($bForceRecreate = False) ; ; Author: Ascend4nt ; ================================================================================================================= Func _SpotlightGUIUpdate($bForceRecreate = False) If Not $g_bSpotlightOn Then Return ; Keep all data local Local Static $aLastMousePos = 0, $aMousePos = 0 ; Need this Global so we can delete the GUI outside of function ;Local Static $hSpotlightGUI = 0 If $g_aSpotLockDown[0] Then $aMousePos[0] = $g_aSpotLockDown[1] $aMousePos[1] = $g_aSpotLockDown[2] Else $aMousePos = MouseGetPos() EndIf ; Initializing? Or Force-Recreate Flag set (possibly Resolution Change)? If $g_hSpotlightGUI = 0 Or $bForceRecreate Then ConsoleWrite("Recreating GUI, $g_hSpotlightGUI = " & $g_hSpotlightGUI & ", $bForceRecreate = " & $bForceRecreate & @LF) ;$aMousePos = MouseGetPos() $aLastMousePos = $aMousePos ; Extra precaution for corner cases where GUI's might activate after a Display Change while no WM_DISPLAYCHANGE handler was in effect _VirtualScreenSizeUpdate() _SpotlightGUIRecreate($aMousePos) ; If we rebuilt the GUI, no need to check for changes in position Else ; Movement? If $aMousePos[0] <> $aLastMousePos[0] Or $aMousePos[1] <> $aLastMousePos[1] Then ;ConsoleWrite("<>") WinMove($g_hSpotlightGUI, "", $aMousePos[0] - $g_aVScrRect[2] + 1, $aMousePos[1] - $g_aVScrRect[3] + 1) ; (Topmost check in main loop as there can be flashing with other GUI's fighting for topmost status) ;WinSetOnTop($g_hSpotlightGUI, "", 1) $aLastMousePos = $aMousePos #cs ;~ Else ; Otherwise lets check the topmost status and adjust if necessary ; (Logic moved to main loop as there can be flashing with other GUI's fighting for topmost status) ;~ Local $hWnd = _WinAPI_GetTopWindow(0) ;~ If $g_hSpotlightGUI <> $hWnd Then ;~ ;ConsoleWrite("WinOnTop hWnd = " & $hWnd & ", Title = " & WinGetTitle($hWnd) & @LF) ;~ WinSetOnTop($g_hSpotlightGUI, "", 1) ;~ EndIf #ce EndIf EndIf EndFunc ; ================================================================================================================= ; Func _SpotlightGUIRecreate($aMousePos) ; ; Author: Ascend4nt ; ================================================================================================================= Func _SpotlightGUIRecreate($aMousePos) If $g_hSpotlightGUI Then GUIDelete($g_hSpotlightGUI) Local $iWidth, $iHeight ; Spotlight Style 0 = Circle, 1 = Round-REct, 2 = Wide-Rect. [Hmm.. Wide Circle?] If $g_nSpotlightStyle Then If $g_nSpotlightStyle = 1 Then $iWidth = $nSpotlightSqDiameter $iHeight = $nSpotlightSqDiameter Else $iWidth = $nSpotlightRectWidth $iHeight = $nSpotlightRectHeight EndIf Else $iWidth = $nSpotlightDiameter $iHeight = $iWidth EndIf ; If even width/height, add 1 so that boxes align to mouse cursor ; ( width of 2 would result in 1 pixel on mouse position, 1 off. otherwise an odd # would mean 2 outside, 1 on) $iWidth += BitXOR(BitAND($iWidth, 1), 1) $iHeight += BitXOR(BitAND($iHeight, 1), 1) $g_hSpotlightGUI = _GUIShapeCreateHolePunchGUI($aMousePos[0] - $g_aVScrRect[2] + 1, $aMousePos[1] - $g_aVScrRect[3] + 1, _ $g_aVScrRect[2] * 2 +1, $iWidth, $g_aVScrRect[3] * 2 +1, $nShadeColor, $iHeight) WinSetTrans($g_hSpotlightGUI, "", $g_bFocusOn ? ($nSpotlightTransparency / 2) : $nSpotlightTransparency) ;xx nvm Careful: We don't want to compete with a Focus-Window GUI ;xx If Not $g_bFocusOn Then WinSetOnTop($g_hSpotlightGUI, "", 1) ;GUISetState(@SW_SHOWNOACTIVATE, $g_hSpotlightGUI) WinSetState($g_hSpotlightGUI, "", @SW_SHOWNOACTIVATE) Return EndFunc ;==>_SpotlightGUIRecreate ; ================================================================================================================= ; Func _GUIShapeCreateHolePunchGUI($iX, $iY, $iBoxSzX, $iHoleXDiameter, $iBoxSzY = Default, $iBkColor = Default, ; $iHoleYDiameter = Default) ; ; Author: Ascend4nt ; ================================================================================================================= Func _GUIShapeCreateHolePunchGUI($iX, $iY, $iBoxSzX, $iHoleXDiameter, $iBoxSzY = Default, $iBkColor = Default, $iHoleYDiameter = Default) Local $hGUI, $hRectRgn = 0, $hEllipseHollowRgn = 0, $hXLineRgn = 0, $iErrFlag = 0 If $iBoxSzY = Default Then $iBoxSzY = $iBoxSzX If $iHoleYDiameter = Default Then $iHoleYDiameter = $iHoleXDiameter If $iHoleXDiameter < 0 Or $iHoleXDiameter > $iBoxSzX Then $iHoleXDiameter = 0 If $iHoleYDiameter < 0 Or $iHoleYDiameter > $iBoxSzY Then $iHoleYDiameter = 0 ; Styles: Basic: WS_POPUP (0x80000000), Extended: WS_EX_NOACTIVATE 0x08000000. ; $WS_EX_TOOLWINDOW (0x80) + $WS_EX_TRANSPARENT (click-through) $hGUI = GUICreate("", $iBoxSzX, $iBoxSzY, $iX, $iY, 0x80000000, 0x08000080 + 0x20) If @error Then Return SetError(1, @error, 0) Do If $iHoleXDiameter Or $iHoleYDiameter Then Local $iHoleXRadius = Int($iHoleXDiameter / 2), $iHoleYRadius = Int($iHoleYDiameter / 2) Local $iBoxHalfX = Int($iBoxSzX / 2), $iBoxHalfY = Int($iBoxSzY / 2) $iErrFlag = 10 ; Basic region (full extent of GUI) - needed for combining with Hollow region below $hRectRgn = _WinAPI_CreateRectRgn(0, 0, $iBoxSzX, $iBoxSzY) If $hRectRgn = 0 Then ExitLoop ; Ellipse_Region Start ; Spotlight Style of 0 = Circle If $g_nSpotlightStyle = 0 Then ; Create the Hollow interior region $hEllipseHollowRgn = _WinAPI_CreateEllipticRgn( _ _WinAPI_CreateRect($iBoxHalfX - $iHoleXRadius, $iBoxHalfY - $iHoleYRadius, $iBoxHalfX + $iHoleXRadius, $iBoxHalfY + $iHoleYRadius)) ; Spotlight Style non-zero is RoundRect. Could do more.. perhaps a Complex Region is best in the end Else ; MSDN: "Regions created by the Create<shape>Rgn methods (such as CreateRectRgn and CreatePolygonRgn) ; only include the interior of the shape; the shape's outline is excluded from the region" ; In practice: The uppermost and leftmost lines are not included, so 1 must be subtracted from both params to include the full rectangle $hEllipseHollowRgn = _WinAPI_CreateRoundRectRgn($iBoxHalfX - $iHoleXRadius - 1, $iBoxHalfY - $iHoleYRadius - 1, _ $iBoxHalfX + $iHoleXRadius, $iBoxHalfY + $iHoleYRadius, $nRoundRectCornerWidth, $nRoundRectCornerWidth) EndIf $iErrFlag += 1 If $hEllipseHollowRgn = 0 Then ExitLoop ; Ellipse_Region END ; CrossHairs_Region Start If $g_nSpotlightXHairState Then Local $iArrSt = 0, $iArrEnd = 3 Local $iXHairHollowRadius = Int($nSpotlightXHairDiameter / 2) Local $aXHairSides[4][4] = [ _ ; Upper side of X-Hair ( | ) [$iBoxHalfX - 1, $iBoxHalfY - $iHoleYRadius, $iBoxHalfX + 1, $iBoxHalfY - $iXHairHollowRadius], _ ; ( o ) [$iBoxHalfX - 1, $iBoxHalfY + $iXHairHollowRadius, $iBoxHalfX + 1, $iBoxHalfY + $iHoleYRadius - 1], _ ; Bottom side of X-Hair ( | ) [$iBoxHalfX - $iHoleXRadius, $iBoxHalfY - 1 + $nSpotlightXHairYOffset, _ $iBoxHalfX - $iXHairHollowRadius, $iBoxHalfY + 1 + $nSpotlightXHairYOffset], _ ; Left side of X-Hair (--o ) [$iBoxHalfX + $iXHairHollowRadius, $iBoxHalfY - 1 + $nSpotlightXHairYOffset, _ $iBoxHalfX + $iHoleXRadius - 1, $iBoxHalfY + 1 + $nSpotlightXHairYOffset] ] ; Right side of X-Hair ( o--) ; One-dimensional XHairs.. (1 = FULL, 2 = Horizontal, 3 = Vertical) If $g_nSpotlightXHairState = 2 Then $iArrSt = 2 ; $iArrEnd = 3 ElseIf $g_nSpotlightXHairState = 3 Then $iArrEnd = 1 ; $iArrSt = 0 EndIf For $i = $iArrSt To $iArrEnd ; MSDN: "Regions created by the Create<shape>Rgn methods (such as CreateRectRgn and CreatePolygonRgn) ; only include the interior of the shape; the shape's outline is excluded from the region" ; In practice: The uppermost and leftmost lines are not included, so 1 must be subtracted from both params to include the full rectangle $hXLineRgn = _WinAPI_CreateRectRgn($aXHairSides[$i][0] - 1, $aXHairSides[$i][1] - 1, $aXHairSides[$i][2], $aXHairSides[$i][3]) $iErrFlag += 1 If $hXLineRgn = 0 Then ExitLoop ;ConsoleWrite("XHair Region #"&$i&" X1: " & $aXHairSides[$i][0] & ", Y1: " & $aXHairSides[$i][1] & ", X2: " & $aXHairSides[$i][2] & ", Y2: " & $aXHairSides[$i][3] & @LF) $iErrFlag += 1 ; With the Ellipse Region, we can use either RGN_XOR or RGN_DIFF as we are 'removing' parts of the circle ; (RGN_AND = 1, RGN_OR = 2, RGN_XOR = 3, RGN_DIFF = 4, RGN_COPY = 5) If Not _WinAPI_CombineRgn($hEllipseHollowRgn, $hEllipseHollowRgn, $hXLineRgn, 4) Then ExitLoop 2 ; Exit out of For..Next AND Do..Until loop ; CombineRgn() Returns: 0 = ERROR, 1 = NULLREGION, 2 = SIMPLEREGION, 3 = COMPLEXREGION ; Don't need this Region after combined with the $hEllipseHollowRgn _WinAPI_DeleteObject($hXLineRgn) $hXLineRgn = 0 ; Primarily debug, as DeleteObject prior to function return (on error) will ignore both Next EndIf ; CrossHairs_Region END $iErrFlag = 20 ; Combine, put resulting region in $hRectRgn. RGN_DIFF = 4 If Not _WinAPI_CombineRgn($hRectRgn, $hRectRgn, $hEllipseHollowRgn, 4) Then ExitLoop ; Don't need this anymore (already combined with the Region injected into the GUI) _WinAPI_DeleteObject($hEllipseHollowRgn) $hEllipseHollowRgn = 0 ; Primarily debug, as DeleteObject prior to function return (on error) will ignore both $iErrFlag += 1 ; Set the region into the GUI. (GUI will then own it so there's no need to delete it) If Not _WinAPI_SetWindowRgn($hGUI, $hRectRgn, True) Then ExitLoop EndIf If $iBkColor <> Default Then GUISetBkColor($iBkColor) Return $hGUI ; If we wer to drop through, we'd need a clear ErrFlag count: ;$iErrFlag = 0 Until 1 ; Cleanup GUIDelete($hGUI) _WinAPI_DeleteObject($hRectRgn) _WinAPI_DeleteObject($hXLineRgn) _WinAPI_DeleteObject($hEllipseHollowRgn) Return SetError($iErrFlag, 0, 0) EndFunc ;==>_GUIShapeCreateHolePunchGUI #EndRegion SPOTLIGHT_FUNCTIONS ; ############################################### ; ############################################### #Region FOCUS_GUI_FUNCTIONS ; ================================================================================================================= ; Func _FocusGUIUpdate($iRezChgForce = 0) ; ; Author: Ascend4nt ; ================================================================================================================= Func _FocusGUIUpdate($iRezChgForce = 0) If Not $g_bFocusOn Then Return Local Const $TRANSITION_MAX = 100 ; Keep as much data local as possible (turning out to be tricky now!) Local Static $aLastWinPos = 0 ; Need this Global so that Lockdown can be used ; Local Static $hLastActiveWin = 0 ; Need this Global so it can be reset when GUI is deleted: ;Local Static $nTransitions = 0 ; Need this Global so we can delete it outside of this function ;Local Static $hFocusGUI = 0 Local $aActiveWinPos = 0, $hActiveWin = 0 Local $hTempGUIHandle = 0 ; Max-Transitions Exceeded? We don't want to continually eat up Windows RAM with Window Regions, ; so now and then we must purge the GUI and create a new one. This creates a temporary darkening effect now and then. ; (There's no known workaround for the Region bug - previous ones should be freed with each 'SetWindowRgn', but they aren't) If $g_nTransitions > $TRANSITION_MAX Then $g_nTransitions = $TRANSITION_MAX ; safety measure (issue with recreation & $nTransitions colliding) $hTempGUIHandle = $g_hFocusGUI $g_hFocusGUI = 0 EndIf ; Initializing? If $g_hFocusGUI = 0 Then ; Extra precaution for corner cases where GUI's might activate after a Display Change while no WM_DISPLAYCHANGE handler was in effect _VirtualScreenSizeUpdate() ; ----------------------------------------------------------------------------------------------------| ; Focus Window: Set off-screen 1st so when it finally is moved on-screen, it gives a nicer effect, ; as if lights are being shut off 1 by 1. ; ----------------------------------------------------------------------------------------------------| $g_hFocusGUI = GUICreate("", $g_aVScrRect[2], $g_aVScrRect[3], $g_aVScrRect[0] + $g_aVScrRect[2]-1, $g_aVScrRect[1] + $g_aVScrRect[3]-1, 0x80000000,0x08000080 + 0x20) WinSetTrans($g_hFocusGUI, "", $g_bSpotlightOn ? ($nFocusTransparency / 2): $nFocusTransparency) WinSetOnTop($g_hFocusGUI, "", 1) GUISetBkColor(0) $g_hLastActiveWin = WinGetHandle("[ACTIVE]") $hActiveWin = $g_hLastActiveWin $aActiveWinPos = WinGetPos($hActiveWin) $aLastWinPos = $aActiveWinPos ; Move focus-window's 'hole' to/with active window _GuiHole($g_hFocusGUI, $aActiveWinPos[0] - $g_aVScrRect[0], $aActiveWinPos[1] - $g_aVScrRect[1], $aActiveWinPos[2], $aActiveWinPos[3]) ; Now move and show it (this move AFTER the gui 'hole' has been set causes less disruption) WinMove($g_hFocusGUI, "", $g_aVScrRect[0], $g_aVScrRect[1]) WinSetState($g_hFocusGUI, "", @SW_SHOWNOACTIVATE) If $g_nTransitions = $TRANSITION_MAX Then ConsoleWrite("Transition count exceeded, recreating GUI.." & @LF) GUIDelete($hTempGUIHandle) EndIf ; Reset in both cases $g_nTransitions = 0 ; Don't fall-through Return EndIf ; Adjust if screen resized ;If $g_iResolutionChangeMsg Or $iRezChgForce Then If $iRezChgForce Then ConsoleWrite("Resolution changed, resizing window"&@LF) WinMove($g_hFocusGUI, "", $g_aVScrRect[0], $g_aVScrRect[1], $g_aVScrRect[2], $g_aVScrRect[3]) ;WinMove($g_hFocusGUI, "", Default, Default, $g_aVScrRect[0] + $g_aVScrRect[2], $g_aVScrRect[1] + $g_aVScrRect[3]) ; Force _GuiHole call (down below) $g_hLastActiveWin = -1 ;$g_iResolutionChangeMsg = 0 ; old behavior EndIf ; Active Window changing? (Lockdown skips this test, unless the Window no longer exists) If $g_hFocusLockDown <= 0 Or Not WinExists($g_hFocusLockDown) Then $hActiveWin = WinGetHandle("[ACTIVE]") Else $hActiveWin = $g_hFocusLockDown EndIf $aActiveWinPos = WinGetPos($hActiveWin) ; Workaround for certain scenarios where position isn't able to be retrieved If @error Then $aActiveWinPos = $aLastWinPos $hActiveWin = $g_hLastActiveWin ; Different active window, or different size/position? ElseIf ($hActiveWin <> $g_hLastActiveWin) Or ($aActiveWinPos[0] <> $aLastWinPos[0] Or $aActiveWinPos[1] <> $aLastWinPos[1] Or _ $aActiveWinPos[2] <> $aLastWinPos[2] Or $aActiveWinPos[3] <> $aLastWinPos[3]) Then ;ConsoleWrite("New active window or position: Win:"&WinGetTitle($hActiveWin)&@CRLF) $g_nTransitions += 1 ;_GuiHole($g_hFocusGUI, $aActiveWinPos[0], $aActiveWinPos[1], $aActiveWinPos[2], $aActiveWinPos[3]) _GuiHole($g_hFocusGUI, $aActiveWinPos[0] - $g_aVScrRect[0], $aActiveWinPos[1] - $g_aVScrRect[1], $aActiveWinPos[2], $aActiveWinPos[3]) ; Reset as Topmost GUI (Logic taken to main loop; otherwise causes flashing when competing for topmost GUI) ;WinSetOnTop($g_hFocusGUI, "", 1) $g_hLastActiveWin = $hActiveWin $aLastWinPos = $aActiveWinPos EndIf EndFunc ; =============================================================================================================================== ; Func _GuiHole($h_win, $i_x, $i_y, $i_sizew, $i_sizeh) ; ; Places an empty 'see-through' region inside a GUI, hence 'gui hole' ; ; Author: KaFu, Ascend4nt (error handling, cleanup, API call fixes) ; =============================================================================================================================== Func _GuiHole($h_win, $i_x, $i_y, $i_sizew, $i_sizeh) Local $pos, $set_rgn, $inner_rgn $pos = WinGetPos($h_win) If @error Then Return SetError(1,@error,0) $set_rgn = DllCall($g_hGDI32DLL, "handle", "CreateRectRgn", "long", 0, "long", 0, "long", $pos[2], "long", $pos[3]) If @error Then Return SetError(2,@error,0) $inner_rgn = DllCall($g_hGDI32DLL, "handle", "CreateRectRgn", "long", $i_x, "long", $i_y, "long", $i_x + $i_sizew, "long", $i_y + $i_sizeh) If @error Then DllCall($g_hGDI32DLL, "bool", "DeleteObject", "handle", $set_rgn[0]) Return SetError(2, @error, 0) EndIf ; Unnecessary: ;~ $combined_rgn = DllCall($g_hGDI32DLL, "handle", "CreateRectRgn", "long", 0, "long", 0, "long", 0, "long", 0) ; $RGN_DIFF = 4 DllCall($g_hGDI32DLL, "long", "CombineRgn", "handle", $set_rgn[0], "handle", $set_rgn[0], "handle", $inner_rgn[0], "int", 4) ; Inner Region no longer required once combined with another region DllCall($g_hGDI32DLL, "bool", "DeleteObject", "handle", $inner_rgn[0]) ; After Set, a Region should not be deleted (so we don't touch $set_rgn after) DllCall($g_hUSER32DLL, "long", "SetWindowRgn", "hwnd", $h_win, "handle", $set_rgn[0], "bool", 1) Return 1 EndFunc ;==>_GuiHole #EndRegion FOCUS_GUI_FUNCTIONS ; ############################################### ; ############################################### #Region MOUSE_FUNCTIONS_PARTIAL_UDF ; ==================================================================================================== ; Func _MouseReplaceAllCursors($bDontReplaceResizeCursors = False) ; ; Replaces all cursors with a crosshair cursor (or X style cursor). ; ; ; AND mask XOR mask Display ; --------|-----------|--------- ; 0 0 Black ; 0 1 White ; 1 0 Screen ; 1 1 Reverse screen ; --------|-----------|--------- ; ; Author: Ascend4nt ; ==================================================================================================== Func _MouseReplaceAllCursors($bDontReplaceResizeCursors = False, $bUseXHairCross = True) If $MCF_bCursorsReplaced = 1 Then Return True ; Had a different type of Cursor Replacement? Restore first! If $MCF_bCursorsReplaced Then _MouseRestoreAllCursors() Local $i, $iErrCount = 0, $hCrossHair, $hTempCopy, $stCursor, $aRet Local $iCursorsToReplace = UBound($MCF_aSysCursors) - 1 If $bDontReplaceResizeCursors Then $iCursorsToReplace -= 5 EndIf ; Lets make a 32x32 cursor [1bpp] (32/8=4*32=128) $stCursor = DllStructCreate("ubyte[128];ubyte[128]") ; 32x32 cursor - each bit corresponds to a pixel (4 pixels per hex #) DllStructSetData($stCursor, 1, "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF") If $bUseXHairCross Then ; each bit corresponds to a pixel (4 pixels per hex #) (the rest we'll leave zeroed) DllStructSetData($stCursor, 2, "0x" & _ "01000000" & _ "01000000" & _ "01000000" & _ "01000000" & _ "01000000" & _ "01000000" & _ "01000000" & _ "FEFE0000" & _ ; Line 8 = horizonal line; center bit cleared (same bit set for other rows) "01000000" & _ "01000000" & _ "01000000" & _ "01000000" & _ "01000000" & _ "01000000" & _ "01000000" & _ "00000000") ; Center pixel (7,7 for 15x15 [or 16x16 officially]) $hCrossHair = DllCall($g_hUSER32DLL, "handle", "CreateCursor", "handle", 0, "int", 7, "int", 7, "int", 32, "int", 32, _ "ptr", DllStructGetPtr($stCursor, 1), "ptr", DllStructGetPtr($stCursor, 2)) Else ; $bXHairDiagonal DllStructSetData($stCursor, 2, "0x" & _ "00000000" & _ ; "01000400" & .. ; to make 15x15 "00000000" & _ ; "00800800" & .. ; to make 13x13 "00401000" & _ ; 11x11 "00202000" & _ "00104000" & _ "00088000" & _ "00050000" & _ "00000000" & _ ; Line 8 = center point; center bit cleared "00050000" & _ "00088000" & _ "00104000" & _ "00202000" & _ "00401000" & _ "00000000" & _ ; "00800800" & .. "00000000" & _ ; "01000400" & .. "00000000") $hCrossHair = DllCall($g_hUSER32DLL, "handle", "CreateCursor", "handle", 0, "int", 14, "int", 7, "int", 32, "int", 32, _ "ptr", DllStructGetPtr($stCursor, 1), "ptr", DllStructGetPtr($stCursor, 2)) EndIf If @error Then Return SetError(2, @error, False) If Not $hCrossHair[0] Then Return SetError(3, 0, 0) $hCrossHair = $hCrossHair[0] ;~ ConsoleWrite("cursor:"&$hCrossHair&@CRLF) ; Make copy, one for each cursor to be replaced [don't ask me why I can't reuse one - it just doesn't work] ; (REQUIRED for SetSystemCursor calls) ; (*CopyCursor is a macro for CopyIcon) For $i = 0 To $iCursorsToReplace $hTempCopy = DllCall($g_hUSER32DLL, "handle", "CopyIcon", "handle", $hCrossHair) If @error Or Not $hTempCopy[0] Then $iErrCount += 1 ContinueLoop EndIf $MCF_aSysCursors[$i][1] = $hTempCopy[0] ; Replace with copy of crosshair $aRet = DllCall($g_hUSER32DLL, "bool", "SetSystemCursor", "handle", $hTempCopy[0], "dword", $MCF_aSysCursors[$i][0]) If @error Or Not $aRet[0] Then $iErrCount += 1 ;~ ConsoleWrite("@error="&@error&" for SetSystemCursor"&@CRLF) EndIf ;~ ConsoleWrite("Return for #"&$i&":"&$aRet[0]&", ID:"&$MCF_aSysCursors[$i][0]&" Handle:"&$MCF_aSysCursors[$i][1]&" Msg:"&_WinAPI_GetLastErrorMessage()) Next ; Destroy cursor created (and copied) DllCall($g_hUSER32DLL, "bool", "DestroyCursor", "handle", $hCrossHair) If $iErrCount = 16 Then Return SetError(4, -1, False) ;~ ConsoleWrite("Total Errors:"&$iErrCount&" for _MouseReplaceAllCursors"&@CRLF) $MCF_bCursorsReplaced = 1 EndFunc ;==>_MouseReplaceAllCursors ; ==================================================================================================== ; Func _MouseHideAllCursors($bDontReplaceResizeCursors = False) ; ; Hides all cursors. ; ; Author: Ascend4nt ; ==================================================================================================== Func _MouseHideAllCursors($bDontReplaceResizeCursors = False) If $MCF_bCursorsReplaced = -1 Then Return True ; Had a different type of Cursor Replacement? Restore first! If $MCF_bCursorsReplaced Then _MouseRestoreAllCursors() Local $i, $iErrCount = 0, $hTempCopy, $aRet, $stCursor, $hCursor Local $iCursorsToReplace = UBound($MCF_aSysCursors) - 1 If $bDontReplaceResizeCursors Then $iCursorsToReplace -= 5 EndIf $stCursor = DllStructCreate("ubyte[128];ubyte[128]") ; Create an invisible cursor -> 32x32 (8x8 works but gives artifacts when manipulating items with mouse) DllStructSetData($stCursor, 1, "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF") DllStructSetData($stCursor, 2, 0) $hCursor = DllCall($g_hUSER32DLL, "handle", "CreateCursor", "handle", 0, "int", 0, "int", 0, "int", 32, "int", 32, "ptr", DllStructGetPtr($stCursor, 1), "ptr", DllStructGetPtr($stCursor, 2)) If @error Then Return SetError(2, @error, False) ;ConsoleWrite("hCursor result:" & $hCursor[0] & @CRLF) If Not $hCursor[0] Then Return SetError(3, 0, 0) ;ConsoleWrite("hCursor result:" & $hCursor[0] & @CRLF) $hCursor = $hCursor[0] ;~ ConsoleWrite("cursor:"&$hCursor&@CRLF) ; Make copy, one for each icon to be replaced [don't ask me why I can't reuse one - it just doesn't work] ; (REQUIRED for SetSystemCursor calls) (*CopyCursor is a macro for CopyIcon) For $i = 0 To $iCursorsToReplace $hTempCopy = DllCall($g_hUSER32DLL, "handle", "CopyIcon", "handle", $hCursor) If @error Or Not $hTempCopy[0] Then $iErrCount += 1 ContinueLoop EndIf $MCF_aSysCursors[$i][1] = $hTempCopy[0] ; Replace with copy of 'invisible cursor' $aRet = DllCall($g_hUSER32DLL, "bool", "SetSystemCursor", "handle", $hTempCopy[0], "dword", $MCF_aSysCursors[$i][0]) If @error Or Not $aRet[0] Then $iErrCount += 1 ;~ If Not @error Then ConsoleWrite("Return for #"&$i&":"&$aRet[0]&", ID:"&$MCF_aSysCursors[$i][0]&" Handle:"&$MCF_aSysCursors[$i][1]&" Msg:"&_WinAPI_GetLastErrorMessage()) Next ; Destroy cursor created (and copied) DllCall($g_hUSER32DLL, "bool", "DestroyCursor", "handle", $hCursor) If $iErrCount = 16 Then Return SetError(2, -1, False) ;~ ConsoleWrite("Total Errors:"&$iErrCount&" for _MouseHideAllCursors"&@CRLF) $MCF_bCursorsReplaced = -1 EndFunc ;==>_MouseHideAllCursors ; ==================================================================================================== ; Func _MouseRestoreAllCursors() ; ; Restores all the current default system cursors. ; ; Author: Ascend4nt ; ==================================================================================================== Func _MouseRestoreAllCursors() If Not $MCF_bCursorsReplaced Then Return True Local $i, $iErrCount = 0, $aRet ; SPI_SETCURSORS 0x0057 ; Restores system default cursors $aRet = DllCall($g_hUSER32DLL, "bool", "SystemParametersInfoW", "dword", 0x57, "dword", 0, "ptr", 0, "dword", 0) For $i = 0 To UBound($MCF_aSysCursors) - 1 ; Destroy copy $aRet = DllCall($g_hUSER32DLL, "bool", "DestroyCursor", "handle", $MCF_aSysCursors[$i][1]) If @error Or Not $aRet[0] Then $iErrCount += 1 ContinueLoop EndIf $MCF_aSysCursors[$i][1] = 0 Next If $iErrCount = 16 Then Return SetError(4, -1, False) ;~ ConsoleWrite("Total Errors:"&$iErrCount&" for _MouseRestoreAllCursors"&@CRLF) $MCF_bCursorsReplaced = 0 EndFunc ;==>_MouseRestoreAllCursors #EndRegion MOUSE_FUNCTIONS_PARTIAL_UDF ; ############################################### WindowsSpotlightFocusGUI.au3 ~prev downloads: 44 WindowsSpotlightFocusGUI.au31 point
-
This is an example with the Shell Link object: #include <WinAPI.au3> Global Const $CLSID_ShellLink = "{00021401-0000-0000-C000-000000000046}" Global Const $sIID_IShellLinkW = "{000214F9-0000-0000-C000-000000000046}" Global Const $dtag_IShellLinkW = _ "GetPath hresult();" & _ "GetIDList hresult();" & _ "SetIDList hresult();" & _ "GetDescription hresult();" & _ "SetDescription hresult();" & _ "GetWorkingDirectory hresult();" & _ "SetWorkingDirectory hresult();" & _ "GetArguments hresult();" & _ "SetArguments hresult();" & _ "GetHotkey hresult();" & _ "SetHotkey hresult();" & _ "GetShowCmd hresult();" & _ "SetShowCmd hresult();" & _ "GetIconLocation hresult();" & _ "SetIconLocation hresult();" & _ "SetRelativePath hresult();" & _ "Resolve hresult();" & _ "SetPath hresult();" Global Const $dtag_IPersist = _ "GetClassID hresult();" Global Const $sIID_IPersistFile = "{0000010b-0000-0000-C000-000000000046}" Global Const $tRIID_IPersistFile = _WinAPI_GUIDFromString( $sIID_IPersistFile ) Global Const $dtag_IPersistFile = $dtag_IPersist & _ ; Inherits from IPersist "IsDirty hresult();" & _ "Load hresult();" & _ "Save hresult();" & _ "SaveCompleted hresult();" & _ "GetCurFile hresult();" Opt( "MustDeclareVars", 1 ) MainFunc() Func MainFunc() Local $oIShellLinkW = ObjCreateInterface( $CLSID_ShellLink , $sIID_IShellLinkW, $dtag_IShellLinkW ) If Not IsObj( $oIShellLinkW ) Then Return ConsoleWrite( "$oIShellLinkW ERR" & @CRLF ) ConsoleWrite( "$oIShellLinkW OK" & @CRLF ) Local $pIPersistFile, $oIPersistFile $oIShellLinkW.QueryInterface( $tRIID_IPersistFile, $pIPersistFile ) $oIPersistFile = ObjCreateInterface( $pIPersistFile, $sIID_IPersistFile, $dtag_IPersistFile ) If Not IsObj( $oIPersistFile ) Then Return ConsoleWrite( "$oIPersistFile ERR" & @CRLF ) ConsoleWrite( "$oIPersistFile OK" & @CRLF ) EndFunc As you can see, the interface description strings are incomplete.1 point
-
Modify registry key
obfuscatedv reacted to JLogan3o13 for a topic
Taken almost word for word from the example under RegEnumKey... $path = "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\ABC\" For $i = 1 To 100 $sSubKey = RegEnumKey($path, $i) If @error Then ExitLoop Else $var = RegRead($path & $sSubKey, "VALNAME") If Not @error Then MsgBox(0, $path & $sSubKey, $var) EndIf Next1 point -
Try this modified version. GraphGDIPlus.au3: ;#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 ; #INDEX# =============================================================================== ; Title .........: GraphGDIPlus ; AutoIt Version: 3.3.0.0+ ; Language: English ; Description ...: A Graph control to draw line graphs, using GDI+, also double-buffered. ; Notes .........: ; ======================================================================================= ; #VARIABLES/INCLUDES# ================================================================== #include-once #include <GDIplus.au3> Global $aGraphGDIPlusaGraphArrayINTERNAL[1] ; ======================================================================================= ; #FUNCTION# ============================================================================ ; Name...........: _GraphGDIPlus_Create ; Description ...: Creates graph area, and prepares array of specified data ; Syntax.........: _GraphGDIPlus_Create($hWnd,$iLeft,$iTop,$iWidth,$iHeight,$hColorBorder = 0xFF000000,$hColorFill = 0xFFFFFFFF) ; Parameters ....: $hWnd - Handle to GUI ; $iLeft - left most position in GUI ; $iTop - top most position in GUI ; $iWidth - width of graph in pixels ; $iHeight - height of graph in pixels ; $hColorBorder - Color of graph border (ARGB) ; $hColorFill - Color of background (ARGB) ; Return values .: Returns array containing variables for subsequent functions... ; Returned Graph array is: ; [1] graphic control handle ; [2] left ; [3] top ; [4] width ; [5] height ; [6] x low ; [7] x high ; [8] y low ; [9] y high ; [10] x ticks handles ; [11] x labels handles ; [12] y ticks handles ; [13] y labels handles ; [14] Border Color ; [15] Fill Color ; [16] Bitmap Handle ; [17] Backbuffer Handle ; [18] Last used x pos ; [19] Last used y pos ; [20] Pen (main) Handle ; [21] Brush (fill) Handle ; [22] Pen (border) Handle ; [23] Pen (grid) Handle ; [24] Window Handle (hWnd) ; ======================================================================================= Func _GraphGDIPlus_Create($hWnd, $iLeft, $iTop, $iWidth, $iHeight, $hColorBorder = 0xFF000000, $hColorFill = 0xFFFFFFFF, $iSmooth = 2) Local $graphics, $bitmap, $backbuffer, $brush, $bpen, $gpen, $pen Local $ahTicksLabelsX[1] Local $ahTicksLabelsY[1] Local $ahTicksX[1] Local $ahTicksY[1] Local $aGraphArray[1] ;----- Set GUI transparency to SOLID (prevents GDI+ glitches) ----- ;WinSetTrans($hWnd, "", 255) - causes problems when more than 2 graphs used ;----- GDI+ Initiate ----- _GDIPlus_Startup() $graphics = _GDIPlus_GraphicsCreateFromHWND($hWnd) ;graphics area $bitmap = _GDIPlus_BitmapCreateFromGraphics($iWidth + 1, $iHeight + 1, $graphics);buffer bitmap $backbuffer = _GDIPlus_ImageGetGraphicsContext($bitmap) ;buffer area _GDIPlus_GraphicsSetSmoothingMode($backbuffer, $iSmooth) ;----- Set background Color ----- $brush = _GDIPlus_BrushCreateSolid($hColorFill) _GDIPlus_GraphicsFillRect($backbuffer, 0, 0, $iWidth, $iHeight, $brush) ;----- Set border Pen + color ----- $bpen = _GDIPlus_PenCreate($hColorBorder) _GDIPlus_PenSetEndCap($bpen, $GDIP_LINECAPROUND) ;----- Set Grid Pen + color ----- $gpen = _GDIPlus_PenCreate(0xFFf0f0f0) _GDIPlus_PenSetEndCap($gpen, $GDIP_LINECAPROUND) ;----- set Drawing Pen + Color ----- $pen = _GDIPlus_PenCreate() ;drawing pen initially black, user to set _GDIPlus_PenSetEndCap($pen, $GDIP_LINECAPROUND) _GDIPlus_GraphicsDrawRect($backbuffer, 0, 0, $iWidth, $iHeight, $pen) ;----- draw ----- _GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, $iLeft, $iTop, $iWidth + 1, $iHeight + 1) ;----- register redraw ----- GUIRegisterMsg(0x0006, "_GraphGDIPlus_ReDraw") ;0x0006 = win activate GUIRegisterMsg(0x0003, "_GraphGDIPlus_ReDraw") ;0x0003 = win move ;----- prep + load array ----- Dim $aGraphArray[25] = ["", $graphics, $iLeft, $iTop, $iWidth, $iHeight, 0, 1, 0, 1, _ $ahTicksX, $ahTicksLabelsX, $ahTicksY, $ahTicksLabelsY, $hColorBorder, $hColorFill, _ $bitmap, $backbuffer, 0, 0, $pen, $brush, $bpen, $gpen, $hWnd] ;----- prep re-draw array for all graphs created ----- ReDim $aGraphGDIPlusaGraphArrayINTERNAL[UBound($aGraphGDIPlusaGraphArrayINTERNAL) + 1] $aGraphGDIPlusaGraphArrayINTERNAL[UBound($aGraphGDIPlusaGraphArrayINTERNAL) - 1] = $aGraphArray Return $aGraphArray EndFunc ;==>_GraphGDIPlus_Create Func _GraphGDIPlus_ReDraw($hWnd) ;----- Allows redraw of the GDI+ Image upon window min/maximize ----- Local $i _WinAPI_RedrawWindow($hWnd, 0, 0, 0x0100) For $i = 1 To UBound($aGraphGDIPlusaGraphArrayINTERNAL) - 1 If $aGraphGDIPlusaGraphArrayINTERNAL[$i] = 0 Then ContinueLoop _GraphGDIPlus_Refresh($aGraphGDIPlusaGraphArrayINTERNAL[$i]) Next EndFunc ;==>_GraphGDIPlus_ReDraw ; #FUNCTION# ============================================================================ ; Name...........: _GraphGDIPlus_Delete ; Description ...: Deletes previously created graph and related ticks/labels ; Syntax.........: _GraphGDIPlus_Delete($hWnd,ByRef $aGraphArray) ; Parameters ....: $hWnd - GUI handle ; $aGraphArray - the array returned from _GraphGDIPlus_Create ; $iKeepGDIPlus - if not zero, function will not _GDIPlus_Shutdown() ; ======================================================================================= Func _GraphGDIPlus_Delete($hWnd, ByRef $aGraphArray, $iKeepGDIPlus = 0) If IsArray($aGraphArray) = 0 Then Return Local $ahTicksX, $ahTicksLabelsX, $ahTicksY, $ahTicksLabelsY, $i, $aTemp ;----- delete x ticks/labels ----- $ahTicksX = $aGraphArray[10] $ahTicksLabelsX = $aGraphArray[11] For $i = 1 To (UBound($ahTicksX) - 1) GUICtrlDelete($ahTicksX[$i]) Next For $i = 1 To (UBound($ahTicksLabelsX) - 1) GUICtrlDelete($ahTicksLabelsX[$i]) Next ;----- delete y ticks/labels ----- $ahTicksY = $aGraphArray[12] $ahTicksLabelsY = $aGraphArray[13] For $i = 1 To (UBound($ahTicksY) - 1) GUICtrlDelete($ahTicksY[$i]) Next For $i = 1 To (UBound($ahTicksLabelsY) - 1) GUICtrlDelete($ahTicksLabelsY[$i]) Next ;----- delete graphic control ----- _GDIPlus_GraphicsDispose($aGraphArray[17]) _GDIPlus_BitmapDispose($aGraphArray[16]) _GDIPlus_GraphicsDispose($aGraphArray[1]) _GDIPlus_BrushDispose($aGraphArray[21]) _GDIPlus_PenDispose($aGraphArray[20]) _GDIPlus_PenDispose($aGraphArray[22]) _GDIPlus_PenDispose($aGraphArray[23]) If $iKeepGDIPlus = 0 Then _GDIPlus_Shutdown() _WinAPI_InvalidateRect($hWnd) ;----- remove form global redraw array ----- For $i = 1 To UBound($aGraphGDIPlusaGraphArrayINTERNAL) - 1 $aTemp = $aGraphGDIPlusaGraphArrayINTERNAL[$i] If IsArray($aTemp) = 0 Then ContinueLoop If $aTemp[1] = $aGraphArray[1] Then $aGraphGDIPlusaGraphArrayINTERNAL[$i] = 0 Next ;----- close array ----- $aGraphArray = 0 EndFunc ;==>_GraphGDIPlus_Delete ; #FUNCTION# ============================================================================ ; Name...........: _GraphGDIPlus_Clear ; Description ...: Clears graph content ; Syntax.........: _GraphGDIPlus_Clear(ByRef $aGraphArray) ; Parameters ....: $aGraphArray - the array returned from _GraphGDIPlus_Create ; ======================================================================================= Func _GraphGDIPlus_Clear(ByRef $aGraphArray) If IsArray($aGraphArray) = 0 Then Return ;----- Set background Color ----- _GDIPlus_GraphicsFillRect($aGraphArray[17], 0, 0, $aGraphArray[4], $aGraphArray[5], $aGraphArray[21]) ;----- set border + Color ----- _GraphGDIPlus_RedrawRect($aGraphArray) EndFunc ;==>_GraphGDIPlus_Clear ; #FUNCTION# ============================================================================= ; Name...........: _GraphGDIPlus_Refresh ; Description ...: refreshes the graphic ; Syntax.........: _GraphGDIPlus_Refresh(ByRef $aGraphArray) ; Parameters ....: $aGraphArray - the array returned from _GraphGDIPlus_Create ; ======================================================================================== Func _GraphGDIPlus_Refresh(ByRef $aGraphArray) If IsArray($aGraphArray) = 0 Then Return ;----- draw ----- _GDIPlus_GraphicsDrawImageRect($aGraphArray[1], $aGraphArray[16], $aGraphArray[2], _ $aGraphArray[3], $aGraphArray[4] + 1, $aGraphArray[5] + 1) EndFunc ;==>_GraphGDIPlus_Refresh ; #FUNCTION# ============================================================================ ; Name...........: _GraphGDIPlus_Set_RangeX ; Description ...: Allows user to set the range of the X axis and set ticks and rounding levels ; Syntax.........: _GraphGDIPlus_Set_RangeX(ByRef $aGraphArray,$iLow,$iHigh,$iXTicks = 1,$bLabels = 1,$iRound = 0) ; Parameters ....: $aGraphArray - the array returned from _GraphGDIPlus_Create ; $iLow - the lowest value for the X axis (can be negative) ; $iHigh - the highest value for the X axis ; $iXTicks - [optional] number of ticks to show below axis, if = 0 then no ticks created ; $bLabels - [optional] 1=show labels, any other number=do not show labels ; $iRound - [optional] rounding level of label values ; ======================================================================================= Func _GraphGDIPlus_Set_RangeX(ByRef $aGraphArray, $iLow, $iHigh, $iXTicks = 1, $bLabels = 1, $iRound = 0) If IsArray($aGraphArray) = 0 Then Return Local $ahTicksX, $ahTicksLabelsX, $i ;----- load user vars to array ----- $aGraphArray[6] = $iLow $aGraphArray[7] = $iHigh ;----- prepare nested array ----- $ahTicksX = $aGraphArray[10] $ahTicksLabelsX = $aGraphArray[11] ;----- delete any existing ticks ----- For $i = 1 To (UBound($ahTicksX) - 1) GUICtrlDelete($ahTicksX[$i]) Next Dim $ahTicksX[1] ;----- create new ticks ----- For $i = 1 To $iXTicks + 1 ReDim $ahTicksX[$i + 1] $ahTicksX[$i] = GUICtrlCreateLabel("", (($i - 1) * ($aGraphArray[4] / $iXTicks)) + $aGraphArray[2], _ $aGraphArray[3] + $aGraphArray[5], 1, 5) GUICtrlSetBkColor(-1, 0x000000) GUICtrlSetState(-1, 128) Next ;----- delete any existing labels ----- For $i = 1 To (UBound($ahTicksLabelsX) - 1) GUICtrlDelete($ahTicksLabelsX[$i]) Next Dim $ahTicksLabelsX[1] ;----- create new labels ----- For $i = 1 To $iXTicks + 1 ReDim $ahTicksLabelsX[$i + 1] $ahTicksLabelsX[$i] = GUICtrlCreateLabel("", _ ($aGraphArray[2] + (($aGraphArray[4] / $iXTicks) * ($i - 1))) - (($aGraphArray[4] / $iXTicks) / 2), _ $aGraphArray[3] + $aGraphArray[5] + 10, $aGraphArray[4] / $iXTicks, 13, 1) GUICtrlSetBkColor(-1, -2) Next ;----- if labels are required, then fill ----- If $bLabels = 1 Then For $i = 1 To (UBound($ahTicksLabelsX) - 1) GUICtrlSetData($ahTicksLabelsX[$i], _ StringFormat("%." & $iRound & "f", _GraphGDIPlus_Reference_Pixel("p", (($i - 1) * ($aGraphArray[4] / $iXTicks)), _ $aGraphArray[6], $aGraphArray[7], $aGraphArray[4]))) Next EndIf ;----- load created arrays back into array ----- $aGraphArray[10] = $ahTicksX $aGraphArray[11] = $ahTicksLabelsX EndFunc ;==>_GraphGDIPlus_Set_RangeX ; #FUNCTION# ============================================================================ ; Name...........: _GraphGDIPlus_Set_RangeY ; Description ...: Allows user to set the range of the Y axis and set ticks and rounding levels ; Syntax.........: _GraphGDIPlus_SetRange_Y(ByRef $aGraphArray,$iLow,$iHigh,$iYTicks = 1,$bLabels = 1,$iRound = 0) ; Parameters ....: $aGraphArray - the array returned from _GraphGDIPlus_Create ; $iLow - the lowest value for the Y axis (can be negative) ; $iHigh - the highest value for the Y axis ; $iYTicks - [optional] number of ticks to show next to axis, if = 0 then no ticks created ; $bLabels - [optional] 1=show labels, any other number=do not show labels ; $iRound - [optional] rounding level of label values ; ======================================================================================= Func _GraphGDIPlus_Set_RangeY(ByRef $aGraphArray, $iLow, $iHigh, $iYTicks = 1, $bLabels = 1, $iRound = 0) If IsArray($aGraphArray) = 0 Then Return Local $ahTicksY, $ahTicksLabelsY, $i ;----- load user vars to array ----- $aGraphArray[8] = $iLow $aGraphArray[9] = $iHigh ;----- prepare nested array ----- $ahTicksY = $aGraphArray[12] $ahTicksLabelsY = $aGraphArray[13] ;----- delete any existing ticks ----- For $i = 1 To (UBound($ahTicksY) - 1) GUICtrlDelete($ahTicksY[$i]) Next Dim $ahTicksY[1] ;----- create new ticks ----- For $i = 1 To $iYTicks + 1 ReDim $ahTicksY[$i + 1] $ahTicksY[$i] = GUICtrlCreateLabel("", $aGraphArray[2] - 5, _ ($aGraphArray[3] + $aGraphArray[5]) - (($aGraphArray[5] / $iYTicks) * ($i - 1)), 5, 1) GUICtrlSetBkColor(-1, 0x000000) GUICtrlSetState(-1, 128) Next ;----- delete any existing labels ----- For $i = 1 To (UBound($ahTicksLabelsY) - 1) GUICtrlDelete($ahTicksLabelsY[$i]) Next Dim $ahTicksLabelsY[1] ;----- create new labels ----- For $i = 1 To $iYTicks + 1 ReDim $ahTicksLabelsY[$i + 1] $ahTicksLabelsY[$i] = GUICtrlCreateLabel("", $aGraphArray[2] - 40, _ ($aGraphArray[3] + $aGraphArray[5]) - (($aGraphArray[5] / $iYTicks) * ($i - 1)) - 6, 30, 13, 2) GUICtrlSetBkColor(-1, -2) Next ;----- if labels are required, then fill ----- If $bLabels = 1 Then For $i = 1 To (UBound($ahTicksLabelsY) - 1) GUICtrlSetData($ahTicksLabelsY[$i], StringFormat("%." & $iRound & "f", _GraphGDIPlus_Reference_Pixel("p", _ (($i - 1) * ($aGraphArray[5] / $iYTicks)), $aGraphArray[8], $aGraphArray[9], $aGraphArray[5]))) Next EndIf ;----- load created arrays back into array ----- $aGraphArray[12] = $ahTicksY $aGraphArray[13] = $ahTicksLabelsY EndFunc ;==>_GraphGDIPlus_Set_RangeY ; #FUNCTION# ============================================================================= ; Name...........: _GraphGDIPlus_Plot_Start ; Description ...: Move starting point of plot ; Syntax.........: _GraphGDIPlus_Plot_Start(ByRef $aGraphArray,$iX,$iY) ; Parameters ....: $aGraphArray - the array returned from _GraphGDIPlus_Create ; $iX - x value to start at ; $iY - y value to start at ; ======================================================================================== Func _GraphGDIPlus_Plot_Start(ByRef $aGraphArray, $iX, $iY) If IsArray($aGraphArray) = 0 Then Return ;----- MOVE pen to start point ----- $aGraphArray[18] = _GraphGDIPlus_Reference_Pixel("x", $iX, $aGraphArray[6], $aGraphArray[7], $aGraphArray[4]) $aGraphArray[19] = _GraphGDIPlus_Reference_Pixel("y", $iY, $aGraphArray[8], $aGraphArray[9], $aGraphArray[5]) EndFunc ;==>_GraphGDIPlus_Plot_Start ; #FUNCTION# ============================================================================= ; Name...........: _GraphGDIPlus_Plot_Line ; Description ...: draws straight line to x,y from previous point / starting point ; Syntax.........: _GraphGDIPlus_Plot_Line(ByRef $aGraphArray,$iX,$iY) ; Parameters ....: $aGraphArray - the array returned from _GraphGDIPlus_Create ; $iX - x value to draw to ; $iY - y value to draw to ; ======================================================================================== Func _GraphGDIPlus_Plot_Line(ByRef $aGraphArray, $iX, $iY) If IsArray($aGraphArray) = 0 Then Return ;----- Draw line from previous point to new point ----- $iX = _GraphGDIPlus_Reference_Pixel("x", $iX, $aGraphArray[6], $aGraphArray[7], $aGraphArray[4]) $iY = _GraphGDIPlus_Reference_Pixel("y", $iY, $aGraphArray[8], $aGraphArray[9], $aGraphArray[5]) ;~ _GDIPlus_GraphicsDrawLine($aGraphArray[17], $aGraphArray[18], $aGraphArray[19], $iX, $iY, $aGraphArray[20]) DllCall($ghGDIPDll, "int", "GdipDrawLine", "handle", $aGraphArray[17], "handle", $aGraphArray[20], "float", $aGraphArray[18], "float", $aGraphArray[19], "float", $iX, "float", $iY) _GraphGDIPlus_RedrawRect($aGraphArray) ;----- save current as last coords ----- $aGraphArray[18] = $iX $aGraphArray[19] = $iY EndFunc ;==>_GraphGDIPlus_Plot_Line ; #FUNCTION# ============================================================================= ; Name...........: _GraphGDIPlus_Plot_Point ; Description ...: draws point at coords ; Syntax.........: _GraphGDIPlus_Plot_Point(ByRef $aGraphArray,$iX,$iY) ; Parameters ....: $aGraphArray - the array returned from _GraphGDIPlus_Create ; $iX - x value to draw at ; $iY - y value to draw at ; ======================================================================================== Func _GraphGDIPlus_Plot_Point(ByRef $aGraphArray, $iX, $iY) If IsArray($aGraphArray) = 0 Then Return ;----- Draw point from previous point to new point ----- $iX = _GraphGDIPlus_Reference_Pixel("x", $iX, $aGraphArray[6], $aGraphArray[7], $aGraphArray[4]) $iY = _GraphGDIPlus_Reference_Pixel("y", $iY, $aGraphArray[8], $aGraphArray[9], $aGraphArray[5]) ;~ _GDIPlus_GraphicsDrawRect($aGraphArray[17], $iX-1, $iY-1, 2, 2, $aGraphArray[20]) DllCall($ghGDIPDll, "int", "GdipDrawRectangle", "handle", $aGraphArray[17], "handle", $aGraphArray[20], "float", $iX-1, "float", $iY-1,"float", 2, "float", 2) _GraphGDIPlus_RedrawRect($aGraphArray) ;----- save current as last coords ----- $aGraphArray[18] = $iX $aGraphArray[19] = $iY EndFunc ;==>_GraphGDIPlus_Plot_Point ; #FUNCTION# ============================================================================= ; Name...........: _GraphGDIPlus_Plot_Dot ; Description ...: draws single pixel dot at coords ; Syntax.........: _GraphGDIPlus_Plot_Dot(ByRef $aGraphArray,$iX,$iY) ; Parameters ....: $aGraphArray - the array returned from _GraphGDIPlus_Create ; $iX - x value to draw at ; $iY - y value to draw at ; ======================================================================================== Func _GraphGDIPlus_Plot_Dot(ByRef $aGraphArray, $iX, $iY) If IsArray($aGraphArray) = 0 Then Return ;----- Draw point from previous point to new point ----- $iX = _GraphGDIPlus_Reference_Pixel("x", $iX, $aGraphArray[6], $aGraphArray[7], $aGraphArray[4]) $iY = _GraphGDIPlus_Reference_Pixel("y", $iY, $aGraphArray[8], $aGraphArray[9], $aGraphArray[5]) ;~ _GDIPlus_GraphicsDrawRect($aGraphArray[17], $iX, $iY, 1, 1, $aGraphArray[20]) ;draws 2x2 dot ?HOW to get 1x1 pixel????? DllCall($ghGDIPDll, "int", "GdipDrawRectangle", "handle", $aGraphArray[17], "handle", $aGraphArray[20], "float", $iX, "float", $iY,"float", 1, "float", 1) _GraphGDIPlus_RedrawRect($aGraphArray) ;----- save current as last coords ----- $aGraphArray[18] = $iX $aGraphArray[19] = $iY EndFunc ;==>_GraphGDIPlus_Plot_Dot ; #FUNCTION# ============================================================================= ; Name...........: _GraphGDIPlus_Set_PenColor ; Description ...: sets the Color for the next drawing ; Syntax.........: _GraphGDIPlus_Set_PenColor(ByRef $aGraphArray,$hColor,$hBkGrdColor = $GUI_GR_NOBKColor) ; Parameters ....: $aGraphArray - the array returned from _GraphGDIPlus_Create ; $hColor - the Color of the next item (ARGB) ; ======================================================================================== Func _GraphGDIPlus_Set_PenColor(ByRef $aGraphArray, $hColor) If IsArray($aGraphArray) = 0 Then Return ;----- apply pen Color ----- _GDIPlus_PenSetColor($aGraphArray[20], $hColor) EndFunc ;==>_GraphGDIPlus_Set_PenColor ; #FUNCTION# ============================================================================= ; Name...........: _GraphGDIPlus_Set_PenSize ; Description ...: sets the pen for the next drawing ; Syntax.........: _GraphGDIPlus_Set_PenSize(ByRef $aGraphArray,$iSize = 1) ; Parameters ....: $aGraphArray - the array returned from _GraphGDIPlus_Create ; $iSize - size of pen line ; ======================================================================================== Func _GraphGDIPlus_Set_PenSize(ByRef $aGraphArray, $iSize = 1) If IsArray($aGraphArray) = 0 Then Return ;----- apply pen size ----- _GDIPlus_PenSetWidth($aGraphArray[20], $iSize) EndFunc ;==>_GraphGDIPlus_Set_PenSize ; #FUNCTION# ============================================================================= ; Name...........: _GraphGDIPlus_Set_PenDash ; Description ...: sets the pen dash style for the next drawing ; Syntax.........: GraphGDIPlus_Set_PenDash(ByRef $aGraphArray,$iDash = 0) ; Parameters ....: $aGraphArray - the array returned from _GraphGDIPlus_Create ; $iDash - style of dash, where: ; 0 = solid line ; 1 = simple dashed line ; 2 = simple dotted line ; 3 = dash dot line ; 4 = dash dot dot line ; ======================================================================================== Func _GraphGDIPlus_Set_PenDash(ByRef $aGraphArray, $iDash = 0) If IsArray($aGraphArray) = 0 Then Return Local $Style Switch $iDash Case 0 ;solid line _____ $Style = $GDIP_DASHSTYLESOLID Case 1 ;simple dash ----- $Style = $GDIP_DASHSTYLEDASH Case 2 ;simple dotted ..... $Style = $GDIP_DASHSTYLEDOT Case 3 ;dash dot -.-.- $Style = $GDIP_DASHSTYLEDASHDOT Case 4 ;dash dot dot -..-..-.. $Style = $GDIP_DASHSTYLEDASHDOTDOT EndSwitch ;----- apply pen dash ----- _GDIPlus_PenSetDashStyle($aGraphArray[20], $Style) EndFunc ;==>_GraphGDIPlus_Set_PenDash ; #FUNCTION# ============================================================================= ; Name...........: _GraphGDIPlus_Set_GridX ; Description ...: Adds X gridlines. ; Syntax.........: _GraphGDIPlus_Set_GridX(ByRef $aGraphArray, $Ticks=1, $hColor=0xf0f0f0) ; Parameters ....: $aGraphArray - the array returned from _GraphGDIPlus_Create ; $Ticks - sets line at every nth unit assigned to axis ; $hColor - [optional] RGB value, defining Color of grid. Default is a light gray ; $hColorY0 - [optional] RGB value, defining Color of Y=0 line, Default black ; ======================================================================================= Func _GraphGDIPlus_Set_GridX(ByRef $aGraphArray, $Ticks = 1, $hColor = 0xFFf0f0f0, $hColorY0 = 0xFF000000) If IsArray($aGraphArray) = 0 Then Return ;----- Set gpen to user color ----- _GDIPlus_PenSetColor($aGraphArray[23], $hColor) ;----- draw grid lines ----- Select Case $Ticks > 0 For $i = $aGraphArray[6] To $aGraphArray[7] Step $Ticks If $i = Number($aGraphArray[6]) Or $i = Number($aGraphArray[7]) Then ContinueLoop _GDIPlus_GraphicsDrawLine($aGraphArray[17], _ _GraphGDIPlus_Reference_Pixel("x", $i, $aGraphArray[6], $aGraphArray[7], $aGraphArray[4]), _ 1, _ _GraphGDIPlus_Reference_Pixel("x", $i, $aGraphArray[6], $aGraphArray[7], $aGraphArray[4]), _ $aGraphArray[5] - 1, _ $aGraphArray[23]) Next EndSelect ;----- draw y=0 ----- _GDIPlus_PenSetColor($aGraphArray[23], $hColorY0) _GDIPlus_GraphicsDrawLine($aGraphArray[17], _ _GraphGDIPlus_Reference_Pixel("x", 0, $aGraphArray[6], $aGraphArray[7], $aGraphArray[4]), _ 1, _ _GraphGDIPlus_Reference_Pixel("x", 0, $aGraphArray[6], $aGraphArray[7], $aGraphArray[4]), _ $aGraphArray[5] - 1, _ $aGraphArray[23]) _GDIPlus_GraphicsDrawLine($aGraphArray[17], _ 1, _ _GraphGDIPlus_Reference_Pixel("y", 0, $aGraphArray[8], $aGraphArray[9], $aGraphArray[5]), _ $aGraphArray[4] - 1, _ _GraphGDIPlus_Reference_Pixel("y", 0, $aGraphArray[8], $aGraphArray[9], $aGraphArray[5]), _ $aGraphArray[23]) _GraphGDIPlus_RedrawRect($aGraphArray) ;----- re-set to user specs ----- _GDIPlus_PenSetColor($aGraphArray[23], $hColor) ;set Color back to user def EndFunc ;==>_GraphGDIPlus_Set_GridX ; #FUNCTION# ============================================================================= ; Name...........: _GraphGDIPlus_Set_GridY ; Description ...: Adds Y gridlines. ; Syntax.........: _GraphGDIPlus_Set_GridY(ByRef $aGraphArray, $Ticks=1, $hColor=0xf0f0f0) ; Parameters ....: $aGraphArray - the array returned from _GraphGDIPlus_Create ; $Ticks - sets line at every nth unit assigned to axis ; $hColor - [optional] RGB value, defining Color of grid. Default is a light gray ; $hColorX0 - [optional] RGB value, defining Color of X=0 line, Default black ; ======================================================================================= Func _GraphGDIPlus_Set_GridY(ByRef $aGraphArray, $Ticks = 1, $hColor = 0xFFf0f0f0, $hColorX0 = 0xFF000000) If IsArray($aGraphArray) = 0 Then Return ;----- Set gpen to user color ----- _GDIPlus_PenSetColor($aGraphArray[23], $hColor) ;----- draw grid lines ----- Select Case $Ticks > 0 For $i = $aGraphArray[8] To $aGraphArray[9] Step $Ticks If $i = Number($aGraphArray[8]) Or $i = Number($aGraphArray[9]) Then ContinueLoop _GDIPlus_GraphicsDrawLine($aGraphArray[17], _ 1, _ _GraphGDIPlus_Reference_Pixel("y", $i, $aGraphArray[8], $aGraphArray[9], $aGraphArray[5]), _ $aGraphArray[4] - 1, _ _GraphGDIPlus_Reference_Pixel("y", $i, $aGraphArray[8], $aGraphArray[9], $aGraphArray[5]), _ $aGraphArray[23]) Next EndSelect ;----- draw abcissa/ordinate ----- _GDIPlus_PenSetColor($aGraphArray[23], $hColorX0) _GDIPlus_GraphicsDrawLine($aGraphArray[17], _ _GraphGDIPlus_Reference_Pixel("x", 0, $aGraphArray[6], $aGraphArray[7], $aGraphArray[4]), _ 1, _ _GraphGDIPlus_Reference_Pixel("x", 0, $aGraphArray[6], $aGraphArray[7], $aGraphArray[4]), _ $aGraphArray[5] - 1, _ $aGraphArray[23]) _GDIPlus_GraphicsDrawLine($aGraphArray[17], _ 1, _ _GraphGDIPlus_Reference_Pixel("y", 0, $aGraphArray[8], $aGraphArray[9], $aGraphArray[5]), _ $aGraphArray[4] - 1, _ _GraphGDIPlus_Reference_Pixel("y", 0, $aGraphArray[8], $aGraphArray[9], $aGraphArray[5]), _ $aGraphArray[23]) _GraphGDIPlus_RedrawRect($aGraphArray) ;----- re-set to user specs ----- _GDIPlus_PenSetColor($aGraphArray[23], $hColor) ;set Color back to user def EndFunc ;==>_GraphGDIPlus_Set_GridY ; #FUNCTION# ============================================================================= ; Name...........: _GraphGDIPlus_RedrawRect ; Description ...: INTERNAL FUNCTION - Re-draws the border ; Syntax.........: _GraphGDIPlus_RedrawRect(ByRef $aGraphArray) ; Parameters ....: $aGraphArray - the array returned from _GraphGDIPlus_Create ; Notes..........: This prevents drawing over the border of the graph area ; ========================================================================================= Func _GraphGDIPlus_RedrawRect(ByRef $aGraphArray) If IsArray($aGraphArray) = 0 Then Return ;----- draw border ----- _GDIPlus_GraphicsDrawRect($aGraphArray[17], 0, 0, $aGraphArray[4], $aGraphArray[5], $aGraphArray[22]) ;draw border EndFunc ;==>_GraphGDIPlus_RedrawRect ; #FUNCTION# ============================================================================= ; Name...........: _GraphGDIPlus_Reference_Pixel ; Description ...: INTERNAL FUNCTION - performs pixel reference calculations ; Syntax.........: _GraphGDIPlus_Reference_Pixel($iType,$iValue,$iLow,$iHigh,$iTotalPixels) ; Parameters ....: $iType - "x"=x axis pix, "y" = y axis pix, "p"=value from pixels ; $iValue - pixels reference or value ; $iLow - lower limit of axis ; $iHigh - upper limit of axis ; $iTotalPixels - total number of pixels in range (either width or height) ; ========================================================================================= Func _GraphGDIPlus_Reference_Pixel($iType, $iValue, $iLow, $iHigh, $iTotalPixels) ;----- perform pixel reference calculations ----- Switch $iType Case "x" Return (($iTotalPixels / ($iHigh - $iLow)) * (($iHigh - $iLow) * (($iValue - $iLow) / ($iHigh - $iLow)))) Case "y" Return ($iTotalPixels - (($iTotalPixels / ($iHigh - $iLow)) * (($iHigh - $iLow) * (($iValue - $iLow) / ($iHigh - $iLow))))) Case "p" Return ($iValue / ($iTotalPixels / ($iHigh - $iLow))) + $iLow EndSwitch EndFunc ;==>_GraphGDIPlus_Reference_Pixel ; #FUNCTION# ============================================================================= ; Name...........: _GraphGDIPlus_SaveImage ; Description ...: INTERNAL FUNCTION - save drawn image to file ; Syntax.........: _GraphGDIPlus_SaveImage($aGraphArray, $file) ; Parameters ....: ByRef $aGraphArray - the array returned from _GraphGDIPlus_Create ; $file - filename ; Autor .........: UEZ ; ========================================================================================= Func _GraphGDIPlus_SaveImage(ByRef $aGraphArray, $file, $bFull = True) If IsArray($aGraphArray) = 0 Then Return If Not $bFull Then _GDIPlus_ImageSaveToFile($aGraphArray[16], $file) If @error Then Return SetError(1, 0, 0) Else If Not WinActive($aGraphArray[24]) Then WinActive($aGraphArray[24]) Local $aWinCPos = WinGetClientSize($aGraphArray[24]) Local $hDC = _WinAPI_GetDC($aGraphArray[24]) Local $hCDC = _WinAPI_CreateCompatibleDC($hDC) Local $hHBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $aWinCPos[0], $aWinCPos[1]) _WinAPI_SelectObject ($hCDC, $hHBitmap) _WinAPI_BitBlt($hCDC, 0, 0, $aWinCPos[0], $aWinCPos[1], $hDC, 0, 0, 0x00CC0020) ; 0x00CC0020 = $SRCCOPY Local $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hHBitmap) _WinAPI_ReleaseDC($aGraphArray[24], $hDC) _WinAPI_DeleteDC($hCDC) _WinAPI_DeleteObject ($hHBitmap) _GDIPlus_ImageSaveToFile($hBitmap, $file) If @error Then _GDIPlus_BitmapDispose($hBitmap) Return SetError(2, 0, 0) EndIf _GDIPlus_BitmapDispose($hBitmap) EndIf Return 1 EndFunc ;==>_GraphGDIPlus_SaveImage Func _GraphGDIPlus_DrawText(ByRef $aGraphArray, $sString, $iX, $iY, $iBrushColor = 0xFF000000, $sFont = "Arial", $iFontSize = 12, $iStyle = 0) If IsArray($aGraphArray) = 0 Then Return Local $hBrush = _GDIPlus_BrushCreateSolid($iBrushColor) Local $hFormat = _GDIPlus_StringFormatCreate() Local $hFamily = _GDIPlus_FontFamilyCreate($sFont) Local $hFont = _GDIPlus_FontCreate($hFamily, $iFontSize, $iStyle) Local $tLayout = _GDIPlus_RectFCreate($iX, $iY, 0, 0) _GDIPlus_GraphicsDrawStringEx($aGraphArray[17], $sString, $hFont, $tLayout, $hFormat, $hBrush) _GDIPlus_FontDispose($hFont) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_BrushDispose($hBrush) Return 1 EndFunc ;==>_GraphGDIPlus_DrawText Br, UEZ1 point
-
I have not gone ahead with the scripts by Bluesmaster. Instead I have moved most code from the start script to an UDF: WindowsExplorer.au3. This is the new start script (included in the zip): #include <GuiConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Opt( "MustDeclareVars", 1 ) ; Project includes #include "Resources\Include\WindowsExplorer.au3" ; Include this file #include "Resources\Include\ToolbarFunctions.au3" ; Edit this file to modify toolbar MainFunc() Func MainFunc() ; Create GUI Local $sTitle = "Windows Explorer right pane" Local $iStyle = BitOR( $GUI_SS_DEFAULT_GUI, $WS_CLIPCHILDREN, $WS_MAXIMIZEBOX, $WS_SIZEBOX ) Local $hGui = GUICreate( $sTitle, 700, 400, 200, 50, $iStyle ) ; Show GUI GUISetState( @SW_SHOW, $hGui ) ; Create toolbar ; CreateToolbar( $hGui, $bLargeIcons = False ) CreateToolbar( $hGui, True ) ; Create Explorer window ; CreateExplorerWindow( $hGui, $sFolder = @ScriptDir, $iView = $FVM_DETAILS ) ; $FVM_ICON = 1 ; The view should display medium-size icons. ; $FVM_SMALLICON = 2 ; The view should display small icons. ; $FVM_LIST = 3 ; Object names are displayed in a list view. ; $FVM_DETAILS = 4 ; Object names and other selected information, such as the size or date last updated, are shown. ; $FVM_THUMBNAIL = 5 ; The view should display thumbnail icons. ; $FVM_TILE = 6 ; The view should display large icons. ; $FVM_THUMBSTRIP = 7 ; The view should display icons in a filmstrip format. ;CreateExplorerWindow( $hGui, "C:\Windows", $FVM_ICON ) CreateExplorerWindow( $hGui ) ; Message loop Local $iMsg While 1 $iMsg = GUIGetMsg() If $iMsg = 0 Or $iMsg = $GUI_EVENT_MOUSEMOVE Then ContinueLoop Switch $iMsg Case $idToolbarClick, $idDropDownMenu, $idBackMenu, $idViewMenu ToolbarEvent( $iMsg ) Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd EndFunc This code doesn't work on XP, and you need AutoIt 3.3.10.0+ (however, only a matter of a few includes). Let me know if there are any issues. Windows Explorer right pane.7z1 point