Sign in to follow this  
Followers 0

Using AutoIt to install and update a software automatically

9 posts in this topic

Posted (edited)

Hi all, I'm newbie and have learnt much from here. Thank Autoit Forums' members!

Today I would like to share some scripts I've made. Your reply and feedback are always welcome.

:oops:

Part 1 - Install AutoIt and make some settings with a click

Introduction

The installation software typically consumes a lot of time for someone who regularly tests, sets preferences, uses the software (like me :bye:).

I'd like to discuss in this topic only use it to manipulate instead of mouse clicks and keystrokes when installing a commonly used software. This is especially beneficial for those time-consuming software installation and operation. Only one mouse click or ENTER press and wait, you'll have a ready software installed on your system.

A script example

I'm starting with the script of just installing AutoIt (for the first time we open this script to refer and convert exe to run for the next time).

Required files:

autoit-v3-setup.exe to install the main program

and

SciTE4AutoIt3.exe to install a professional program editor (additional tools and settings attached).

Viewable process

;~ #include <PPCC.au3>

Func _AU3RecordSetup()
    Opt('WinWaitDelay',100)
    Opt('WinDetectHiddenText',1)
    Opt('MouseCoordMode',0)
EndFunc

Func _WinWaitActivate($title,$text,$timeout=0)
    WinWait($title,$text,$timeout)
    If Not WinActive($title,$text) Then WinActivate($title,$text)
    WinWaitActive($title,$text,$timeout)
EndFunc

_AU3RecordSetup()

; Setup
If Not FileExists($AutoIt_file) Then
    RunWait("D:Applied TipsAutoItSetup AIOInstallScript_Silent.exe")
EndIf ;~ If Not FileExists(@ProgramFilesDir & 'AutoIt3AutoIt3.exe') Then Run('D:Applied TipsAutoItSetup AIOInstallScript_Silent.exe')

; Settings
ShellExecute(@ProgramFilesDir & 'AutoIt3SciTESciTEConfigSciteConfig.exe')
_WinWaitActivate("SciTE Config for AutoIt3. ver:","")
Send("{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}")
Send("D:Applied TipsAutoItMy Most Used Functions")
Send("{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{SPACE}")
_WinWaitActivate("SciTE config","")
Send("{ENTER}")
_WinWaitActivate("SciTE Config for AutoIt3. ver:","")
Send("{TAB}{SPACE}")

Silent process

... building

InstallScript_Silent.exe was converted from InstallScript_Silent.au3 file that are as follows, and placed in the script's directory:

RunWait("autoit-v3-setup.exe /S")
RunWait("SciTE4AutoIt3.exe /S")

Note

- ; settings section is for UDF path change.

- The paths for setup files should be changed as yours.

- Using AU3Recorder tools to help coding.

Next time, I will introduce the script to automatically adjust some settings for the Mouse, Keyboard,... in Control Panel.

Thanks all for reading.

Edited by PPCC

Share this post


Link to post
Share on other sites



Posted (edited)

Hi, PPCC. Not bad, but using Send you're just begging for something to go wrong.

All of the desktop support guys where I used to work used AutoIt, so I simply used Wix to package both AutoIT and the latest full version of SciTe as a single MSI. Makes it very easy to install manually. The same could be said for most any other app :oops:

Edited by JLogan3o13
1 person likes this

Share this post


Link to post
Share on other sites

Posted (edited)

You meaned that using Send is not better than ControlSend/Set..., didn't you. Sure! It's one of the first scripts of mine. It'd be improved.

Also I agree about MSI setup file (included both...) but how's about silent installation by them? I mean that

Run('".......file.msi" /s')

If it's possible, MSI setup file is the best case.

Edited by PPCC

Share this post


Link to post
Share on other sites

Posted

As i understand it Send will always be interruptable by the person on the keyboard which can throw you an error if he is banging away whilst your script is running.

Silent installers are always better because its not waiting for keystrokes

I wouldnt say msi is the best for silent ive automated lots of different types and they all work in different ways

1 person likes this

Share this post


Link to post
Share on other sites

Posted

Hi, PPCC, yes MSIs are standardized to support silent installs (try msiexec /? to see a list of switches you can use). The benefit to these, as well, is the ability to set your global properties via the command line. For example, if I have an install that requires that I accept an EULA, I can do something like this:

msiexec /i "<my product name>.msi" ACCEPT=YES /qn

1 person likes this

Share this post


Link to post
Share on other sites

Posted

@JLogan3o13: Helpful for me. Thanks a lot.

@Chimaera: Thanks. I see, last time I was lazy when using Au3Recorder tool :oops: as you see that just Send and _WinWaitActivate were used. Do you know how to make automatically like Au3Recorder or convert faster Send commands to ControlSend commands?

such as

_WinWaitActivate("SciTE Config for AutoIt3. ver:","")
Send("{TAB 2}")

