Sign in to follow this  
Followers 0
Briandr

add code to code from Autoit recorder

1 post in this topic

#1 ·  Posted (edited)

Hi, 

I am trying to add in code to existing code from the autoit recorder (the autoit recorder codes works fine). I am just not sure how to incorporate my If $Model statement in properly. Should that be part of the AU3RecordSetup() or should I have a separate function like DetectLaptop() ? I added that new function below. Just trying to confirm I am going down the right path with this or if I am way off base.

#region --- Au3Recorder generated code Start (v3.3.9.5 KeyboardLayout=00000409)  ---
#region --- Internal functions Au3Recorder Start ---
#include <Process.au3>
#include <WindowsConstants.au3>
#include <File.au3>
#include <Constants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>

Dim $Model
$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$colItems = ""
$StrComputer = "localhost"

Func _DetectLaptop()
If $Model = "HP EliteBook 2530p" Or $Model = "HP EliteBook 2540p" Or $Model = "HP EliteBook 2560p" Or $Model = "HP EliteBook 2570p" Or $Model = "HP Compaq 6530b (FG996AW#ABA)" Or $Model = "HP ProBook 6455b" Or $Model = "HP ProBook 6465b" Or $Model = "HP ProBook 6475b" Or $Model = "HP EliteBook Folio 9470m" Or $Model = "HP ProBook 645 G1"  Or $Model = "HP EliteBook Folio 9480m" Then ; Not a laptop or system not supported, do nothing
_Au3RecordSetup()
EndIf
EndFunc

Func _Au3RecordSetup()
Opt('WinWaitDelay',100)
Opt('WinDetectHiddenText',1)
Opt('MouseCoordMode',0)
Local $aResult = DllCall('User32.dll', 'int', 'GetKeyboardLayoutNameW', 'wstr', '')
If $aResult[1] <> '00000409' Then
  MsgBox(64, 'Warning', 'Recording has been done under a different Keyboard layout' & @CRLF & '(00000409->' & $aResult[1] & ')')
EndIf

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()
#endregion --- Internal functions Au3Recorder End ---
Run('C:\Program Files (x86)\Hewlett-Packard\HP Connection Manager\HPConnectionManager.exe')
_WinWaitActivate("HP Connection Manager","")
Send("{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{ENTER}")
_WinWaitActivate("Preferences","")
Send("{TAB}{TAB}{DOWN}{TAB}{TAB}{SPACE}{TAB}{SPACE}{TAB}{SPACE}{TAB}{SPACE}{TAB}{ENTER}")
;Send("{TAB}{TAB}{DOWN}{TAB}{TAB}{SPACE}{TAB}{SPACE}{TAB}{SPACE}{TAB}{SPACE}{TAB}{SPACE}{TAB}{ENTER}")
_WinWaitActivate("HP Connection Manager","")
Send("{ALTDOWN}{F4}{ALTUP}{TAB}{ENTER}")
#endregion --- Au3Recorder generated code End ---

sleep (10000)

_Win32_ComputerSystem() ;Get Model

Func _Win32_ComputerSystem()
    ;Get General PC Info
    $objWMIService = ObjGet("winmgmts:\\" & $StrComputer & "\root\CIMV2")
    $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
    If IsObj($colItems) Then
        For $objItem In $colItems
            ;$DOMAIN = $objItem.Domain
            $Manufacturer = $objItem.Manufacturer
            $Model = $objItem.Model
            ;$MachineName = $objItem.Name
            ;$NumberOfProcessors = $objItem.NumberOfProcessors
            ;$PartOfDomain = $objItem.PartOfDomain
            ;$MEM = Round($objItem.TotalPhysicalMemory / 1024 / 1024, 0)
        Next
    EndIf
EndFunc   ;==>_Win32_ComputerSystem

_SelfDelete()

Func _SelfDelete($iDelay = 0)
    Local $sCmdFile
    FileDelete(@TempDir & "\scratch.bat")
    $sCmdFile = 'ping -n ' & $iDelay & '127.0.0.1 > nul' & @CRLF _
            & ':loop' & @CRLF _
            & 'del "' & @ScriptFullPath & '"' & @CRLF _
            & 'if exist "' & @ScriptFullPath & '" goto loop' & @CRLF _
            & 'del ' & @TempDir & '\scratch.bat'
    FileWrite(@TempDir & "\scratch.bat", $sCmdFile)
    Run(@TempDir & "\scratch.bat", @TempDir, @SW_HIDE)
EndFunc
Edited by Briandr

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