Jump to content
dany

GetOpt: UDF to parse the command line

Recommended Posts

dany

GetOpt.au3 v1.3

If you've ever dabbled in C (or Python, Perl etc) then you might have heard of getopt() (Wiki entry). Well, I wrote this UDF to get that functionality into AutoIt. Some searching around here on the forum did turn up some other UDFs in this direction, but I decided to write my own port anyway and parallel the implementation in the C library. It's still missing a few things but on a whole it does the job really well. It's now pretty much complete.

And I want to share it with you all. So here it is.

If you want to handle the command line options passed to your script or program like a master, then this is the UDF for you!

Main features:

  • Parses DOS style options as well as GNU style options alike.
  • Handles both short and long options.
  • Define options that must have arguments when used.
  • Define and handle suboptions (-s=foo,bar=quux,baz).
  • Supports + and /- option modifiers.
  • Casts string arguments to AutoIt variants, e.g. -a=yes becomes True.
  • Easy access to any passed operand that's not an option.

Some examples of invoking scripts:

Script.au3 -a -b=10 --long-option file.txt
Script.au3 /A /B:10 /Long-Option file.txt

As you see you can use both styles on the command line (as a matter of fact, at this moment you could even mix them but that wouldn't be good practice). In your script you just set the options you want to detect with _GetOpt_Set() and then iterate through each option with _GetOpt(). The 'file.txt' is available through _GetOpt_Oper(). See GetOpt-Example.au3 below for a step-by-step walkthrough of using GetOpt.au3.

The UDF:

GetOpt.au3 (+43)

GetOpt-Example.au3: A demo of GetOpt.au3

#include <GetOpt.au3>
#include <Array.au3> ; For demo purposes only.

If 0 = $CmdLine[0] Then
    ; Create our own example command line.
    Run(FileGetShortName(@AutoItExe) & ' ' & FileGetShortName(@ScriptFullPath) & ' -a=no -b=42 -c=0.5 /Windows:' & @OSVersion & ' -z --required -s=foo,bar=quux,baz +p /-M -- -w=ignored Hello World!')
    Exit
EndIf

_GetOpt_Demo()

Func _GetOpt_Demo()
    Local $sMsg = @ScriptName & ' for GetOpt v' & $GETOPT_VERSION & '.' & @CRLF & 'Parsing: ' & _ArrayToString($CmdLine, ' ', 1) & @CRLF & @CRLF; Message.
    Local $sOpt, $sSubOpt, $sOper
    ; Options array, entries have the format [short, long, default value]
    Local $aOpts[9][3] = [ _
        ['-a', '--a-option', True], _
        ['-b', '--b-option', False], _
        ['-c', '--c-option', 'c option argument'], _
        ['/W', '/Windows', 'windows style argument'], _ ; For demo purposes styles are mixed.
        ['-r', '--required', $GETOPT_REQUIRED_ARGUMENT], _ ; This option requires an argument.
        ['-s', '--suboption', $GETOPT_REQUIRED_ARGUMENT], _ ; option with suboptions.
        ['-p', '--plus', Default], _
        ['/M', '/Minus', Default], _
        ['-h', '--help', True] _
    ]
    ; Suboptions array, entries have the format [suboption, default value]
    Local $aSubOpts[2][2] = [ _
        ['foo', 47], _
        ['bar', True] _
    ]
    _GetOpt_Set($aOpts) ; Set options.
    If 0 < $GetOpt_Opts[0] Then ; If there are any options...
        While 1 ; ...loop through them one by one.
            ; Get the next option passing a string with valid options.
            $sOpt = _GetOpt('abcwr:s:pmh') ; r: means -r option requires an argument.
            If Not $sOpt Then ExitLoop ; No options or end of loop.
            ; Check @extended above if you want better error handling.
            ; The current option is stored in $GetOpt_Opt, it's index (in $GetOpt_Opts)
            ; in $GetOpt_Ind and it's value in $GetOpt_Arg.
            Switch $sOpt ; What is the current option?
                Case '?' ; Unknown options come here. @extended is set to $E_GETOPT_UNKNOWN_OPTION
                    $sMsg &= 'Unknown option: ' & $GetOpt_Ind & ': ' & $GetOpt_Opt
                    $sMsg &= ' with value "' & $GetOpt_Arg & '" (' & VarGetType($GetOpt_Arg) & ').' & @CRLF
                Case ':' ; Options with missing required arguments come here. @extended is set to $E_GETOPT_MISSING_ARGUMENT
                    $sMsg &= 'Missing required argument for option: ' & $GetOpt_Ind & ': ' & $GetOpt_Opt & @CRLF
                Case 'a', 'b', 'c', 'w', 'p', 'm'
                    $sMsg &= 'Option ' & $GetOpt_Ind & ': ' & $GetOpt_Opt
                    $sMsg &= ' with value "' & $GetOpt_Arg & '" (' & VarGetType($GetOpt_Arg) & ')'
                    If $GETOPT_MOD_PLUS = $GetOpt_Mod Then
                        $sMsg &= ' and invoked with plus modifier (+' & $GetOpt_Opt & ')'
                    ElseIf $GETOPT_MOD_MINUS = $GetOpt_Mod Then
                        $sMsg &= ' and invoked with minus modifier (/-' & $GetOpt_Opt & ')'
                    EndIf
                    $sMsg &= '.' & @CRLF
                Case 'r'
                    $sMsg &= 'Option ' & $GetOpt_Ind & ': ' & $GetOpt_Opt
                    $sMsg &= ' with required value "' & $GetOpt_Arg & '" (' & VarGetType($GetOpt_Arg) & ')'
                    If $GETOPT_MOD_PLUS = $GetOpt_Mod Then
                        $sMsg &= ' and invoked with plus modifier (+' & $GetOpt_Opt & ')'
                    ElseIf $GETOPT_MOD_MINUS = $GetOpt_Mod Then
                        $sMsg &= ' and invoked with minus modifier (/-' & $GetOpt_Opt & ')'
                    EndIf
                    $sMsg &= '.' & @CRLF
                Case 's'
                    $sMsg &= 'Option ' & $GetOpt_Ind & ': ' & $GetOpt_Opt
                    $sMsg &= ' with required suboptions:' & @CRLF
                    While 1 ; Loop through suboptions.
                        $sSubOpt = _GetOpt_Sub($GetOpt_Arg, $aSubOpts)
                        If Not $sSubOpt Then ExitLoop ; No suboptions or end of loop.
                        ; Check @extended above if you want better error handling.
                        ; The current suboption is stored in $GetOpt_SubOpt, it's index (in $GetOpt_SubOpts)
                        ; in $GetOpt_SubInd and it's value in $GetOpt_SubArg.
                        Switch $sSubOpt ; What is the current suboption?
                            Case '?'
                                $sMsg &= '    Unknown suboption ' & $GetOpt_SubInd & ': ' & $GetOpt_SubOpt
                                $sMsg &= ' with value "' & $GetOpt_SubArg & '" (' & VarGetType($GetOpt_SubArg) & ').' & @CRLF
                            Case 'foo', 'bar'
                                $sMsg &= '    Suboption ' & $GetOpt_SubInd & ': ' & $GetOpt_SubOpt
                                $sMsg &= ' with value "' & $GetOpt_SubArg & '" (' & VarGetType($GetOpt_SubArg) & ').' & @CRLF
                        EndSwitch
                    WEnd
                    If $GETOPT_MOD_PLUS = $GetOpt_Mod Then
                        $sMsg &= 'And invoked with plus modifier (+' & $GetOpt_Opt & ').'
                    ElseIf $GETOPT_MOD_MINUS = $GetOpt_Mod Then
                        $sMsg &= ' and invoked with minus modifier (/-' & $GetOpt_Opt & ')'
                    EndIf
                Case 'h'
                    MsgBox(0, 'GetOpt.au3', 'GetOpt.au3 example.' & @CRLF & _
                            'Just try out some options and find out what happens!')
                    Exit
            EndSwitch
        WEnd
    Else
        $sMsg &= 'No options passed.' & @CRLF
    EndIf
    $sMsg &= @CRLF
    If 0 < $GetOpt_Opers[0] Then ; If there are any operands...
        While 1 ; ...loop through them one by one.
            $sOper = _GetOpt_Oper() ; Get the next operand.
            If Not $sOper Then ExitLoop ; no operands or end of loop.
            ; Check @extended above if you want better error handling.
            $sMsg &= 'Operand ' & $GetOpt_OperInd & ': ' & $sOper & @CRLF
        WEnd
    Else
        $sMsg &= 'No operands passed.' & @CRLF
    EndIf
    MsgBox(0, @ScriptName, $sMsg) ; Let's see what we've got.
    _ArrayDisplay($GetOpt_Opts, '$GetOpt_Opts')
    _ArrayDisplay($GetOpt_Opers, '$GetOpt_Opers')
    _ArrayDisplay($GetOpt_ArgV, '$GetOpt_ArgV')
    Exit
EndFunc

Version 1.3:
+ Added support for -- (marks end of options).
+ Added support for + option modifiers e.g. +x.
+ Added support for /- option modifiers e.g. /-X.
+ Added _GetOpt_Sub to iterate through comma-separated suboptions like -s=a=foo,b=bar.
* Changed $GETOPT_REQUIRED_ARGUMENT from keyword Default to Chr(127), keyword can now be used as an option argument.
* Standardized comments and function headers.
* Tidy-ed up source code.
Version 1.2:
+ Support for required arguments with options, e.g. _GetOpt('ab:c') where -b=foo is valid and -b will return an error.
+ Added support for /C:foo (colon) when using DOS style.
+ Added optional auto-casting of arguments from Strings to AutoIt variants, e.g. -a=yes on the CLI would set the $GetOpt_Arg to True and not 'yes'. See __GetOpt_Cast.
* Private __GetOpt_DOSToGNU to simplify code.
Version 1.1:
* Initial public release.

If you encounter any bugs or have any suggestions, requests or improvements, then please let me know.

Happy coding!

Edited by dany
  • Like 1

[center]Spiderskank Spiderskank[/center]GetOpt Parse command line options UDF | AU3Text Program internationalization UDF | Identicon visual hash UDF

Share this post


Link to post
Share on other sites
JasonTHEchristian

If im reading this right, it steps through your code one line at a time is that right?

Share this post


Link to post
Share on other sites
BrewManNH

This set of functions is for dealing with command line parameters sent to your script when you run the exe.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
JasonTHEchristian

Got it, thanks.

Share this post


Link to post
Share on other sites
dany

Yep, if you run 'program.exe -a -b -c' you can access each option inside the loop and deal with them appropiately.


[center]Spiderskank Spiderskank[/center]GetOpt Parse command line options UDF | AU3Text Program internationalization UDF | Identicon visual hash UDF

Share this post


Link to post
Share on other sites
dany

New version 1.2, see first post for download and a changelog.


[center]Spiderskank Spiderskank[/center]GetOpt Parse command line options UDF | AU3Text Program internationalization UDF | Identicon visual hash UDF

Share this post


Link to post
Share on other sites
dany

New version 1.3, see first post for download and a changelog.


[center]Spiderskank Spiderskank[/center]GetOpt Parse command line options UDF | AU3Text Program internationalization UDF | Identicon visual hash UDF

Share this post


Link to post
Share on other sites
DaHack

Thank you for this awesome tool. I really love it. I did find an issue. When using an option, I am not able to send a zero as an option for a required option. For instance:

-t=0 or /t:0

This gives me an error that results from going into the Case ':'

I do have version 1.3, I upgraded today from 1.2.

Thanks again for the tool.


Time is precious, search wisely.

Share this post


Link to post
Share on other sites
useruser

Thank you for this awesome tool. I really love it. I did find an issue. When using an option, I am not able to send a zero as an option for a required option. For instance:

 

-t=0 or /t:0

 

This gives me an error that results from going into the Case ':'

 

I do have version 1.3, I upgraded today from 1.2.

 

Thanks again for the tool.

The same happens when passing "True/Yes/yes/y" as the required option.

Share this post


Link to post
Share on other sites
aixylinux

Thank you for your excellent UDF.  I used years ago with great success with an earlier version of Autoit--I don't recall which one.  Recently, using Autoit 3.3.14.2, I get a syntax error on these statements:

Global Const Enum $GETOPT_MOD_NONE = 0, $GETOPT_MOD_PLUS, $GETOPT_MOD_MINUS ; Int: Option modifiers.

 Global Const Enum $E_GETOPT_BAD_FUNCTION_ARGUMENT = 1, _
        $E_GETOPT_INVALID_OPTIONS, $E_GETOPT_NO_OPTIONS_SET, _
        $E_GETOPT_NO_COMMAND_LINE, $E_GETOPT_NO_OPTIONS, $E_GETOPT_NO_OPERANDS, _
        $E_GETOPT_UNKNOWN_OPTION, $E_GETOPT_MISSING_ARGUMENT, _
        $E_GETOPT_SUBOPTION_MISMATCH, $E_GETOPT_NO_SUBOPTIONS, $E_GETOPT_UNKNOWN_SUBOPTION

I found that if I remove the Const qualifier, the module compiles successfully.  Perhaps some change to Autoit altered the previously  valid syntax. After all, Enum implies Const.  

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Similar Content

    • somebadhat
      By somebadhat
      THANKS TO RASIM, MARTIN, AND BOOMINGRANNY FOR TEACHING ME HOW TO DO THIS. 
      SCRIPT ONE WORKS ON MY PLATFORM.  IT CREATED THE ATTACHMENTS.
      IMPROVEMENTS ARE WELCOMED. 
      SEE BOLD TEXT BELOW.
      PURPOSE:
      WRITE AN AUTOIT3 SCRIPT THAT WHEN RUN IN A WINDOWS SCHEDULED TASK WILL PRODUCE SCREENSHOTS OF THE DESKTOP, START MENU, QUICK ACCESS MENU, AND DEVICE MANAGER WITHOUT INTERACTION.  IF MULTIPLE SHOTS ARE REQUIRED THE SHOTS CAN BE COMBINED STACKED OR SIDE-BY-SIDE.  SCRIPTS ARE WRITTEN TO RUN ON WINDOWS 10.0.17134.286 PRO 64-BIT IN AN ACCOUNT WITH ADMIN PRIVILEGES IN A WINDOW WITH ADMIN PRIVILEGES AND AUTOIT3 v3.3.14.5
      PROCEDURE:
      WHAT ARE THE COORDINATES OF THE SCREENSHOTS?
      WHERE DO YOU WANT TO CREATE THE SHOTS?
      WHAT DO YOU WANT TO CALL THE SHOTS?
      TAKE THE SHOTS.
      PROCESS THE SHOTS:
      WHERE ARE THEY? WHAT ARE THEY CALLED? WHERE DO YOU WANT THEM TO GO? WHAT DO YOU WANT TO CALL THEM? DO YOU WANT THEM STACKED, SIDE-BY-SIDE, OR NEITHER? TWEAK TO ELIMINATE ERRORS.
      RESULTS: SCRIPT TWO I'VE INCORPORATED THE SUGGESTION OF @BOOMINGRANNY AND MADE A SECOND SCRIPT.  MY WAY OF FINDING THE SHOT COORDINATES OF THE DEVICE MANAGER DID NOT WORK WHEN STARTING THE DEVICE MANAGER THIS WAY . #include <Coordinates.au3> finds incorrect coordinates.  They are shifted down ~50px.  Does not work on menus exposed by right clicking or the start menu. WORK NEEDS TO BE DONE TO ELIMINATE THE BLACK BAR WHEN THE SHOTS ARE NOT THE SAME HEIGHT and ARE BEING DISPLAYED SIDE-BY-SIDE. 
      SEE    If $Position = "right"
      CONCLUSION:
      UNFINISHED AS OF THIS TIME.
      MAKE ROBUST.  A ROBUST SCRIPT FAILS LESS THAN 1% OF THE TIME AND RUNS ON WINDOWS 10 64-BIT THROUGH WINDOWS XP 32-BIT SP0 IN AN ACCOUNT WITH STANDARD/USER/LIMITED PRIVILEGES IN A WINDOW WITH STANDARD/USER/LIMITED PRIVILEGES.   IT WOULD BE NICE TO MAKE THE SCRIPT FASTER AND LIGHTER.

      RESULTS ATTACHED. SCRIPT ONE:
      ;; AUTOIT3 v3.3.14.5 SCRIPT ;; PURPOSE: ; WRITE AN AUTOIT3 SCRIPT THAT WHEN RUN IN A WINDOWS SCHEDULED TASK WILL PRODUCE SCREENSHOTS OF THE WINDOWS 10 DESKTOP, START MENU, QUICK ACCESS MENU, AND DEVICE MANAGER WITHOUT INTERACTION. ;; SEE https://www.autoitscript.com/forum/topic/196256-screenshot-win10-desktop-quick-access-device-manager-start-menu-automated-shots-stacked-or-side-by-side-requires-admin/ ;; MUST BE RUN WITH ADMIN PRIVILEDGES. NOT ROBUST YET. ;; SCREENSHOT WIN10 DESKTOP, QUICK ACCESS, DEVICE MANAGER AND START MENU. ;; MULTIPLE SHOTS JOINED STACKED, SIDE-BY-SIDE, OR NEITHER. SEE SIDE-BY-SIDE ;; WORK NEEDS TO BE DONE TO ELIMINATE THE BLACK BAR WHEN THE SHOTS ARE NOT THE SAME HEIGHT AND ARE BEING DISPLAYED SIDE-BY-SIDE. ;; MY GUESS THE EASIEST THING TO DO WOULD BE TO TURN IT WHITE. ;; YOU WILL HAVE TO TELL IT WHERE YOUR TASKBAR EXPLORER SHORTCUT IS. SEE MouseClick ( "right", 74, 748, 1, 0) ;; YOU WILL HAVE TO TELL IT WHERE TO PROCESS AND MOVE THE SHOTS. SEE MULTIPLE OF $ZDIR, $ZNAME, FQPN SEE $outputFile ;; ;; IMPROVEMENTS ARE WELCOMED ;; FIND LIST OF ENVIRONMENT VARIABLES NAMES ;; AUTOIT3 HELP File ;; "C:\Program Files (x86)\AutoIt3\AutoIt.chm" ;; SEARCH FOR MACRO REFERENCE AND MACRO REFERENCE - DIRECTORY ;; THANKS TO RASIM, MARTIN, AND BOOMINGRANNY AT AUTOITSCRIPT.COM ; https://www.autoitscript.com/forum/topic/80896-join-two-bitmap-images/ ; https://www.autoitscript.com/forum/topic/80896-join-two-bitmap-images/?do=findComment&comment=581214 ; https://www.autoitscript.com/forum/topic/80896-join-two-bitmap-images/?do=findComment&comment=581372 ; https://www.autoitscript.com/forum/topic/196256-screenshot-win10-desktop-quick-access-device-manager-start-menu-automated-shots-stacked-or-side-by-side-requires-admin/ ; https://www.autoitscript.com/forum/topic/196256-screenshot-win10-desktop-quick-access-device-manager-start-menu-automated-shots-stacked-or-side-by-side-requires-admin//?do=findComment&comment=1407181 ;; "C:\Program Files (x86)\AutoIt3\AutoIt3_x64.exe" "F:\MYAPPS\WINDOWS\screenshots1.au3" ;; Screenshot Win10 desktop, quick access, device manager, start menu. Automated. Shots stacked or side-by-side. Requires admin. ; BEGIN How to get 4 Screen Coordinates just by dragging a Rectangle ; download Coordinates.au3 https://www.autoitscript.com/forum/applications/core/interface/file/attachment.php?id=59228 ; END How to get 4 Screen Coordinates just by dragging a Rectangle ; BEGIN CAPTURE ; https://www.autoitscript.com/forum/topic/8377-capture-screen-dll/ ; Capture full screen ; Fist parameter - filename, last - jpeg quality. #include <ScreenCapture.au3> ; BEGIN THE FOLLOWING REQUIRED TO SHOOT THE ENTIRE DEVICE MANAGER IN ONE SHOT ; https://www.autoitscript.com/forum/topic/196256-screenshot-win10-desktop-quick-access-device-manager-start-menu-automated-shots-stacked-or-side-by-side-requires-admin//?do=findComment&comment=1407181 ; credit for the screenshot scrolling code goes to monoscout999 #include <ScrollBarsConstants.au3> #include <WindowsConstants.au3> #include <process.au3> #include <GuiTreeView.au3> #include <GuiScrollBars.au3> #include <WinAPISysWin.au3> ; END THE FOLLOWING REQUIRED TO SHOOT THE ENTIRE DEVICE MANAGER IN ONE SHOT ; BETTER RESULTS IF AT LEASE ONE EXPLORER WINDOW IS OPEN Run("explorer.exe", "", @SW_SHOWMINIMIZED) ; Run( @comspec & " /c start explorer.exe","", @SW_SHOWMINIMIZED) ; Run( @comspec & " /c start explorer.exe","", @SW_HIDE) WinWait("My Computer") ; WinActivate("My Computer") ; WinSetState("My Computer", "", @SW_MAXIMIZE) ; wake the monitor, show the desktop, wait X milliseconds ; Send(" ") send( "#d" ) Sleep( 500 ) ; QUICK ACCESS ; https://www.autoitscript.com/autoit3/docs/functions/MouseClick.htm MouseClick ( "right", 74, 748, 1, 0 ) ; right click windows explorer shortcut on taskbar to open context menu Sleep( 250 ) send("{PGDN}") ; expose the most pinned items Sleep( 250 ) send("{down}") ; expose the most pinned items $ZDIR=@homeDrive & "\Users\Default\Desktop\UPDATE" ;where does the screenshot go $ZNAME="\quick-access.jpg" ;what will its name be $ZTOPX=0 $ZTOPY=0 $ZBOTTOMX=250 $ZBOTTOMY=615 Sleep( 500 ) ScreenShot() ; Sleep( 2000 ) MouseClick ( "left", 74, 748, 1, 0 ) ; left click windows explorer shortcut on taskbar to close context menu send( "#d" ) ; show desktop ; exit ; START MENU Sleep( 500 ) send("{LWIN}") ;OPEN START MENU $ZDIR=@tempDir ;where does the screenshot go $ZNAME="\start-menu1.jpg" ;what will its name be $ZTOPX=315 $ZTOPY=139 $ZBOTTOMX=1285 $ZBOTTOMY=660 Sleep( 1250 ) ScreenShot() ; BEGIN WEAK POINT send("{tab}"); COMBINING TABS BREAKS SCRIPT Sleep( 120 ) send("{tab}") Sleep( 120 ) send("{tab}") Sleep( 500 ) send("{down 8}"); move to the bottom of the start menu to take the next screenshot. operates on the first column of shortcuts. will only go to the bottom of it. add send("{right}") after the last tab to operate on another column. ; END WEAK POINT ; $ZDIR=@tempDir ;where does the screenshot go $ZNAME="\start-menu2.jpg" ;what will its name be $ZTOPX=315 $ZTOPY=409 $ZBOTTOMX=1285 $ZBOTTOMY=730 Sleep( 125 ) ScreenShot() send("{LWIN}") ; CLOSE THE START MENU ; DESKTOP $ZDIR=@homeDrive & "\Users\Default\Desktop\UPDATE" ;where does the screenshot go $ZNAME="\desktop.jpg" ;what will its name be $ZTOPX=0 $ZTOPY=0 $ZBOTTOMX=-1 $ZBOTTOMY=-1 Sleep( 125 ) ScreenShot() ; BEGIN OPEN DEVICE MANAGER MAXIMIZED ; CHOOSE YOUR POISON Run( @comspec & " /c start devmgmt.msc","", @SW_HIDE) WinWait("Device Manager") WinActivate("Device Manager") WinSetState("Device Manager", "", @SW_MAXIMIZE) ; ; BEGIN SHOOTING THE DEVICE MANAGER THE FOLLOWING WAY REQUIRED: ; 1. IT BE DONE AT THE BEGINNING OF THE SCRIPT. ; 2. MORE WORK TO FIND THE COORDINATES: ; https://www.autoitscript.com/forum/topic/165325-how-to-get-4-screen-coordinates-just-by-dragging-a-rectangle/?do=findComment&comment=1206830 ; modified and saved as "C:\Program Files (x86)\AutoIt3\Include\Coordinates.au3" ; download Coordinates.au3 https://www.autoitscript.com/forum/topic/196256-screenshot-win10-desktop-quick-access-device-manager-start-menu-automated-shots-stacked-or-side-by-side-requires-admin/ ; Run("control /name Microsoft.DeviceManager") ; script must be run with admin privileges ; WinWaitActive("Device Manager") ; $WinHndl = WinGetHandle("Device Manager") ; WinMove($WinHndl,"",-4,0,@DesktopWidth+10,@DesktopHeight) ; MAKE ADJUSTMENTS HERE ; #include <Coordinates.au3> ; END SHOOTING THE DEVICE MANAGER THE FOLLOWING WAY REQUIRED: ; ; Run("mmc devmgmt.msc") ; WinActivate ( "Device Manager", "" ) ; Sleep( 125 ) ; WinSetState("[ACTIVE]", "", @SW_MAXIMIZE) ; Sleep( 125 ) ; WinSetState("Device Manager", "", @SW_MAXIMIZE) ; END OPEN DEVICE MANAGER MAXIMIZED Sleep( 1000 ) Send("{TAB}") Sleep( 250 ) send("{down 4}") Sleep( 250 ) send("{right}") ;DISK DRIVES Sleep( 250 ) send("{down2}") Sleep( 250 ) send("{right}") ;DISPLAY ADAPTERS Sleep( 250 ) send("{down 5}") Sleep( 250 ) send("{right}") ;IDE ATA/ATAPI CONTROLLERS Sleep( 250 ) send("{down 6}") Sleep( 250 ) send("{right}") ;NETWORK ADAPTERS $ZDIR=@tempDir ;where does the screenshot go $ZNAME="\device-manager1.jpg" ;what will its name be $ZTOPX=2 $ZTOPY=77 $ZBOTTOMX=272 $ZBOTTOMY=382 Sleep( 250 ) ScreenShot() send("{down 15}") Sleep( 250 ) send("{right}") ;SOUND, VIDEO, AND GAME CONTROLLERS Sleep( 250 ) send("{down 7}") ;MOVES NETWORK ADAPTERS TO THE $ZTOPY=273 POSITION $ZDIR=@tempDir ;where does the screenshot go $ZNAME="\device-manager2.jpg" ;what will its name be $ZTOPX=2 $ZTOPY=273 $ZBOTTOMX=272 $ZBOTTOMY=638 Sleep( 250 ) ScreenShot() Sleep( 1000 ) ; https://www.autoitscript.com/forum/topic/196256-screenshot-win10-desktop-quick-access-device-manager-start-menu-automated-shots-stacked-or-side-by-side-requires-admin//?do=findComment&comment=1407181 ; credit for the screenshot scrolling code goes to monoscout999 ; screenshot of everything in the device manager $outputFile = @HomeDrive&"\Users\Default\Desktop\UPDATE\device-manager2.jpg" ;get a handle of things $WinHndl = WinGetHandle("Device Manager") $Treeview = ControlGetHandle("Device Manager","","[Class:SysTreeView32]") ;expand the treeview control _GUICtrlTreeView_Expand($Treeview) MouseMove(300,200) MouseWheel("up",100) Sleep(250) ;Get Edit1 Vertical Scroll Min/Max range and page size. $aScrollRange = _GUIScrollBars_GetScrollRange($Treeview, $SB_VERT) $iPageSize = _GUIScrollBars_GetScrollInfoPage($Treeview, $SB_VERT) $iPages = Round($aScrollRange[1] / $iPageSize) ;get treeview control size $aTreeviewPos = ControlGetPos($WinHndl,"",$Treeview) ;Capture $scrollBarSize = 20 $hDC = _winapi_GetDC($Treeview) $hCDC = _WinAPI_CreateCompatibleDC($hDC) $hBMP = _WinAPI_CreateCompatibleBitmap($hDC, $aTreeviewPos[2] - $scrollBarSize , ($aTreeviewPos[3] * ($iPages +1 ))) _WinAPI_SelectObject($hCDC, $hBMP) For $i = 0 to $iPages+1 _WinAPI_BitBlt($hCDC, 0, $aTreeviewPos[3] * $i, $aTreeviewPos[2] - $scrollBarSize , ($aTreeviewPos[3] ), $hDC,0, 0, $SRCCOPY) _WinAPI_PostMessage($Treeview,$WM_VSCROLL,$SB_PAGEDOWN,0) Sleep(250) Next _WinAPI_ReleaseDC($Treeview, $hDC) _WinAPI_DeleteDC($hCDC) _GDIPlus_Startup() $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBMP) _GDIPlus_ImageSaveToFile($hImage, $outputFile) _GDIPlus_Shutdown() _WinAPI_DeleteObject($hBMP) ; If FileExists($outputFile) Then ShellExecute($outputFile) Sleep( 1000 ) ProcessClose ( "mmc.exe" ) ; close the device manager. THIS MIGHT BE WEAK. ; MouseMove ( 1150, 650) ; TO START, SECURE, SHUTDOWN SHORTCUT Sleep( 1000 ) ;; END CAPTURE ;; BEGIN JOIN IMAGES #include <GDIPlus.au3> #include <WinAPISysWin.au3> ; FULLY QUALIFIED PATH NAME (FQPN) TO FIRST IMAGE, FQPN TO SECOND IMAGE, FQPN TO COMBINED IMAGE ; _BMPJoin(@tempDir & "\start-menu1.jpg", @tempDir & "\start-menu2.jpg", @homeDrive & "\Users\Default\Desktop\UPDATE\start-menu.jpg", "right") ; SIDE-BY-SIDE ; _BMPJoin(@tempDir & "\device-manager1.jpg", @tempDir & "\device-manager2.jpg", @homeDrive & "\Users\Default\Desktop\UPDATE\device-manager.jpg", "") ; STACKED _BMPJoin(@tempDir & "\start-menu1.jpg", @tempDir & "\start-menu2.jpg", @homeDrive & "\Users\Default\Desktop\UPDATE\start-menu.jpg", "") _BMPJoin(@tempDir & "\device-manager1.jpg", @tempDir & "\device-manager2.jpg", @homeDrive & "\Users\Default\Desktop\UPDATE\device-manager.jpg", "") ;; END JOIN IMAGES Exit ; END OF SCRIPT ;; BEGIN SCREENSHOT FUNCTION Func ScreenShot() ; Capture full screen _ScreenCapture_Capture($ZDIR & $ZNAME, $ZTOPX, $ZTOPY, $ZBOTTOMX, $ZBOTTOMY) EndFunc ;==>ScreenShot ; https://www.autoitscript.com/autoit3/docs/libfunctions/_ScreenCapture_Capture.htm ; $iLeft [optional] X coordinate of the upper left corner of the rectangle ; $iTop [optional] Y coordinate of the upper left corner of the rectangle ; $iRight [optional] X coordinate of the lower right corner of the rectangle. If this is -1, the current screen width will be used. ; $iBottom [optional] Y coordinate of the lower right corner of the rectangle. If this is -1, the current screen height will be used. ;; END SCREENSHOT FUNCTION ;; BEGIN JOIN IMAGES FUNCTION ; https://www.autoitscript.com/forum/topic/80896-join-two-bitmap-images/ Func _BMPJoin($sFile1, $sFile2, $sResult, $Position) Local $hSourceIMG1, $hSourceIMG2, $iWidth1, $width2, $iHeight1, $iHeight2, $hBitmap, $hImage, $hGraphics Local $iBwidth, $iBheight If Not FileExists(StringRegExpReplace($sResult, "(^.*)\\.*", "\1")) Then $sResult = @ScriptDir & "\result.bmp" _GDIPlus_Startup() $hSourceIMG1 = _GDIPlus_ImageLoadFromFile($sFile1) $hSourceIMG2 = _GDIPlus_ImageLoadFromFile($sFile2) $iWidth1 = _GDIPlus_ImageGetWidth($hSourceIMG1) $iHeight1 = _GDIPlus_ImageGetHeight($hSourceIMG1) $iWidth2 = _GDIPlus_ImageGetWidth($hSourceIMG2) $iHeight2 = _GDIPlus_ImageGetHeight($hSourceIMG2) If $Position = "right" Then $iBwidth = $iWidth1 + $iWidth2 $iBheight = $iHeight1 if $iHeight2 > $iHeight1 then $iBheight = $iHeight2 ; WORK NEEDS TO BE DONE TO ELIMINATE THE BLACK BAR WHEN THE SHOTS ARE NOT THE SIZE HEIGHT AND ARE BEING DISPLAYED SIDE-BY-SIDE. Else;position = "below" $iBwidth = $iWidth1 if $iWidth2 > $iWidth1 then $iBwidth = $iWidth2 $iBheight = $iHeight1 + $iHeight2 EndIf $hBitmap = _CreateBMP($iBwidth, $iBheight) $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap) $hGraphics = _GDIPlus_ImageGetGraphicsContext($hImage) ; https://www.autoitscript.com/autoit3/docs/libfunctions/_GDIPlus_GraphicsDrawImageRectRect.htm _GDIPlus_GraphicsDrawImageRectRect($hGraphics, $hSourceIMG1, 0, 0, $iWidth1, $iHeight1, 0, 0, $iWidth1, $iHeight1) If $Position = "right" Then _GDIPlus_GraphicsDrawImageRectRect($hGraphics, $hSourceIMG2, 0, 0, $iWidth2, $iHeight2, $iWidth1, 0, $iWidth2, $iHeight2) Else _GDIPlus_GraphicsDrawImageRectRect($hGraphics, $hSourceIMG2, 0, 0, $iWidth2, $iHeight2, 0, $iHeight1, $iWidth2, $iHeight2) EndIf _GDIPlus_ImageSaveToFile($hImage, $sResult) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteObject($hImage) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_ImageDispose($hSourceIMG1) _GDIPlus_ImageDispose($hSourceIMG2) _GDIPlus_Shutdown() EndFunc ;==>_BMPJoin Func _CreateBMP($sWidth, $sHeight) Local $hWnd, $hDC, $hBMP $hWnd = _WinAPI_GetDesktopWindow() $hDC = _WinAPI_GetDC($hWnd) $hBMP = _WinAPI_CreateCompatibleBitmap($hDC, $sWidth, $sHeight) _WinAPI_ReleaseDC($hWnd, $hDC) Return $hBMP EndFunc ;==>_CreateBMP ;; END JOIN IMAGES FUNCTION SCRIPT TWO:
      ;; AUTOIT3 v3.3.14.5 SCRIPT ;; PURPOSE: ; WRITE AN AUTOIT3 SCRIPT THAT WHEN RUN IN A WINDOWS SCHEDULED TASK WILL PRODUCE A SCREENSHOT OF THE WINDOWS 10 DESKTOP, START MENU, QUICK ACCESS MENU, AND DEVICE MANAGER WITHOUT INTERACTION. ;; SEE https://www.autoitscript.com/forum/topic/196256-screenshot-win10-desktop-quick-access-device-manager-start-menu-automated-shots-stacked-or-side-by-side-requires-admin/ ;; MUST BE RUN WITH ADMIN PRIVILEDGES. NOT ROBUST YET. ;; DOWNLOAD COORDINATES.AU3 https://www.autoitscript.com/forum/topic/196256-screenshot-win10-desktop-quick-access-device-manager-start-menu-automated-shots-stacked-or-side-by-side-requires-admin/ ;; SCREENSHOT WIN10 DESKTOP, QUICK ACCESS, DEVICE MANAGER AND START MENU. ;; MULTIPLE SHOTS JOINED STACKED, SIDE-BY-SIDE, OR NEITHER. SEE SIDE-BY-SIDE ;; WORK NEEDS TO BE DONE TO ELIMINATE THE BLACK BAR WHEN THE SHOTS ARE NOT THE SAME HEIGHT AND ARE BEING DISPLAYED SIDE-BY-SIDE. ;; MY GUESS THE EASIEST THING TO DO WOULD BE TO TURN IT WHITE. ;; YOU WILL HAVE TO TELL IT WHERE YOUR TASKBAR EXPLORER SHORTCUT IS. SEE MouseClick ( "right", 74, 748, 1, 0) ;; YOU WILL HAVE TO TELL IT WHERE TO PROCESS AND MOVE THE SHOTS. SEE MULTIPLE OF $ZDIR, $ZNAME, FQPN SEE $outputFile ;; IMPROVEMENTS ARE WELCOMED ;; FIND LIST OF ENVIRONMENT VARIABLES NAMES ;; AUTOIT3 HELP File ;; "C:\Program Files (x86)\AutoIt3\AutoIt.chm" ;; SEARCH FOR MACRO REFERENCE AND MACRO REFERENCE - DIRECTORY ;; THANKS TO RASIM, MARTIN, AND BOOMINGRANNY AT AUTOITSCRIPT.COM ; https://www.autoitscript.com/forum/topic/80896-join-two-bitmap-images/ ; https://www.autoitscript.com/forum/topic/80896-join-two-bitmap-images/?do=findComment&comment=581214 ; https://www.autoitscript.com/forum/topic/80896-join-two-bitmap-images/?do=findComment&comment=581372 ; https://www.autoitscript.com/forum/topic/196256-screenshot-win10-desktop-quick-access-device-manager-start-menu-automated-shots-stacked-or-side-by-side-requires-admin/ ; https://www.autoitscript.com/forum/topic/196256-screenshot-win10-desktop-quick-access-device-manager-start-menu-automated-shots-stacked-or-side-by-side-requires-admin//?do=findComment&comment=1407181 ;; "C:\Program Files (x86)\AutoIt3\AutoIt3_x64.exe" "F:\MYAPPS\WINDOWS\screenshots9.au3" ;; Screenshot Win10 desktop, quick access, device manager, start menu. Shots stacked or side-by-side. Admin privileges. Not robust. ; BEGIN CAPTURE ; https://www.autoitscript.com/forum/topic/8377-capture-screen-dll/ ; Capture full screen ; Fist parameter - filename, last - jpeg quality. #include <ScreenCapture.au3> send("#d") ; show desktop ;DEVICE MANAGER ;STARTING THE DEVICE MANAGER THIS WAY REQUIRED: ; 1. IT BE DONE AT THE BEGINNING OF THE SCRIPT. ; 2. MORE WORK TO FIND THE COORDINATES: ; https://www.autoitscript.com/forum/topic/165325-how-to-get-4-screen-coordinates-just-by-dragging-a-rectangle/?do=findComment&comment=1206830 ; modified and saved as "C:\Program Files (x86)\AutoIt3\Include\Coordinates.au3" ; download Coordinates.au3 https://www.autoitscript.com/forum/topic/196256-screenshot-win10-desktop-quick-access-device-manager-start-menu-automated-shots-stacked-or-side-by-side-requires-admin/ Run("control /name Microsoft.DeviceManager") WinWaitActive("Device Manager") $WinHndl = WinGetHandle("Device Manager") WinMove($WinHndl,"",-4,0,@DesktopWidth+10,@DesktopHeight) ; MAKE ADJUSTMENTS HERE IF NECESSARY Sleep( 1000 ) Send("{TAB}") Sleep( 125 ) send("{down 4}") Sleep( 125 ) send("{right}") Sleep( 125 ) send("{down2}") Sleep( 125 ) send("{right}") Sleep( 125 ) send("{down 5}") Sleep( 125 ) send("{right}") Sleep( 500 ) send("{down 5}") Sleep( 500 ) send("{right}") Sleep( 125 ) send("{down 14}") Sleep( 125 ) send("{right}") Sleep( 125 ) send("{down 7}") Sleep ( 120 ) $ZDIR=@tempDir ;where does the screenshot go $ZNAME="\device-manager1.jpg" ;what will its name be $ZTOPX=24 $ZTOPY=84 $ZBOTTOMX=277 $ZBOTTOMY=374 #include <Coordinates.au3>; finds incorrect coordinates. They are shifted down ~50px. Does not work on menus exposed by right clicking or the start menu ScreenShot () ; exit $ZDIR=@tempDir ;where does the screenshot go $ZNAME="\device-manager2.jpg" ;what will its name be $ZTOPX=24 $ZTOPY=374 $ZBOTTOMX=277 $ZBOTTOMY=716 #include <Coordinates.au3>; finds incorrect coordinates. They are shifted down ~50px. Does not work on menus exposed by right clicking or the start menu ScreenShot() Sleep( 500 ) ProcessClose ( "mmc.exe" ) ; close the device manager ; QUICK ACCESS ; https://www.autoitscript.com/autoit3/docs/functions/MouseClick.htm MouseClick ( "right", 74, 748, 1, 0) ; right click windows explorer shortcut on taskbar. Sleep( 1200 ) send("{up}") ; SCRIPT MORE RELIABLE IF UPs ARE NOT COMBINED Sleep( 120 ) send("{up}") Sleep( 120 ) send("{up}") Sleep( 120 ) send("{up}") Sleep( 120 ) send("{down}") Sleep (1200) $ZDIR=@homeDrive & "\Users\Default\Desktop\UPDATE" ;where does the screenshot go $ZNAME="\quick-access.jpg" ;what will its name be $ZTOPX=0 $ZTOPY=0 $ZBOTTOMX=251 $ZBOTTOMY=615 #include <Coordinates.au3>; finds incorrect coordinates. They are shifted down ~50px. Does not work on menus exposed by right clicking or the start menu ScreenShot() Sleep ( 250 ) ; START MENU send("{LWIN}") ;OPEN START MENU Sleep ( 250 ) $ZDIR=@tempDir ;where does the screenshot go $ZNAME="\start-menu1.jpg" ;what will its name be $ZTOPX=315 $ZTOPY=139 $ZBOTTOMX=1285 $ZBOTTOMY=660 #include <Coordinates.au3>; finds incorrect coordinates. They are shifted down ~50px. Does not work on menus exposed by right clicking or the start menu ScreenShot() ; BEGIN WEAK POINT send("{tab}"); COMBINING TABS BREAKS SCRIPT Sleep ( 240 ) send("{tab}") Sleep ( 240 ) send("{tab}") Sleep ( 500 ) send("{down 8}"); move to the bottom of the start menu to take the next screenshot. operates on the first column of shortcuts. will only go to the bottom of it. add send("{right}") after the last tab to operate on another column. Sleep ( 1000 ) ; END WEAK POINT ; $ZDIR=@tempDir ;where does the screenshot go $ZNAME="\start-menu2.jpg" ;what will its name be $ZTOPX=315 $ZTOPY=409 $ZBOTTOMX=1285 $ZBOTTOMY=730 #include <Coordinates.au3>; finds incorrect coordinates. They are shifted down ~50px. Does not work on menus exposed by right clicking or the start menu ScreenShot() Sleep ( 120 ) send("{LWIN}") ; CLOSE THE START MENU Sleep ( 120 ) ; DESKTOP $ZDIR=@homeDrive & "\Users\Default\Desktop\UPDATE" ;where does the screenshot go $ZNAME="\desktop.jpg" ;what will its name be $ZTOPX=0 $ZTOPY=0 $ZBOTTOMX=-1 $ZBOTTOMY=-1 ScreenShot() sleep (500) ;; END CAPTURE ;; BEGIN JOIN IMAGES #include <GDIPlus.au3> #include <WinAPISysWin.au3> ; FULLY QUALIFIED PATH NAME (FQPN) TO FIRST IMAGE, FQPN TO SECOND IMAGE, FQPN TO COMBINED IMAGE ; _BMPJoin(@tempDir & "\start-menu1.jpg", @tempDir & "\start-menu2.jpg", @homeDrive & "\Users\Default\Desktop\UPDATE\start-menu.jpg", "right") ; SIDE-BY-SIDE ; _BMPJoin(@tempDir & "\device-manager1.jpg", @tempDir & "\device-manager2.jpg", @homeDrive & "\Users\Default\Desktop\UPDATE\device-manager.jpg", "") ; STACKED _BMPJoin(@tempDir & "\start-menu1.jpg", @tempDir & "\start-menu2.jpg", @homeDrive & "\Users\Default\Desktop\UPDATE\start-menu.jpg", "") _BMPJoin(@tempDir & "\device-manager1.jpg", @tempDir & "\device-manager2.jpg", @homeDrive & "\Users\Default\Desktop\UPDATE\device-manager.jpg", "") ;; END JOIN IMAGES Exit ; END OF SCRIPT ;; BEGIN SCREENSHOT FUNCTION Func ScreenShot() ; Capture full screen _ScreenCapture_Capture($ZDIR & $ZNAME, $ZTOPX, $ZTOPY, $ZBOTTOMX, $ZBOTTOMY) EndFunc ;==>ScreenShot ; https://www.autoitscript.com/autoit3/docs/libfunctions/_ScreenCapture_Capture.htm ; $iLeft [optional] X coordinate of the upper left corner of the rectangle ; $iTop [optional] Y coordinate of the upper left corner of the rectangle ; $iRight [optional] X coordinate of the lower right corner of the rectangle. If this is -1, the current screen width will be used. ; $iBottom [optional] Y coordinate of the lower right corner of the rectangle. If this is -1, the current screen height will be used. ;; END SCREENSHOT FUNCTION ;; BEGIN JOIN IMAGES FUNCTION ; https://www.autoitscript.com/forum/topic/80896-join-two-bitmap-images/ Func _BMPJoin($sFile1, $sFile2, $sResult, $Position) Local $hSourceIMG1, $hSourceIMG2, $iWidth1, $width2, $iHeight1, $iHeight2, $hBitmap, $hImage, $hGraphics Local $iBwidth, $iBheight If Not FileExists(StringRegExpReplace($sResult, "(^.*)\\.*", "\1")) Then $sResult = @ScriptDir & "\result.bmp" _GDIPlus_Startup() $hSourceIMG1 = _GDIPlus_ImageLoadFromFile($sFile1) $hSourceIMG2 = _GDIPlus_ImageLoadFromFile($sFile2) $iWidth1 = _GDIPlus_ImageGetWidth($hSourceIMG1) $iHeight1 = _GDIPlus_ImageGetHeight($hSourceIMG1) $iWidth2 = _GDIPlus_ImageGetWidth($hSourceIMG2) $iHeight2 = _GDIPlus_ImageGetHeight($hSourceIMG2) If $Position = "right" Then $iBwidth = $iWidth1 + $iWidth2 $iBheight = $iHeight1 if $iHeight2 > $iHeight1 then $iBheight = $iHeight2 ; WORK NEEDS TO BE DONE TO ELIMINATE THE BLACK BAR WHEN THE SHOTS ARE NOT THE SIZE HEIGHT AND ARE BEING DISPLAYED SIDE-BY-SIDE. Else;position = "below" $iBwidth = $iWidth1 if $iWidth2 > $iWidth1 then $iBwidth = $iWidth2 $iBheight = $iHeight1 + $iHeight2 EndIf $hBitmap = _CreateBMP($iBwidth, $iBheight) $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap) $hGraphics = _GDIPlus_ImageGetGraphicsContext($hImage) ; https://www.autoitscript.com/autoit3/docs/libfunctions/_GDIPlus_GraphicsDrawImageRectRect.htm _GDIPlus_GraphicsDrawImageRectRect($hGraphics, $hSourceIMG1, 0, 0, $iWidth1, $iHeight1, 0, 0, $iWidth1, $iHeight1) If $Position = "right" Then _GDIPlus_GraphicsDrawImageRectRect($hGraphics, $hSourceIMG2, 0, 0, $iWidth2, $iHeight2, $iWidth1, 0, $iWidth2, $iHeight2) Else _GDIPlus_GraphicsDrawImageRectRect($hGraphics, $hSourceIMG2, 0, 0, $iWidth2, $iHeight2, 0, $iHeight1, $iWidth2, $iHeight2) EndIf _GDIPlus_ImageSaveToFile($hImage, $sResult) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteObject($hImage) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_ImageDispose($hSourceIMG1) _GDIPlus_ImageDispose($hSourceIMG2) _GDIPlus_Shutdown() EndFunc ;==>_BMPJoin Func _CreateBMP($sWidth, $sHeight) Local $hWnd, $hDC, $hBMP $hWnd = _WinAPI_GetDesktopWindow() $hDC = _WinAPI_GetDC($hWnd) $hBMP = _WinAPI_CreateCompatibleBitmap($hDC, $sWidth, $sHeight) _WinAPI_ReleaseDC($hWnd, $hDC) Return $hBMP EndFunc ;==>_CreateBMP ;; END JOIN IMAGES FUNCTION ;; BEGIN COORDINATES FUNCTION ;; END COORDINATES FUNCTION
      KEYWORDS: RIGHT CLICK EXPLORER SHORTCUT PINNED TO TASKBAR PINNED TO QUICK ACCESS PIN TO QUICK ACCESS PIN TO EXPLORER PINNED TO EXPLORER
       
       
    • caramen
      By caramen
      I watched _OL_ItemSend&_OL_ItemFind&_OL_ItemCreate in OutlookEx UDF but hmmm
       
      Since it use the test environnement i cant get the orders of the mail creation
       
      Can someone make me win some time of reading all exemples script and lead me how to do one ?
      That whould be lovely.
      Gnight
    • Tersion
      By Tersion
      Here the this wiki page with list of available UDFs for data compression. For my tasks I only need ZIP support, so I started looking at pure AutoIt UDFs without any 3rd party dlls. And found out that most of available realizations uses standard ("native method") Windows dll - "zipfldr.dll". So for now I chose ZIP UDF by wraithdu. I've tested it on Windows 7 (x64) and it seem works fine. But here the comment from another topic where user says that Windows 10 discontinued support of "zipfldr.dll". Now I confused. I don't have around any Windows 10 machine to tested it. So maybe someone could confirm or deny that? Or maybe would better to switch to UDF with 7zip dll?
      I need an advice...
    • TheSaint
      By TheSaint
      Here is the bare bones of a UDF I have started work on.
      Mostly just a proof of concept at this stage, and still need to add some functions and dress the UDF up a bit ... to look like a UDF ... though it has my own distinct styling, especially as I have never really developed a UDF before now .... used plenty and modified plenty though. I've even invented my own UDF variable naming convention, which I am sure some of you will be aghast at. I work with what feels best for me, but others are free to adapt if they wish.
      The idea is to emulate the simplicity of INI files, but gain the benefits of SQL.
      Two scripts are provided.
      (1) The UDF, a work in progress - SimpleSQL_UDF.au3
      (2) An example or testing script - UDF_Test.au3
      Another first for me, is creating a 2D array from scratch, never done that before, that I can recall ... never had a need, and even for 1 dimension arrays, for a long time now, I have just used _StringSplit to create them. So I needed a bit of a refresher course, which my good buddy @TheDcoder assisted me with ... not without some angst I might add. LOL
      SimpleSQL_UDF.zip  (12 downloads previously)
      (I have now completed all the functions I intended to. My next update will be a big improvement, bringing things more inline with my latest INItoSQL DB program changes.)
      Program requires the sqlite3.dll, not included, but easily enough obtained.
      Hopefully the usage is self-evident ... just change the Job number variable in the UDF_Test.au3 file to check the existing functions out.
      Enjoy!
      P.S. This is also related to a new program I have just finished and uploaded - INItoSQL DB
    • jacobestepp
      By jacobestepp
      I am Very new to Autoit and I'm trying to figure out how to input text in an administrator Level Command prompt on windows 10. this is what I currently have
      Send ("#r") WinWaitActive("Run") Send("runas /user:Administrator cmd") Send("{Enter}") WinWait("C:\WINDOWS\system32\runas.exe") ControlClick("", "", "[CLASS:ConsoleWindowClass]") Send("test-Password") Send("{Enter}") The issue I am having is I can not send the "test-password" to the command prompt.  I cried adding the ControlClick command to place the cursor in he CMD box, but its still not working. What am I doing wrong?
×