to

_WinWaitActivate("SciTE Config for AutoIt3. ver:","")
ControlSend("SciTE Config for AutoIt3. ver:","",$ID,"{TAB 2}")

Share this post


Link to post
Share on other sites

Posted (edited)

Everything is governed by the pc your running on, not sure how you think you will speed up Send it will run as fast as it runs.

You already answered in this thread that the normal silent install worked for you

So you know it can be done the other way ie /S

Edited by Chimaera
1 person likes this

Share this post


Link to post
Share on other sites

Posted (edited)

I see but sometimes we need control a program or a task (click and type) that are running or set some options for example, so we cannot use Run or Shellexecute... with /s or normally silent running.

Let me show another example, this time also use Send command to viewable, I made it as soon as script in the part 1 (in post 1)

Part 2 - The script to automatically adjust some settings for the Auto Play, Keyboard,... in Control Panel

I made ​​it to run in Windows 7 (Win7). For other tools of the Control Panel as well for tools in Windows XP, you can change the open command in a different tool, refer to this website:

http://pcsupport.about.com/od/tipstricks/a/control-panel-command-line.htm

These settings are my own, you should only refer to self-adjust or record your own settings by Au3Recorder slightly and replace something like Send to ControlSend/SetText. You can adjust how much you are familiar in some panel.

Turn off Auto Play in Win7

;~ #include <PPCC.au3>

_AU3RecordSetup()

Run('control /name Microsoft.AutoPlay')
_WinWaitActivate("AutoPlay","Address: Control Pan")
Sleep(500)
Send("{-}")
Sleep(500)
Send("{ALTDOWN}s{ALTUP}")

Change of the keyboard setting

;~ #include <PPCC.au3>
_AU3RecordSetup()
Run('control /name Microsoft.Mouse')
_WinWaitActivate("Mouse Properties","Button configuration")
Send("{CTRLDOWN}{TAB}{CTRLUP}")
_WinWaitActivate("Mouse Properties","&Enable pointer shad")
Send("{CTRLDOWN}{TAB}{CTRLUP}")
_WinWaitActivate("Mouse Properties","Sele&ct a pointer sp")
Send("{RIGHT 50}{LEFT 2}{CTRLDOWN}{TAB}{CTRLUP}")
_WinWaitActivate("Mouse Properties","Roll the wheel one n")
Send("{TAB}5{TAB}{CTRLDOWN}{TAB}{CTRLUP}")
_WinWaitActivate("Mouse Properties","Device Properties")
Send("{CTRLDOWN}{TAB}{CTRLUP}")
_WinWaitActivate("Mouse Properties","Synaptics Pointing D")
Send("{ALTDOWN}a{ALTUP}{ALTDOWN}{F4}{ALTUP}")
Sleep(2000)

Turn off Auto Update of Windows 7 and run once again before close

;~ #include <PPCC.au3>

_AU3RecordSetup()

; Disable autoupdate
Run('control /name Microsoft.WindowsUpdate')
_WinWaitActivate("Windows Update","Address: Control Pan")
; MouseClick("left",91,144,1)
ControlClick("Windows Update","Address: Control Pan","[CLASS:DirectUIHWND; INSTANCE:3]","primary",1,67,86)
ControlSend("Windows Update","Address: Control Pan","[CLASS:DirectUIHWND; INSTANCE:3]","{ENTER}");~ Send("{ENTER}")
_WinWaitActivate("Change settings","Address: Control Pan")
Send("{ALTDOWN}i{ALTUP}n{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{ENTER}")
_WinWaitActivate("Windows Update","Address: Control Pan")
Send("{ALTDOWN}{F4}{ALTUP}")

; Run update now
Run('control /name Microsoft.WindowsUpdate')
_WinWaitActivate("Windows Update","Address: Control Pan")
ControlClick("Windows Update","Address: Control Pan","[CLASS:DirectUIHWND; INSTANCE:3]","primary",1,57,59)
ControlSend("Windows Update","Address: Control Pan","[CLASS:DirectUIHWND; INSTANCE:3]","{ENTER}");~ Send("{ENTER}")
If WinActive("Windows Update","cannot currently") Then
    Send("{ENTER}")
EndIf
While 1
    _WinWaitActivate("Windows Update","Address: Control Pan")
    If WinActive("Windows Update","&Install now") Then
        ControlClick("Windows Update","Address: Control Pan","[CLASS:Button; INSTANCE:1]","primary",1)
        ExitLoop
    EndIf
    Sleep(30000)
WEnd
While 1
    _WinWaitActivate("Windows Update","Address: Control Pan")
    If WinActive("Windows Update","&Restart now") Then
        Send("{ALTDOWN}{F4}{ALTUP}")
        ExitLoop
    EndIf
    Sleep(30000)
WEnd

Next part:

Automatically find, download and install the latest version of a software

Edited by PPCC

Share this post


Link to post
Share on other sites

Posted

Part 3 - Automatically find, download and install the latest version of a software

An instance as follows is Gom Player...

#include <PPCC.au3>
_AU3RecordSetup()
;~ WinMinimizeAll()
$msgb=MsgBoxDJS(4+32+256,'GOM Media Player Setup','Would you like to download newest version?' & @LF & 'Automatic choose No after',5)
;~ ConsoleWrite($msgb)
;~ Exit
$SavedPath="D:setupmultimedia toolsgom player"
If $msgb=7 Or $msgb=-1 Then
$Found=_GetFileName($SavedPath,".exe",'SETUP.EXE')
Run($SavedPath & '' & $Found)
Sleep(3000)
_WinWaitActivate("GOM Player Setup","Welcome to the GOM P")
Send("{ALTDOWN}n{ALTUP}")
_WinWaitActivate("GOM Player Setup ","Please review the li")
Send("{ALTDOWN}a{ALTUP}")
_WinWaitActivate("GOM Player Setup ","Choose which feature")
Send("{ALTDOWN}n{ALTUP}")
_WinWaitActivate("GOM Player Setup ","Choose Install Locat")
Send("{CTRLDOWN}c{CTRLUP}{CTRLDOWN}{CTRLUP}{CTRLDOWN}{CTRLUP}{HOME}{SHIFTDOWN}{RIGHT}d{SHIFTUP}{HOME}{SHIFTDOWN}{END}{SHIFTUP}{CTRLDOWN}c{CTRLUP}{ALTDOWN}i{ALTUP}")
_WinWaitActivate("GOM Player Setup ","Completing the GOM P")
Send("{ALTDOWN}f{ALTUP}")
_WinWaitActivate("GOM VIDEO CONVERTER","Download and install")
ControlClick("GOM VIDEO CONVERTER","Download and install","[CLASS:Button; INSTANCE:2]")
Exit
Else
$URL0='http://player.gomlab.com/eng/download/'
$TempFile = "_Test.html"
If FileExists(@TempDir & '' & $TempFile) Then
  FileDelete(@TempDir & '' & $TempFile)
  Sleep(2000)
EndIf
_DownloadFile($URL0, @TempDir, $TempFile);~ ShellExecute($URL)
$file=FileOpen(@TempDir & '' & $TempFile)
If $file = -1 Then ; Check if file opened for reading OK
  MsgBox(0, "Error", "Unable to open file.", 5)
  Exit
EndIf
$BeginTag='<a href="/eng/download/'
$EndTag='" onclick="javascript: pageTracker._trackPageview(' & "'/CNET')"
$TempStr=_GetLinkDownload($file,$BeginTag,$EndTag) ;~ ConsoleWrite($TempStr & @CRLF)
FileClose($file)
$URL=$URL0 & $TempStr
ConsoleWrite($URL & @CRLF)
$TempFile = "_Test.html"
If FileExists(@TempDir & '' & $TempFile) Then
  FileDelete(@TempDir & '' & $TempFile)
  Sleep(2000)
EndIf
_DownloadFile($URL, @TempDir, $TempFile);~ ShellExecute($URL)
$file=FileOpen(@TempDir & '' & $TempFile)
If $file = -1 Then ; Check if file opened for reading OK
  MsgBox(0, "Error", "Unable to open file.", 5)
  Exit
EndIf
$BeginTag='<div class="dlLinkWrapper"> <a href="'
$EndTag='"'
$TempStr=_GetLinkDownload($file,$BeginTag,$EndTag) ;~ ConsoleWrite($TempStr & @CRLF)
FileClose($file)
$URL='' & $TempStr
ConsoleWrite($URL & @CRLF)
$TempFile = "_Test.html"
If FileExists(@TempDir & '' & $TempFile) Then
  FileDelete(@TempDir & '' & $TempFile)
  Sleep(2000)
EndIf
_DownloadFile($URL, @TempDir, $TempFile);~ ShellExecute($URL)
$file=FileOpen(@TempDir & '' & $TempFile)
If $file = -1 Then ; Check if file opened for reading OK
  MsgBox(0, "Error", "Unable to open file.")
  Exit
EndIf
$BeginTag='URL=http://software'
$EndTag='.EXE"/>'
$TempStr=_GetLinkDownload($file,$BeginTag,$EndTag) ;~ ConsoleWrite($TempStr & @CRLF)
FileClose($file)
$URL='http://software' & $TempStr & '.EXE'
ConsoleWrite($URL & @CRLF)
$URLSplit=StringSplit($URL,'=')
$FileName=$URLSplit[UBound($URLSplit)-1] ;~
ConsoleWrite($FileName & @CRLF)
If Not FileExists($SavedPath & '' & $FileName) Then _DownloadFile($URL,$SavedPath,$FileName)
Run($SavedPath & '' & $FileName)
Sleep(3000)
_WinWaitActivate("GOM Player Setup","Welcome to the GOM P")
Send("{ALTDOWN}n{ALTUP}")
_WinWaitActivate("GOM Player Setup ","Please review the li")
Send("{ALTDOWN}a{ALTUP}")
_WinWaitActivate("GOM Player Setup ","Choose which feature")
Send("{ALTDOWN}n{ALTUP}")
_WinWaitActivate("GOM Player Setup ","Choose Install Locat")
Send("{CTRLDOWN}c{CTRLUP}{CTRLDOWN}{CTRLUP}{CTRLDOWN}{CTRLUP}{HOME}{SHIFTDOWN}{RIGHT}d{SHIFTUP}{HOME}{SHIFTDOWN}{END}{SHIFTUP}{CTRLDOWN}c{CTRLUP}{ALTDOWN}i{ALTUP}")
_WinWaitActivate("GOM Player Setup ","Completing the GOM P")
Send("{ALTDOWN}f{ALTUP}")
_WinWaitActivate("GOM VIDEO CONVERTER","Download and install")
ControlClick("GOM VIDEO CONVERTER","Download and install","[CLASS:Button; INSTANCE:2]")
EndIf
FileDelete(@DesktopCommonDir & 'GOM Player.lnk')

The functions used in above script was set in the related UDF (named PPCC.au3):

#include-once
#include <String.au3>
#include <Array.au3>
#include <Inet.au3>
#include <File.au3>
#include <WindowsConstants.au3>
#include <GUIToolbar.au3>
#include <WinAPI.au3>
#include <GuiMenu.au3>

HotKeySet("{ESC}", "Script_Close")
Func Script_Close()
Exit
EndFunc

Func _WinCloseAll($WinClass,$text="")
Local $hWC=1
While $hWC=1
  $hWC=WinClose($WinClass,$text) ; such as, "[CLASS:OperaWindowClass]";~   ConsoleWrite($hWC & @LF)
WEnd
EndFunc

; #FUNCTION# ====================================================================================================================
; Name...........: _AU3RecordSetup
; Description ...: Au3 File Record Setup.
; Syntax.........: _AU3RecordSetup()
; ===============================================================================================================================
Func _AU3RecordSetup()
Opt('WinWaitDelay',100)
Opt('WinDetectHiddenText',1)
Opt('MouseCoordMode',0)
EndFunc   ;==>_AU3RecordSetup

; #FUNCTION# ====================================================================================================================
; Name...........: _WinWaitActivate
; Description ...: Activate a opening windows.
; Syntax.........: _WinWaitActivate($title,$text,$timeout=0)
; Parameters ....: $title   - The title of the window to check. See Title special definition.
;                 $text   - The text of the window to check.
;                 $timeout - Timeout in seconds
; Return values .: Success - Returns handle to the requested window.
;                 Failure - Returns 0 if timeout occurred.
; Author ........: AutoIt
; ===============================================================================================================================
Func _WinWaitActivate($title,$text="",$timeout=0)
WinWait($title,$text,$timeout)
If Not WinActive($title,$text) Then WinActivate($title,$text)
WinWaitActive($title,$text,$timeout)
EndFunc   ;==>_WinWaitActivate

Func _DownloadFile($URLToDownload,$SavedPath,$FileName)
Local $hDownload=InetGet($URLToDownload, $SavedPath & '' & $FileName, 1, 1)
Do
  Sleep(250)
Until InetGetInfo($hDownload, 2) ; Check if the download is complete.
InetClose($hDownload) ; Close the handle to release resources.
EndFunc   ;==>_DownloadFile

Func _GetFirstInfoBetweenTags($URL,$BeginTag,$EndTag)
$array=_StringBetween(_INetGetSource($URL),$BeginTag,$EndTag);~  _ArrayDisplay($array, '')
Return $array[0]
EndFunc   ;==>

Func _GetLinkDownload($file,$BeginTag,$EndTag)
While 1 ; Read in lines of text until the EOF is reached
  Local $line=FileReadLine($file)
  If @error=-1 Then
   Return 0
   ExitLoop
  EndIf
  If StringInStr($line,$BeginTag) And StringInStr($line,$EndTag) Then
   $array0=_StringBetween($line,$BeginTag,$EndTag) ;~   ConsoleWrite($line & @CRLF); ConsoleWrite('http:' & $array0[0] & @CRLF)
   Return $array0[0]
  EndIf
WEnd
EndFunc   ;==>

Func _GetLinkMediaFire($file,$BeginTag,$EndTag,$FileTitleTag)
While 1 ; Read in lines of text until the EOF is reached
  Local $line=FileReadLine($file)
  If @error=-1 Then
   Return 0
   ExitLoop
  EndIf
  If StringInStr($line,"http") And StringInStr($line,$BeginTag) And StringInStr($line,$EndTag) And StringInStr($line,$FileTitleTag) Then
   $array0=_StringBetween($line,$BeginTag,$EndTag) ; ConsoleWrite($line & @CRLF); ConsoleWrite('http:' & $array0[0] & @CRLF)
   Return 'http:' & $array0[0]
  EndIf
WEnd
EndFunc

Func _GetFileName($Path,$FileExt,$Character)
Local $FileList=_FileListToArray($Path)
If @error=1 Then
  MsgBox(0,"","No folders found.",10)
  Exit
EndIf
If @error=4 Then
  MsgBox(0,"","No files found.",10)
  Exit
EndIf
Local $sFlag=True
Local $iStart=0;~ ConsoleWrite(UBound($FileList))
$n=UBound($FileList)
Global $SeekFile[$n+1]
$i=0
$SeekFile[$i]=0
$sExt=$FileExt ;".exe"
While $sFlag=True
  Local $iIndex=_ArraySearch($FileList,$sExt,$iStart,0,0,1)
  If @error Then
   $sFlag=False
  Else
   $SeekFile[$i]=$FileList[$iIndex]
   If StringInStr($SeekFile[$i],$Character,1) Then ; 'SETUP.EXE';~   MsgBox(0,"Found needed exe file",'The exe file #' & $i & ': ' & $SeekFile[$i],1)
    $Found=$SeekFile[$i]
   EndIf
   $i=$i+1
  EndIf
  $iStart=$iIndex+1
WEnd
Return $Found
EndFunc

; Manipulate system tray program (right click, choose option).au3
Func Get_Systray_Index($sToolTipTitle)
    ; Find systray handle
    $hSysTray_Handle=ControlGetHandle('[Class:Shell_TrayWnd]', '', '[Class:ToolbarWindow32;Instance:1]')
    If @error Then
        MsgBox(16, "Error", "System tray not found")
        Exit
    EndIf
    ; Get systray item count
    Local $iSystray_ButCount=_GUICtrlToolbar_ButtonCount($hSysTray_Handle)
    If $iSystray_ButCount=0 Then
        MsgBox(16, "Error", "No items found in system tray")
        Exit
    EndIf
    ; Look for wanted tooltip
    For $iSystray_ButtonNumber=0 To $iSystray_ButCount - 1
        If StringInStr(_GUICtrlToolbar_GetButtonText($hSysTray_Handle, $iSystray_ButtonNumber), $sToolTipTitle) <> 0 Then ExitLoop
    Next
    If $iSystray_ButtonNumber=$iSystray_ButCount Then
        Return 0 ; Not found
    Else
        Return $iSystray_ButtonNumber ; Found
    EndIf
EndFunc

Func GetPopUpSelText()
    Local $aPopUp_List=_WinAPI_EnumWindowsPopup()
    Local $hWnd=$aPopUp_List[1][0]
    Local $sClass=$aPopUp_List[1][1]
    If $sClass="#32768" Then ; This is a "standard" Windows API popup menu
        $hMenu=_SendMessage($hWnd, $MN_GETHMENU, 0, 0)
        If _GUICtrlMenu_IsMenu($hMenu) Then
            $iCount=_GUICtrlMenu_GetItemCount($hMenu)
            For $j=0 To $iCount - 1
                If _GUICtrlMenu_GetItemHighlighted($hMenu, $j) Then
                    Return _GUICtrlMenu_GetItemText($hMenu, $j)
                EndIf
            Next
        EndIf
    EndIf
    Return ""
EndFunc
; #FUNCTION# ====================================================================================================================
; Name...........: _Get_MonitorsInformation
; Description....: Gets details of all the Displays.
; Syntax.........: _Get_MonitorsInformation()
; Parameters.....: None
; Return values..: The array returned is 8 dimensional and is made up as follows:
;     Success  ====>
;     $array[0][0]=The number of displays on the computer
;     $array[0][1]=The Error code returned by MIService Object
;
;     $array[1][0]=Name
;     $array[1][1]=Monitor Type
;     $array[1][2]=Manfucturer
;     $array[1][3]=DPI X
;     $array[1][4]=DPI Y
;     $array[1][5]=Screen Width
;     $array[1][6]=Screen Height
;     $array[1][7]=Display Type
;                Failure  ====>
;     $array[0][0]=0
;     $array[0][1]=The Error code returned by MIService Object
; Author.........: Antonio Do Rosario (Aipion)
; Remarks........: Works with Windows 2000, 2003, XP, Vista and 7
; Example........: No
;~ #include <Array.au3>
;~ $DisplaysArray=_Get_MonitorsInformation()
;~ _ArrayDisplay($DisplaysArray)
;~ ConsoleWrite($DisplaysArray[1][5])
;~ ConsoleWrite($DisplaysArray[1][6])
; ===============================================================================================================================
Func _Get_MonitorsInformation() ; Get resolution of 2nd or 3rd monitor
   Local $objWMIService ; As Object
   Local $colItems  ; As Object
   Local $objItem  ; As Object
   Local $DisplaysArray[1][8]
   Local $objWMIService=ObjGet("winmgmts:.rootcimv2")
   $DisplaysArray[0][1]=Hex(@error, 8)
   If @error Then
   ;Error Getting an active WMIService Object.
   $DisplaysArray[0][0]=0
   Return $DisplaysArray
   EndIf
   $colItems=$objWMIService.ExecQuery("Select * From Win32_DesktopMonitor")
   For $objItem In $colItems
   $DisplaysArray[0][0] += 1
   ReDim $DisplaysArray[$DisplaysArray[0][0]+1][8]
   $DisplaysArray[$DisplaysArray[0][0]][0]=$objItem.Name      ;Name
   $DisplaysArray[$DisplaysArray[0][0]][1]=$objItem.MonitorType  ;Monitor Type
   $DisplaysArray[$DisplaysArray[0][0]][2]=$objItem.MonitorManufacturer   ;Manufacturer
   $DisplaysArray[$DisplaysArray[0][0]][3]=$objItem.PixelsPerXLogicalInch ;DPI X
   $DisplaysArray[$DisplaysArray[0][0]][4]=$objItem.PixelsPerYLogicalInch ;DPI Y
   $DisplaysArray[$DisplaysArray[0][0]][5]=$objItem.ScreenWidth  ;Screen Width
   $DisplaysArray[$DisplaysArray[0][0]][6]=$objItem.ScreenHeight    ;Screen Height
   ;Display Type
   Switch $objItem.DisplayType
   Case 0
   $DisplaysArray[$DisplaysArray[0][0]][7]="Unknown"
   Case 1
   $DisplaysArray[$DisplaysArray[0][0]][7]="Other"
   Case 2
   $DisplaysArray[$DisplaysArray[0][0]][7]="MultiScan Color"
   Case 3
   $DisplaysArray[$DisplaysArray[0][0]][7]="MultiScan Monochrome"
   Case 4
   $DisplaysArray[$DisplaysArray[0][0]][7]="Fixed Frequency Color"
   Case 5
   $DisplaysArray[$DisplaysArray[0][0]][7]="Fixed Frequency Monochrome"
   Case Else
   $DisplaysArray[$DisplaysArray[0][0]][7]="Unknown"
   EndSwitch
   Next
   Return $DisplaysArray
EndFunc

; #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7
; #FUNCTION# ====================================================================================================================
; Name ..........: _DesktopDimensions
; Description ...: Returns an array containing information about the primary and virtual monitors.
; Syntax ........: _DesktopDimensions()
; Return values .: Success - Returns a 6-element array containing the following information:
;                 $aArray[0]=Number of elements.
;                 $aArray[1]=Total number of monitors.
;                 $aArray[2]=Width of the primary monitor.
;                 $aArray[3]=Height of the primary monitor.
;                 $aArray[4]=Total width of the desktop including the width of multiple monitors. Note: If no secondary monitor this will be the same as $aArray[2].
;                 $aArray[5]=Total height of the desktop including the height of multiple monitors. Note: If no secondary monitor this will be the same as $aArray[3].
; Author ........: guinness
; Remarks .......: WinAPI.au3 must be included i.e. #include <winapi.au3>
; Related .......: @DesktopWidth, @DesktopHeight, _WinAPI_GetSystemMetrics
; Example .......: Yes
;~ #include <WinAPI.au3>
;~ #include <WindowsConstants.au3>
;~ Global $aScreenResolution
;~ $aScreenResolution=_DesktopDimensions()
;~ ConsoleWrite("Example of _DesktopDimensions():" & @CRLF & _
;~       "Number of monitors=" & $aScreenResolution[1] & @CRLF & _
;~       "Primary Width=" & $aScreenResolution[2] & @CRLF & _
;~       "Primary Height=" & $aScreenResolution[3] & @CRLF & _
;~       "Secondary Width=" & $aScreenResolution[4] & @CRLF & _
;~       "Secondary Height=" & $aScreenResolution[5] & @CRLF)
; ===============================================================================================================================
Func _DesktopDimensions() ; _DesktopDimensions() - Details about the primary and secondary monitors.
    Local $aReturn[6]=[5, _
            _WinAPI_GetSystemMetrics($SM_CMONITORS), _ ; Number of monitors.
            _WinAPI_GetSystemMetrics($SM_CXSCREEN), _ ; Width or Primary monitor.
            _WinAPI_GetSystemMetrics($SM_CYSCREEN), _ ; Height or Primary monitor.
            _WinAPI_GetSystemMetrics($SM_CXVIRTUALSCREEN), _ ; Width of the Virtual screen.
            _WinAPI_GetSystemMetrics($SM_CYVIRTUALSCREEN)] ; Height of the Virtual screen.
    Return $aReturn
EndFunc   ;==>_DesktopDimensions

;~ Func Show_About()
;~  MsgBox(64, "About " & $shortscrname, $fullscrname & @LF & @LF & $version & @LF & "Coded by PPCC") ;Hotkey:...
;~ EndFunc

Func _ProcessGetLocation($iPID)
Local $aProc=DllCall('kernel32.dll', 'hwnd', 'OpenProcess', 'int', BitOR(0x0400, 0x0010), 'int', 0, 'int', $iPID)
If $aProc[0]=0 Then Return SetError(1, 0, '')
Local $vStruct=DllStructCreate('int[1024]')
DllCall('psapi.dll', 'int', 'EnumProcessModules', 'hwnd', $aProc[0], 'ptr', DllStructGetPtr($vStruct), 'int', DllStructGetSize($vStruct), 'int_ptr', 0)
Local $aReturn=DllCall('psapi.dll', 'int', 'GetModuleFileNameEx', 'hwnd', $aProc[0], 'int', DllStructGetData($vStruct, 1), 'str', '', 'int', 2048)
If StringLen($aReturn[3])=0 Then Return SetError(2, 0, '')
Return $aReturn[3]
EndFunc

; For ä ö ü ß ä ö ü € ´ (Special German keyboard)
HotKeySet("+{F1}","a_umlaut")
Func a_umlaut()
Send("ä")
EndFunc
HotKeySet("^+{F1}","ca_umlaut")
Func ca_umlaut()
Send("ä")
EndFunc
HotKeySet("+{F2}","o_umlaut")
Func o_umlaut()
Send("ö")
EndFunc
HotKeySet("^+{F2}","co_umlaut")
Func co_umlaut()
Send("ö")
EndFunc
HotKeySet("+{F3}","u_umlaut")
Func u_umlaut()
Send("ü")
EndFunc
HotKeySet("^+{F3}","cu_umlaut")
Func cu_umlaut()
Send("ü")
EndFunc
HotKeySet("+{F4}","eszett")
Func eszett()
Send("ß")
EndFunc
HotKeySet("^+{F4}","euro")
Func euro()
Send("€")
EndFunc
HotKeySet("+{F5}","acute_accent")
Func acute_accent()
Send("´")
EndFunc

; Copy and edit from http://www.autoitscript.com/forum/topic/133222-manipulate-system-tray-program-right-click-choose-option/
Func _ActiveContextMenuSysTrayIcon($SendKey,$sToolTipTitle)
Run('control /name Microsoft.NotificationAreaIcons')
While 1
  If WinActive("Notification Area Icons") Then ExitLoop
WEnd
_WinWaitActivate("Notification Area Icons","")
ControlSend("Notification Area Icons","","Button3","{ALTDOWN}a{ALTUP}{+}");~  ControlCommand("Notification Area Icons","","Button3","Check", "");~  Send("{ALTDOWN}a{ALTUP}{+}")
Sleep(500)
Global $hSysTray_Handle, $iSystray_ButtonNumber
Opt("WinTitleMatchMode", 2)
$iSystray_ButtonNumber=Get_Systray_Index($sToolTipTitle)
Opt("WinTitleMatchMode", 1)
If $iSystray_ButtonNumber=0 Then
  MsgBox(16, "Error", "The '" & $sToolTipTitle & "' application seems to be not running!",5);~   Exit
Else
  Sleep(500)
  _GUICtrlToolbar_ClickButton($hSysTray_Handle, $iSystray_ButtonNumber, "right")
  Sleep(500)
;~   $SendKeyArray=StringSplit($SendKey,"")
;~   For $Key In $SendKeyArray
;~    Send($Key); Move your cursor around on the menu here <<<<<<<<<<<<<<<<<<<<<<<<<<<;~     ConsoleWrite(GetPopUpSelText() & @CRLF) ; This will read the currently selected item <<<<<<<<<<<<<<<<<<<<<<<<<<<<
;~   Next
  Send($SendKey)
  Sleep(1000)
EndIf
Run('control /name Microsoft.NotificationAreaIcons')
While 1
  If WinActive("Notification Area Icons") Then ExitLoop
WEnd
_WinWaitActivate("Notification Area Icons","")
ControlSend("Notification Area Icons","","Button3","{ALTDOWN}a{ALTUP}{-}")
Sleep(500)
WinClose("Notification Area Icons")
EndFunc

; Copy and edit from http://www.autoitscript.com/forum/topic/102160-msgbox-with-downtime-count/page__view__findpost__p__751116
Func MsgBoxDJS($flag, $title, $text, $timeout=10, $Cflag=1, $hwnd='')
Global $vStringFormat='%01s'
    Global $Timer=DllCallbackRegister('Timer', 'int', 'hwnd;uint;uint;dword')
    If $timeout='' Or $timeout=-1 Then $timeout=10
    Global $_title=$title, $_text=$text, $_Cflag=$Cflag, $_ibj=1, $_ttc=$timeout, $bttxtbj=0
    Global $TimerDLL=DllCall('user32.dll', 'uint', 'SetTimer', 'hwnd', 0, 'uint', 0, 'int', 1000, 'ptr', DllCallbackGetPtr($Timer))
    Local $Mkmsg
    If $Cflag=0 Then
        If StringRegExp($title, '%s')=0 Then
            $title='%s' & $title
            $_title=$title
        EndIf
        $title=StringRegExpReplace($title, "%s", StringFormat($vStringFormat, $_ttc), 1)
    EndIf
    If $Cflag=1 Then
        If StringRegExp($text, '%s')=0 Then
            $text=$text & ' %s seconds.' ;'%s' & $text
            $_text=$text
        EndIf
        $text=StringRegExpReplace($text, "%s", StringFormat($vStringFormat, $_ttc), 1)
    EndIf
    $Mkmsg=MsgBox($flag, $title, $text)
    DllClose($TimerDLL)
    DllCallbackFree($Timer)
    Return $Mkmsg
EndFunc   ;==>MsgBoxDJS
Func Timer($hwnd, $uiMsg, $idEvent, $dwTime)
    Global $TimerDLL, $bttxtbj, $_Cflag, $_title, $_ttc, $_text, $_ibj, $Timer
    If $idEvent=$TimerDLL[0] Then
        Global $bttxt, $CtrlF, $Static
        If $bttxtbj=0 Then
            If $_Cflag=0 Then $CtrlF=ControlGetFocus(StringRegExpReplace($_title, "%s", StringFormat($vStringFormat, $_ttc), 1))
            If $_Cflag=1 Or $_Cflag=2 Then $CtrlF=ControlGetFocus($_title)
            $bttxt=ControlGetText($_title, $_text, $CtrlF)
            If $_Cflag=1 Then
                $Static='Static1'
                ControlGetText($_title, StringRegExpReplace($_text, "%s", StringFormat($vStringFormat, $_ttc), 1), 'Static1')
                If @error Then $Static='Static2'
            EndIf
            $bttxtbj=1
        EndIf
        If $_Cflag=0 Then
            $_title1=StringRegExpReplace($_title, "%s", StringFormat($vStringFormat, $_ttc - $_ibj + 1), 1)
            $_title2=StringRegExpReplace($_title, "%s", StringFormat($vStringFormat, $_ttc - $_ibj), 1)
            WinSetTitle($_title1, $_text, $_title2)
        ElseIf $_Cflag=1 Then
            $_text1=StringRegExpReplace($_text, "%s", StringFormat($vStringFormat, $_ttc - $_ibj + 1), 1)
            $_text2=StringRegExpReplace($_text, "%s", StringFormat($vStringFormat, $_ttc - $_ibj), 1)
            ControlSetText($_title, $_text1, $Static, $_text2)
        ElseIf $_Cflag=2 Then
            ControlSetText($_title, $_text, $CtrlF, $bttxt & StringFormat(' %03s', $_ttc - $_ibj))
        EndIf
        If $_ibj=$_ttc Then
            If $_Cflag=0 Then $_title=$_title2
            If $_Cflag=1 Then $_text=$_text2
            DllClose($TimerDLL)
            DllCallbackFree($Timer)
            ControlClick($_title, $_text, $CtrlF, '', 2)
        EndIf
        $_ibj += 1
    EndIf
EndFunc   ;==>Timer

; http://www.autoitscript.com/forum/topic/112868-getting-progressbar-to-work-with-inetget/
; $FileURL1="http://download.macromedia.com/pub/flashplayer/current/uninstall_flash_player.exe"
; $FileName1="uninstall_flash_player.exe"
; $Program1="Flash uninstall"
; _DownloadProgress($FileURL1, $FileName1, $Program1)
Func _DownloadFileProgress($FileURL, $FileName, $ProgramName, $SavedDir=@TempDir)
$FileSaveLocation=$SavedDir & "" & $FileName
    $FileSize=InetGetSize($FileURL)
    $FileDownload=InetGet($FileURL, $FileSaveLocation, 0, 1)
    ProgressOn("", "", "", -1, 5, 18)
    Do
        $Percentage=InetGetInfo($FileDownload, 0) * 100 / $FileSize
        ProgressSet($Percentage, Round($Percentage, 0) & "% Downloaded " & Round(InetGetInfo($FileDownload, 0) / 1048576, 2) & " of " & Round($FileSize / 1048576, 2) & " MB", "Downloading " & $ProgramName)
        Sleep(250)
    Until InetGetInfo($FileDownload, 2)
EndFunc   ;==>_DownloadFileProgress

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
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.