Jump to content
Sign in to follow this  
JustinMeyer

AutoIT & Phidgets, Robotics with AutoIT (How To)

Recommended Posts

I am planning on building a "How To - AutoIT & Phidgets" and am looking for direction on how to document it.

Phidgets are "Products for USB Sensing and Control" that can be utilized with AutoIT. They allow physical

interface, functions and events / input and output through COM in the case of AutoIT. Check out the

Phidgets page for more information, and go to Trossen Robotics if you are going to buy (Cheaper and Faster).

The image is a link to the video right after I was able to get

AutoIT and the 1063 Bipolar stepper controllers talking. I

am building a 3-Axis CNC mill.

Posted Image

I Know AutoIT and Phidgets are not the ideal way to go when

building a mill... its a learning experience.

Quick piece together of code used in video above.

#include <GUIConstantsEx.au3>
 
GUICreate("PhidgetStepper Control Test",500,400)$Add_2C_B = GUICtrlCreateButton("Add to Current Position (+10000 1/16)", 5, 5, 490, 30)
$Sub_FC_B = GUICtrlCreateButton("Subtract from Current Position (-10000 1/16)", 5, 40, 490, 30)
$Output_E = GUICtrlCreateEdit("", 5, 335, 490, 60)GUISetState(@SW_SHOW)
;create the phidget object
$oPhidget = ObjCreate("phidget21COM.PhidgetStepper");open the Phidget system
$oPhidget.Open(130664)
$oPhidget.WaitForAttachment(3000)
If NOT $oPhidget.IsAttached Then
MsgBox(0, "Error", "Phidget Device not attached")
Exit
EndIf
;register Phidget events
$oPhidEvents = ObjEvent($oPhidget, "phid1_");Power Stepper Motor, index motor 0
$oPhidget.Engaged(0) = 1
;set Stepper control values
$oPhidget.CurrentLimit(0) = 00.70
$oPhidget.VelocityLimit(0) = 7000.00
$oPhidget.Acceleration(0) = 18100.00;set the current position
$oPhidget.CurrentPosition(0) = 0
;read current position to variable
$Current_P = $oPhidget.CurrentPosition(0)GUICtrlSetData($Output_E, $Current_P)
While 1
$msg = GUIGetMsg()Select
Case $msg = $GUI_EVENT_CLOSE
MsgBox(0,"Application Alert", "Application Closing")
ExitLoopCase $msg = $Add_2C_B
$Current_P = $oPhidget.CurrentPosition(0)
$oPhidget.TargetPosition(0) = $Current_P +10000
GUICtrlSetData($Output_E, $Current_P)
Case $msg = $Sub_FC_B
$Current_P = $oPhidget.CurrentPosition(0)
$oPhidget.TargetPosition(0) = $Current_P -10000
GUICtrlSetData($Output_E, $Current_P)
EndSelect
WEnd;power off stepper at index 0
$oPhidget.Engaged(0) = 0
;close
$oPhidget.Close();Phidget Event Handlers
Func phid1_OnDetach($Index, $IRValue)
MsgBox(0,"Error", "Phidget detached")
Exit
EndFunc

Sorry its one blob, it keeps coming out like that.

So where should I start a thread or threads, examples or questions, as it will be both and more.

I have a few different Phidgets and will be progressing the capabilities and limitations with the

help of the forum.


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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By WilliamasKumeliukas
      Hi,
      I started this project alone in May 2020 as project in my spare time at work, I'm working for a IT compagny that's started opening their services to residential customers few months ago and now my position in the company kinda drifted in the doom and gloom world of repetitive tasks like: Reinstallation of Windows 10.
      The procedure is very repetitive and I started feeling like being a robot which is the main reason I started this project.
       
      ==============================FAQ==================================
      1. Q: Do you want this project to be accomplished with the usage of AutoIT ONLY or 3rd party tools / Scripts (BATCH / POWERSHELL / VB) ? A: No, if I cannot find a way using AutoIT to accomplish a task I will move to my Plan B which consist of automating an 3rd party tool to accomplish the affected task until a solution is found. 2. Q: What do I get from helping/collaborating in this project? A: I will personally take the responsability to mention you in the credits of this project. 3. Q: If I have more questions, can I ask? A: Certainly! feel free to ask any questions related to this project! 4. Q: What is the main goal of this project? A: Automating Windows 10 configuration without user interaction needed (as much as possible) ______________________________________________________________________________________________________________________________
      Current progression of the project (more will be added in future)
      « Blue = Info || Yellow = Unfinished/Untested || Purple = Could be better || Green = Done ||Red = Not Yet Started »
      ***Very early Stage ***
      Connect Network Attached Storage(NAS) (Tested & Working - AutoIT only)
      Download & Install up to 567 softwares with Auto prediction of text typed  (Tested & Working - using 3rd party tool)
      Change OEM Information (Tested & Working - contains both AutoIT version and CMD script)
      Disable ScreenSaver (Require testing AutoIT only)
      Change Computer Name (Require testing AutoIT only) 
      Show Computer Information and Smart status on GUI (Work - AutoIT Only)
      Change .pdf / .pdfxml from Edge to Adobe Reader DC (Work - using 3rd party tool)
      Change Edge to Google Chrome as Default Browser (Tested & Working - using 3rd party tool)
      Windows Updates (Working - AutoIT only)
      Install Office 
      Verify and Update softwares installed (Can be added if wanted (up to 567 softwares) - 3rd party tool)
      Activate Office (Tested on 2010 & Working - CMD Script)
      Pin to taskbar Excel, Outlook, Word, Chrome (Tested & Working - using 3rd party tool)
      GUI currently featuring the following options :
      - Checkboxes for desired tasks
      Inputs for : SupportUrl, Manufacturer, Model, SupportPhone, SupportHour, OEM Logo path
      -  Redirect ConsoleWrite with timestamped messages in richedit (errors shown separately in red text)
                 *** To Do ***
       - Read informations needed for tasks like: OEM, ComputerName, NAS user/password etc... from a file
       - ListView for Windows Updates
       - Probably more
       
      ***  If this project interest you, Reply here This will greatly help me to see if you'd like this project to become real  ***
      ______________________________________________________________________________________________________________________________
      2020.09.21 Update: Since this topic reached over 200+ views without a single interest shown by community, pm me if you're willing to be part of the project and i'll share with you the GitHub project link  
      Best Regards,
      ~WilliamasKumeliukas
    • By DirtyJohny
      Hi everyone.Need rewrite this function how in еxample.
      Original:
      #RequireAdmin #NoTrayIcon Opt("MustDeclareVars",1) Func _a() Local $sls=ObjGet("winmgmts:{impersonationLevel=impersonate," _ &"authenticationLevel=Pkt}!\\"& _ @ComputerName&'\root\wmi'),$lss=$sls.ExecQuery _ ('SELECT * FROM WmiMonitorID'), _ $lll,$sll,$sss="",$lsl,$lls,$i,$z For $z In $lss $lsl=$z.UserFriendlyName For $i=0 To Ubound($lsl)-1 if ($lsl[$i]) Then $lll&=Chr($lsl[$i]) Next $lls=$z.SerialNumberID For $i=0 To Ubound($lls)-1 if ($lls[$i]) Then $sll&=Chr($lls[$i]) Next $sss&="Model"&@TAB&@TAB&": "&$lll&@CR&"Serial Number"&@TAB&": "&$sll&@CR&@CR $lll="" $sll="" Next MsgBox(262144,'Monitors '&$lss.Count,$sss&" "&@CR) $lss=Null $sls=Null EndFunc _a() Example:
      Func _InfoPC() Local $ObjService = ObjGet('winmgmts:{impersonationLevel = impersonate}!\\' & @ComputerName & '\root\cimv2') Local $ObjMB = $ObjService.ExecQuery('SELECT * FROM Win32_BaseBoard', 'WQL', 0x30) If IsObj($ObjService) Then For $objItemMB In $ObjMB $sInfo &= @TAB & 'Motherboard: ...... ' & $objItemMB.Product & @CRLF I'm beginner in this sphere and need  you all speak easy and simply because i'm Russian.Thanks)
    • By Deshanur
      Am trying to automate injecting credential on the login form for all kind of Web application for IE. I know how to identify the form name by viewing the source code and using the method - _IEFormGetObjByName($ie, $form_Name).
      I would like to know how to identify or get the form object for the web app where there is no form name tag for example below, for the is I have used - _IEFormGetCollection($ie, 0) to get the form object.
      My Question is does it work for all kind of application "_IEFormGetCollection($ie, 0)" how to identify Index value? is it always 0? is there any better solution?
      The final solution am looking for is find out form object, get the username, password field and inject credential and submit the form.
      How to find out index value? for the forms which does not have form name field.
      $login_form = _IEFormGetCollection($ie, 0) $email_field = _IEFormElementGetObjByName($login_form, $form_UserName) $pass_field = _IEFormElementGetObjByName($login_form, $form_password) $login_button = _IEFormElementGetObjByName($login_form, $form_submitbutton) _IEFormElementSetValue($email_field, $CmdLine[2]) _IEFormElementSetValue($pass_field, $CmdLine[3]) ControlSend($hwnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]","{Enter}") OR This works fine if the form has form name. $login_form = _IEFormGetObjByName($ie, $form_Name) $email_field = _IEFormElementGetObjByName($login_form, $form_UserName) $pass_field = _IEFormElementGetObjByName($login_form, $form_password) $login_button = _IEFormElementGetObjByName($login_form, $form_submitbutton) _IEFormElementSetValue($email_field, $CmdLine[2]) _IEFormElementSetValue($pass_field, $CmdLine[3]) ControlSend($hwnd, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]","{Enter}")
    • By abberration
      Software Installer
      version 1.1 - 11/6/2020
      This new version (first in 8 years) is a total rewrite of the original. I was not getting notifications on this thread and missed people's questions and requests. I have incorporated some recent requests and will go back further in the posts and consider more upgrades.
      The overall look remains the same, but this version brings many changes. The only script breaking change is your old INI file is not compatible with this version. Some new features:
      When you add software to the Software folder (you need to create this folder in the same directory as your script), you will get prompted to configure the software. If you say yes, it will bring up a form where you can type up a display name for the software (instead of the installer name. Ex: 7z1900-x64.msi can be displayed as 7-Zip), the switch to use, software description and what category tab you want it to appear in. This feature creates and updates an INI file for you, so you don't have to do it manually. While configuring your software, there is a drop-down menu with installer types (Inno, NSIS, MSI, Installshield, Wise, etc). If you know the installer type, it narrows down the switches in the Switch drop-down menu to only show switches for that installer type. If none of the switches are what you need (ex: Firefox uses -ms), just manually type the needed switch in the Switch drop-down menu. By default, only unconfigured software shows up in the Configure Software menu. There is a checkbox to show all software, where you can double-click the software and modify it's data. There is an option to edit the order in which the software is installed. If selected, a form will pop up after you press the Install Selected Software button and before the installation begins. On this form, you can select software installers and move them up and down in the list. I will watch this thread more closely and continue to work on this project. This was one of my first "big" projects and one of my favorites. I'm surprised I haven't revisited sooner.
      Enjoy!
      #include <Array.au3> #include <File.au3> #include <GDIPlus.au3> #include <GUIConstants.au3> #include <GuiTab.au3> #include <GuiListView.au3> #include <GuiMenu.au3> #include <ProgressConstants.au3> Global $fIniConfig = @ScriptDir & "\Config.ini" Global $sSWDir = @ScriptDir & "\Software\" Global $sVersion = "1.1" ; Main GUI $Form1 = GUICreate("Software Installer", 633, 451) $Tab1 = GUICtrlCreateTab(16, 8, 601, 377) $TabSheet1 = GUICtrlCreateTabItem("Audio/Video/Photo") $ListView1 = GUICtrlCreateListView("Software Name|Description", 24, 40, 582, 334) _GUICtrlListView_SetExtendedListViewStyle($ListView1, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES, $LVS_EX_GRIDLINES)) GUICtrlSendMsg(-1, 0x101E, 0, 200) GUICtrlSendMsg(-1, 0x101E, 1, 375) $TabSheet2 = GUICtrlCreateTabItem("System Tools") $ListView2 = GUICtrlCreateListView("Software Name|Description", 24, 40, 578, 334) _GUICtrlListView_SetExtendedListViewStyle($ListView2, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES, $LVS_EX_GRIDLINES)) GUICtrlSendMsg(-1, 0x101E, 0, 200) GUICtrlSendMsg(-1, 0x101E, 1, 375) $TabSheet3 = GUICtrlCreateTabItem("Internet") $ListView3 = GUICtrlCreateListView("Software Name|Description", 24, 40, 578, 334) _GUICtrlListView_SetExtendedListViewStyle($ListView3, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES, $LVS_EX_GRIDLINES)) GUICtrlSendMsg(-1, 0x101E, 0, 200) GUICtrlSendMsg(-1, 0x101E, 1, 375) $TabSheet4 = GUICtrlCreateTabItem("Games") $ListView4 = GUICtrlCreateListView("Software Name|Description", 24, 40, 578, 334) _GUICtrlListView_SetExtendedListViewStyle($ListView4, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES, $LVS_EX_GRIDLINES)) GUICtrlSendMsg(-1, 0x101E, 0, 200) GUICtrlSendMsg(-1, 0x101E, 1, 375) $TabSheet5 = GUICtrlCreateTabItem("Miscellaneous") $ListView5 = GUICtrlCreateListView("Software Name|Description", 24, 40, 578, 334) _GUICtrlListView_SetExtendedListViewStyle($ListView5, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES, $LVS_EX_GRIDLINES)) GUICtrlSendMsg(-1, 0x101E, 0, 200) GUICtrlSendMsg(-1, 0x101E, 1, 375) $TabSheet6 = GUICtrlCreateTabItem("Patches/Updates") $ListView6 = GUICtrlCreateListView("Software Name|Description", 24, 40, 578, 334) _GUICtrlListView_SetExtendedListViewStyle($ListView6, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES, $LVS_EX_GRIDLINES)) GUICtrlSendMsg(-1, 0x101E, 0, 200) GUICtrlSendMsg(-1, 0x101E, 1, 375) $TabSheet7 = GUICtrlCreateTabItem("Productivity") $ListView7 = GUICtrlCreateListView("Software Name|Description", 24, 40, 578, 334) _GUICtrlListView_SetExtendedListViewStyle($ListView7, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES, $LVS_EX_GRIDLINES)) GUICtrlSendMsg(-1, 0x101E, 0, 200) GUICtrlSendMsg(-1, 0x101E, 1, 375) GUICtrlCreateTabItem("") ; This ends the tab item creation $g1Checkbox1 = GUICtrlCreateCheckbox("Prompt to edit software installation order", 16, 400, 220, 17) ;~ GUICtrlSetState(-1, $GUI_CHECKED) ; Enable this if you want. $g1Button1 = GUICtrlCreateButton("Install Selected Software", 398, 395, 219, 25, 0) $MenuItem1 = GUICtrlCreateMenu("File") $MenuItem1a = GUICtrlCreateMenuItem("Select All", $MenuItem1) $MenuItem2 = GUICtrlCreateMenuItem("Unselect All", $MenuItem1) $MenuItem3 = GUICtrlCreateMenuItem("Exit", $MenuItem1) $MenuItem4 = GUICtrlCreateMenu("Settings") $MenuItem5 = GUICtrlCreateMenuItem("Edit Software Configuration", $MenuItem4) $MenuItem6 = GUICtrlCreateMenu("Help") $MenuItem7 = GUICtrlCreateMenuItem("Help Topics", $MenuItem6) $MenuItem8 = GUICtrlCreateMenuItem("About", $MenuItem6) GUISetState(@SW_SHOW) $aSoftwareList = _FileListToArrayRec(@ScriptDir & "\Software", "*.exe;*.msi", 1) ; List all software in Software folder. If NOT IsArray ($aSoftwareList) Then ; Easy fix for program crashing if no software is in the Software folder. MsgBox(262144, "Error", "No software installers found in the Software folder." & @CRLF & "This program cannot function without any software installers." & @CRLF & "Add some to the folder and restart the program.") Exit EndIf For $i = 1 To 5 ; Add columns for other data. _ArrayColInsert($aSoftwareList, 1) Next Global $aUnconfiguredSW[$aSoftwareList[0][0]+1][5] $aUnconfiguredSW[0][0] = 0 _CheckForNewSoftware($aSoftwareList) If $aUnconfiguredSW[0][0] > 0 Then ; Get a list of all software that has not been configured. $iQueryUser = _QueryUser() If $iQueryUser = 1 Then _SWConfiguration() EndIf EndIf _Populate() ; Loads the software in the Software folder into the various lists. While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $g1Button1 _InstallSelectedSoftware() Case $MenuItem1a _SelectAll(True) Case $MenuItem2 _SelectAll(False) Case $MenuItem3 Exit Case $MenuItem5 _SWConfiguration() Case $MenuItem7 _HelpTopics() Case $MenuItem8 _About() EndSwitch WEnd Func _Populate() ; Find all files in the Software folder and populate the tabs with the installers. For $i = 1 To 7 ; Fill out the master array with data _GUICtrlListView_DeleteAllItems(Eval("ListView" & $i)) Next For $i = 1 To $aSoftwareList[0][0] $sDisplayName = IniRead($fIniConfig, $aSoftwareList[$i][0], "DisplayName", $aSoftwareList[$i][0]) $sCategory = IniRead($fIniConfig, $aSoftwareList[$i][0], "Category", "") If $sCategory = "" Then $sCategory = 5 EndIf $sDescription = IniRead($fIniConfig, $aSoftwareList[$i][0], "Description", "") $checked = IniRead($fIniConfig,$aSoftwareList[$i][0],"IsDefault", "") $aSoftwareList[$i][1] = $sDisplayName $aSoftwareList[$i][2] = $sCategory $aSoftwareList[$i][3] = $sDescription $aSoftwareList[$i][4] = $checked Next For $i = 1 To $aSoftwareList[0][0] ; Populate the tabs with items $iCategory = IniRead($fIniConfig, $aSoftwareList[$i][0], "Category", 5) GUICtrlCreateListViewItem($aSoftwareList[$i][1] & "|" & $aSoftwareList[$i][3], (Eval("ListView" & $iCategory))) If $aSoftwareList[$i][4] = 1 Then $iI = _GUICtrlListView_FindText((Eval("ListView" & $iCategory)), $aSoftwareList[$i][1]) _GUICtrlListView_SetItemChecked((Eval("ListView" & $iCategory)), $iI, True) ;Set checked radiobox of last found control EndIf Next EndFunc ;==>_Populate Func _InstallSelectedSoftware() GUISetState(@SW_DISABLE, $Form1) Local $sExit = "" $Form4 = GUICreate("Installing Software", 443, 172) $g4Label1 = GUICtrlCreateLabel("Installing:", 16, 16, 148, 17) $g4Label2 = GUICtrlCreateLabel("", 16, 40, 418, 19) GUICtrlSetFont(-1, 10, 400, 0, "Arial Rounded MT Bold") GUICtrlSetColor(-1, 0x008080) $g4Label3 = GUICtrlCreateLabel("File Size:", 16, 64, 146, 17) $g4Label4 = GUICtrlCreateLabel("Total Progress:", 16, 112, 75, 17) $g4Progress1 = GUICtrlCreateProgress(16, 136, 414, 17) Local $aInstallList[$aSoftwareList[0][0] + 1][4] $iInstallListSize = 0 For $i = 1 To 7 $iItemCount = _GUICtrlListView_GetItemCount(Eval("ListView" & $i)) For $j = 1 To $iItemCount $vItemChecked = _GUICtrlListView_GetItemChecked(Eval("ListView" & $i), $j - 1) If $vItemChecked = TRUE Then $iInstallListSize += 1 $aInstallList[0][0] = $iInstallListSize $sItemName = _GUICtrlListView_GetItemText(Eval("ListView" & $i), $j - 1) $iArrayPos = _ArraySearch($aSoftwareList, $sItemName, Default, Default, Default, Default, Default, 1) $sSWInstaller = $aSoftwareList[$iArrayPos][0] $sSwitch = IniRead($fIniConfig, $sSWInstaller, "Switch", "") $aInstallList[$iInstallListSize][0] = $sSWDir & $sSWInstaller $aInstallList[$iInstallListSize][1] = $sSwitch $aInstallList[$iInstallListSize][2] = $sItemName $aInstallList[$iInstallListSize][3] = $sSWInstaller EndIf Next Next ReDim $aInstallList[$aInstallList[0][0] + 1][4] $iInstallOrder = GUICtrlRead($g1Checkbox1) If $iInstallOrder = 1 Then ; If the user wants to alter installation order, this pulls up the Gui. $aInstallList = _InstallOrder($aInstallList) EndIf GUISetState(@SW_SHOW, $Form4) ; The Installing Software screen has been hidden until now. For $i = 1 To $aInstallList[0][0] ; Set info into Gui and install the software. If FileExists($aInstallList[$i][0]) Then GUICtrlSetData($g4Label1, "Installing: " & $i & " of " & $aInstallList[0][0]) GUICtrlSetData($g4Label2, $aInstallList[$i][2]) ; Name of software GUICtrlSetData($g4Label3, "File Size: " & Round(FileGetSize($aInstallList[$i][0])/1024000, 1) & " MB") If StringRight($aInstallList[$i][0], 4) = ".msi" Then $sInstallString = '"' & $aInstallList[$i][0] & '" ' & $aInstallList[$i][1] Run("msiexec /i " & $sInstallString) Else RunWait('"' & $aInstallList[$i][0] & '" ' & $aInstallList[$i][1]) EndIf EndIf GUICtrlSetData($g4Progress1, $i/$aInstallList[0][0]*100) Next $sExit = "EXIT" Do Sleep(500) Until $sExit = "EXIT" GUISetState(@SW_ENABLE, $Form1) GUIDelete($Form4) _SelectAll(False) EndFunc Func _SelectAll($TF) ; Sending TRUE or FALSE to select all or unselect all. For $i = 1 To 7 $iItemCount = _GUICtrlListView_GetItemCount(Eval("ListView" & $i)) For $j = 1 To $iItemCount _GUICtrlListView_SetItemChecked(Eval("ListView" & $i), $j - 1, $TF) Next Next EndFunc ;==>_SelectAll Func _HelpTopics() $Form2 = GUICreate("Help", 633, 447) $Label1 = GUICtrlCreateLabel("", 8, 16, 612, 425) GUICtrlSetData(-1, "This program uses silent switches to install software without user interaction. " & _ "To use this functionality, you can edit the Config.ini file to add software and their switches. Example: " & _ @CRLF & @CRLF & "[7z1900-x64.exe] ; <--- This is the actual file name" & _ @CRLF & "Description=YourDescripton" & @CRLF & "Switch=YourSwitcth" & @CRLF & "Category=YourCategory" & @CRLF & "etc... etc..." & _ @CRLF & @CRLF & "Here are some common switches for various installers: (more included in this program's features)" & @CRLF & @CRLF & "/silent used for Inno Setup installers" & @CRLF & _ "/verysilent used for Inno Setup installers" & @CRLF & "/S used for Nullsoft (aka NSIS) installers" & @CRLF & "/s used for Wise installers" & _ @CRLF & "-s used for Ghost installers" & @CRLF & "-ms used for Mozilla installers" & @CRLF & "/quiet used for Microsoft installers" & @CRLF & _ "/qb used for Microsoft installers" & @CRLF & "/qn used for Microsoft installers" & @CRLF & "/passive used for Microsoft installers" & @CRLF & _ "/Q used for Microsoft installers") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE GUIDelete($Form2) ExitLoop EndSwitch WEnd EndFunc ;==>_HelpTopics Func _CheckForNewSoftware($aSoftwareList) Local $aConfigFileSW = IniReadSectionNames($fIniConfig) $iArrayPos = 1 For $i = 1 To $aSoftwareList[0][0] If _ArraySearch($aConfigFileSW, $aSoftwareList[$i][0]) < 1 Then $aUnconfiguredSW[$iArrayPos][0] = $aSoftwareList[$i][0] $aUnconfiguredSW[0][0] = $iArrayPos $iArrayPos += 1 EndIf Next EndFunc Func _SWConfiguration() GUISetState(@SW_DISABLE, $Form1) $Form2 = GUICreate("Configure Software", 620, 470) Global $g2List = GUICtrlCreateList("", 8, 24, 602, 218) $g2Checkbox1 = GUICtrlCreateCheckbox("Show All Software", 8, 240, 121, 17) $g2Label1 = GUICtrlCreateLabel("Display Name For Software:", 8, 264, 250, 17) $g2Input1 = GUICtrlCreateInput("", 8, 280, 250, 21) GUICtrlSetState(-1, $GUI_DISABLE) $g2Label2 = GUICtrlCreateLabel("Installer Type (optional):", 8, 320, 116, 17) $g2Combo1 = GUICtrlCreateCombo("", 8, 336, 250, 25, BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL)) GUICtrlSetState(-1, $GUI_DISABLE) $g2Label3 = GUICtrlCreateLabel("Silent Switch To Be Used:", 8, 376, 128, 17) $g2Combo2 = GUICtrlCreateCombo("", 8, 392, 250, 25) GUICtrlSetState(-1, $GUI_DISABLE) $g2Label4 = GUICtrlCreateLabel("Software Description (optional):", 300, 264, 250, 17) $g2Input2 = GUICtrlCreateInput("", 300, 280, 250, 21) GUICtrlSetState(-1, $GUI_DISABLE) $g2Label5 = GUICtrlCreateLabel("Category:", 300, 320, 128, 17) $g2Combo3 = GUICtrlCreateCombo("", 300, 336, 250, 25, BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL)) GUICtrlSetState(-1, $GUI_DISABLE) $g2Label6 = GUICtrlCreateLabel("Double-Click Each Software To Configure. When Finished, Click The Save Button", 8, 6, 391, 17) $g2Label7 = GUICtrlCreateLabel("Editing: ", 8, 240, 602, 17) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x008000) GUICtrlSetBkColor(-1, 0xC0DCC0) GUICtrlSetState(-1, $GUI_HIDE) $g2Checkbox2 = GUICtrlCreateCheckbox("This Software Defaults To Selected (Check Mark On)", 300, 392, 300, 17) GUICtrlSetState(-1, $GUI_DISABLE) $g2Button1 = GUICtrlCreateButton("Edit A Different Software", 300, 430, 160, 25, $WS_GROUP) GUICtrlSetState(-1, $GUI_DISABLE) $g2Button2 = GUICtrlCreateButton("Save Data", 480, 430, 100, 25, $WS_GROUP) GUICtrlSetState(-1, $GUI_DISABLE) GUISetState(@SW_SHOW) _ClearAndSetInputs($g2List, $g2Combo1, $g2Combo2, $g2Combo3, $g2Input1, $g2Input2, $g2Label7, $g2Checkbox1, $g2Checkbox2, $aUnconfiguredSW) Global $idDummy = GUICtrlCreateDummy() GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE GUISetState(@SW_ENABLE, $Form1) GUIDelete($Form2) _Populate() ExitLoop Case $idDummy _ClearAndSetInputs($g2List, $g2Combo1, $g2Combo2, $g2Combo3, $g2Input1, $g2Input2, $g2Label7, $g2Checkbox1, $g2Checkbox2, $aSoftwareList) GUICtrlSetData($g2Label7, "Editing: " & GUICtrlRead($idDummy)) $sDesc = IniRead($fIniConfig, GUICtrlRead($idDummy), "Description", "") $sFullSwitches = "-s|/silent|/verysilent|/sp- /silent /norestart|/verysilent /norestart|/S|/S /NCRC|/passive|/passive /norestart|/u|/u /z|/q|/q /r:n|/q:a|/qb|/qn|/q:a /r:n|/S|/s" $sSwitch = IniRead($fIniConfig, GUICtrlRead($idDummy), "Switch", $sFullSwitches) Local $aCategories[8] = ["7","Audio/Video/Photo", "System Tools", "Internet", "Games", "Miscellaneous", "Patches/Updates", "Productivity"] $iCategory = IniRead($fIniConfig, GUICtrlRead($idDummy), "Category", "5") $sCategory = $aCategories[$iCategory] $sDisplayName = IniRead($fIniConfig, GUICtrlRead($idDummy), "DisplayName", "") $sIsDefault = IniRead($fIniConfig, GUICtrlRead($idDummy), "IsDefault", "") GUICtrlSetData($g2Input1, $sDisplayName) GUICtrlSetData($g2Combo2, $sSwitch) GUICtrlSetData($g2Input2, $sDesc) GUICtrlSetData($g2Combo3, $sCategory) If $sIsDefault = 1 Then GUICtrlSetState($g2Checkbox2, $GUI_CHECKED) EndIf _EnableDisableControls($g2Input1, $g2Combo1, $g2Combo2, $g2Combo3, $g2Input2, $g2Button1, $g2Button2, $g2Checkbox1, $g2Checkbox2, $g2Label7, $g2List, 1) ; enable Case $g2Button1 GUICtrlSetState($g2Checkbox1, $GUI_UNCHECKED) _ClearAndSetInputs($g2List, $g2Combo1, $g2Combo2, $g2Combo3, $g2Input1, $g2Input2, $g2Label7, $g2Checkbox1, $g2Checkbox2, $aUnconfiguredSW) _EnableDisableControls($g2Input1, $g2Combo1, $g2Combo2, $g2Combo3, $g2Input2, $g2Button1, $g2Button2, $g2Checkbox1, $g2Checkbox2, $g2Label7, $g2List, 0) Case $g2Combo1 _SetSwitchData($g2Combo1, $g2Combo2, $g2Combo3) Case $g2Checkbox1 $iCBRead = GUICtrlRead($g2Checkbox1) If $iCBRead = 1 Then _ClearAndSetInputs($g2List, $g2Combo1, $g2Combo2, $g2Combo3, $g2Input1, $g2Input2, $g2Label7, $g2Checkbox1, $g2Checkbox2, $aSoftwareList) Else _ClearAndSetInputs($g2List, $g2Combo1, $g2Combo2, $g2Combo3, $g2Input1, $g2Input2, $g2Label7, $g2Checkbox1, $g2Checkbox2, $aUnconfiguredSW) EndIf Case $g2Button2 $sCurrentSW = StringTrimLeft(GUICtrlRead($g2Label7), 9) $sDesc = IniWrite($fIniConfig, $sCurrentSW, "Description", GUICtrlRead($g2Input2)) $sSwitch = IniWrite($fIniConfig, $sCurrentSW, "Switch", GUICtrlRead($g2Combo2)) Local $aCategories[8] = ["7","Audio/Video/Photo", "System Tools", "Internet", "Games", "Miscellaneous", "Patches/Updates", "Productivity"] $sCategory = GUICtrlRead($g2Combo3) $iArrayPos = _ArraySearch($aCategories, $sCategory) IniWrite($fIniConfig, $sCurrentSW, "Category", $iArrayPos) $sDisplayName = IniWrite($fIniConfig, $sCurrentSW, "DisplayName", GUICtrlRead($g2Input1)) $sIsDefault = IniWrite($fIniConfig, $sCurrentSW, "IsDefault", GUICtrlRead($g2Checkbox2)) $iArrayPos = _ArraySearch($aUnconfiguredSW, $sCurrentSW) If $iArrayPos > 0 Then _ArrayDelete($aUnconfiguredSW, $iArrayPos) $aUnconfiguredSW[0][0] -= 1 EndIf _ClearAndSetInputs($g2List, $g2Combo1, $g2Combo2, $g2Combo3, $g2Input1, $g2Input2, $g2Label7, $g2Checkbox1, $g2Checkbox2, $aUnconfiguredSW) GUICtrlSetState($g2Checkbox1, $GUI_UNCHECKED) _EnableDisableControls($g2Input1, $g2Combo1, $g2Combo2, $g2Combo3, $g2Input2, $g2Button1, $g2Button2, $g2Checkbox1, $g2Checkbox2, $g2Label7, $g2List, 0) EndSwitch WEnd EndFunc Func _SetSwitchData($g2Combo1, $g2Combo2, $g2Combo3) $sInstaller = GUICtrlRead($g2Combo1) GUICtrlSetData($g2Combo2, "") If $sInstaller = "Ghost Installer" Then GUICtrlSetData($g2Combo2, "-s", "-s") ElseIf $sInstaller = "Inno Setup" Then GUICtrlSetData($g2Combo2, "/silent|/verysilent|/sp- /silent /norestart|/verysilent /norestart", "/silent") ElseIf $sInstaller = "Install Shield" Then GUICtrlSetData($g2Combo2, "/S|/S /NCRC", "/S") ElseIf $sInstaller = "Microsoft Hotfix Package" Then GUICtrlSetData($g2Combo2, "/passive|/passive /norestart|/u|/u /z|/q|/q /r:n|/q:a|/qb|/qn|/q:a /r:n", "/passive /norestart") GUICtrlSetData($g2Combo3, "Patches/Updates") ElseIf $sInstaller = "MSI Package" Then GUICtrlSetData($g2Combo2, "/qb|/qn", "/qb") ElseIf $sInstaller = "Nullsoft (NSIS)" Then GUICtrlSetData($g2Combo2, "/S", "/S") ElseIf $sInstaller = "Wise Installer" Then GUICtrlSetData($g2Combo2, "/s", "/s") Else GUICtrlSetData($g2Combo2, "-s|/silent|/verysilent|/sp- /silent /norestart|/verysilent /norestart|/S|/S /NCRC|/passive|/passive /norestart|/u|/u /z|/q|/q /r:n|/q:a|/qb|/qn|/q:a /r:n|/S|/s") EndIf EndFunc Func _EnableDisableControls($g2Input1, $g2Combo1, $g2Combo2, $g2Combo3, $g2Input2, $g2Button1, $g2Button2, $g2Checkbox1, $g2Checkbox2, $g2Label7, $g2List, $01) GUICtrlSetState($g2Input1, ($01 = 1) ? $GUI_ENABLE : $GUI_DISABLE) GUICtrlSetState($g2Combo1, ($01 = 1) ? $GUI_ENABLE : $GUI_DISABLE) GUICtrlSetState($g2Combo2, ($01 = 1) ? $GUI_ENABLE : $GUI_DISABLE) GUICtrlSetState($g2Combo3, ($01 = 1) ? $GUI_ENABLE : $GUI_DISABLE) GUICtrlSetState($g2Input2, ($01 = 1) ? $GUI_ENABLE : $GUI_DISABLE) GUICtrlSetState($g2Checkbox1, ($01 = 1) ? $GUI_HIDE : $GUI_SHOW) GUICtrlSetState($g2Checkbox2, ($01 = 1) ? $GUI_ENABLE : $GUI_DISABLE) GUICtrlSetState($g2Button1, ($01 = 1) ? $GUI_ENABLE : $GUI_DISABLE) GUICtrlSetState($g2Button2, ($01 = 1) ? $GUI_ENABLE : $GUI_DISABLE) GUICtrlSetState($g2Label7, ($01 = 1) ? $GUI_SHOW : $GUI_HIDE) GUICtrlSetState($g2List, ($01 = 1) ? $GUI_DISABLE : $GUI_ENABLE) EndFunc Func _ClearAndSetInputs($g2List, $g2Combo1, $g2Combo2, $g2Combo3, $g2Input1, $g2Input2, $g2Label7, $g2Checkbox1, $g2Checkbox2, $aSW, $iSWList = 0) GUICtrlSetData($g2List, "") GUICtrlSetData($g2Input1, "") GUICtrlSetData($g2Input2, "") GUICtrlSetData($g2Combo1, "") GUICtrlSetData($g2Combo2, "") GUICtrlSetData($g2Combo3, "") GUICtrlSetData($g2Combo1, "Ghost Installer|Inno Setup|Install Shield|Microsoft Hotfix Package|MSI Package|Nullsoft (NSIS)|Wise Installer") _SetSwitchData($g2Combo1, $g2Combo2, $g2Combo3) GUICtrlSetData($g2Combo3, "Audio/Video/Photo|System Tools|Internet|Games|Miscellaneous|Patches/Updates|Productivity", "Miscellaneous") GUICtrlSetState ($g2Checkbox2, $GUI_UNCHECKED) GUICtrlSetData($g2List, "") $iIsChecked = GUICtrlRead($g2Checkbox1) If IsArray($aSW) Then For $i = 1 To $aSW[0][0] GUICtrlSetData($g2List, $aSW[$i][0]) Next EndIf EndFunc Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) Local $hWndFrom, $iIDFrom, $iCode, $hWndEdit $hWndFrom = $lParam $iIDFrom = _WinAPI_LoWord($wParam) $iCode = _WinAPI_HiWord($wParam) If $iCode = $LBN_DBLCLK AND $iIDFrom = $g2List Then $sClicked = GUICtrlRead($g2List) GUICtrlSendToDummy($idDummy, $sClicked) EndIf EndFunc Func _InstallOrder($aInstallList) GUISetState(@SW_DISABLE, $Form1) $Form5 = GUICreate("Installation Order", 423, 292) $g5Label1 = GUICtrlCreateLabel("Highlight software and click the up and down arrows to change order of installation", 16, 3, 393, 17) $g5List1 = GUICtrlCreateList("", 16, 24, 321, 253, $LBS_NOTIFY) $g5Button1 = GUICtrlCreateButton(ChrW(8593), 344, 112, 35, 25, $WS_GROUP) $g5Button2 = GUICtrlCreateButton(ChrW(8595), 344, 144, 35, 25, $WS_GROUP) $g5Button3 = GUICtrlCreateButton("Done", 351, 251, 59, 25, $WS_GROUP) GUISetState(@SW_SHOW) For $i = 1 To $aInstallList[0][0] GUICtrlSetData($g5List1, $aInstallList[$i][3]) Next While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE GUISetState(@SW_ENABLE, $Form1) GUIDelete($Form5) Return $aInstallList ExitLoop Case $g5Button1 $sRead = GUICtrlRead($g5List1) If $sRead <> "" Then $iArrayPos = _ArraySearch($aInstallList, $sRead, Default, Default, Default,Default,Default, 3) If $iArrayPos > 1 Then _ArraySwap($aInstallList, $iArrayPos, $iArrayPos - 1) EndIf GUICtrlSetData($g5List1, "") For $i = 1 To $aInstallList[0][0] GUICtrlSetData($g5List1, $aInstallList[$i][3]) Next EndIf Case $g5Button2 $sRead = GUICtrlRead($g5List1) If $sRead <> "" Then $iArrayPos = _ArraySearch($aInstallList, $sRead, Default, Default, Default,Default,Default, 3) If $iArrayPos < $aInstallList[0][0] Then _ArraySwap($aInstallList, $iArrayPos, $iArrayPos + 1) EndIf GUICtrlSetData($g5List1, "") For $i = 1 To $aInstallList[0][0] GUICtrlSetData($g5List1, $aInstallList[$i][3]) Next EndIf Case $g5Button3 GUISetState(@SW_ENABLE, $Form1) GUIDelete($Form5) Return $aInstallList ExitLoop EndSwitch WEnd EndFunc Func _QueryUser() $iShowConfigSWDiag = IniRead($fIniConfig, "Settings", "ShowConfigSWDiag", 4) If $iShowConfigSWDiag = 4 Then GUISetState(@SW_DISABLE, $Form1) $iStyle2 = BitOr( $WS_CAPTION, $WS_POPUP, $WS_SYSMENU) $Form6 = GUICreate("Attention", 423, 119, Default, Default, $iStyle2) $g6Label1 = GUICtrlCreateLabel("You have unconfigured software. Do you want to configure them now?", 32, 32, 338, 17) $g6Button1 = GUICtrlCreateButton("Yes", 184, 72, 99, 25, $WS_GROUP) $g6Button2 = GUICtrlCreateButton("No", 296, 72, 99, 25, $WS_GROUP) $g6Checkbox1 = GUICtrlCreateCheckbox("Do not ask again", 32, 80, 121, 17) GUISetState() $g6ExitButton = _GUICtrlMenu_GetSystemMenu($Form6) _GUICtrlMenu_EnableMenuItem($g6ExitButton, $SC_CLOSE, 1, False) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $g6Button1 $iCBRead = GUICtrlRead($g6Checkbox1) If $iCBRead = 1 Then IniWrite($fIniConfig, "Settings", "ShowConfigSWDiag", $iCBRead) EndIf GUISetState(@SW_ENABLE, $Form1) GUIDelete($Form6) Return 1 ExitLoop Case $g6Button2 $iCBRead = GUICtrlRead($g6Checkbox1) If $iCBRead = 1 Then IniWrite($fIniConfig, "Settings", "ShowConfigSWDiag", $iCBRead) EndIf GUISetState(@SW_ENABLE, $Form1) GUIDelete($Form6) Return 0 ExitLoop EndSwitch WEnd EndIf EndFunc Func _About() GUISetState(@SW_DISABLE, $Form1) Local $Form3, $hGraphic Local Const $iWidth = 400, $iHeight = 150, $iBgColor = 0x303030 $Form3 = GUICreate("About Software Installer", 400, 300) GUISetBkColor($iBgColor, $Form3) GUISetState(@SW_SHOW) Local $hGraphics = _GDIPlus_GraphicsCreateFromHWND($Form3) _GDIPlus_GraphicsSetSmoothingMode($hGraphics, $GDIP_SMOOTHINGMODE_HIGHQUALITY) ;sets the graphics object rendering quality (antialiasing) Local $hBrush = _GDIPlus_BrushCreateSolid(0xFFEE88BB) _GDIPlus_Startup() $hGraphic = _GDIPlus_GraphicsCreateFromHWND($Form3) _GDIPlus_GraphicsFillRect($hGraphic, 0, 150, 400, 300, $hBrush) $Label1 = GUICtrlCreateLabel("Software Installer", 48, 16, 304, 44) GUICtrlSetFont(-1, 26, 400, 0, "Arial Rounded MT Bold") GUICtrlSetColor(-1, 0xC0C0C0) $Label2 = GUICtrlCreateLabel("Version " & $sVersion, 48, 56, 84, 22) GUICtrlSetFont(-1, 12, 400, 0, "Arial") GUICtrlSetColor(-1, 0xC0C0C0) $Label3 = GUICtrlCreateLabel("Click here to go to the home page for this software", 48, 240, 300, 21) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x000080) GUICtrlSetBkColor(-1, 0x434E54) GUICtrlSetCursor (-1, 0) $Label4 = GUICtrlCreateLabel("Scripted with AutoIt", 48, 200, 115, 20) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x808080) $Label5 = GUICtrlCreateLabel("This software is designed to help automate unattended and/or silent software installation.", 56, 96, 282, 40) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x00FFFF) While 1 $nmsg = GUIGetMsg() Switch $nMsg Case $Label3 ShellExecute ("https://www.autoitscript.com/forum/topic/143730-software-installer/") Case $GUI_EVENT_CLOSE _GDIPlus_BrushDispose($hBrush) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() GUISetState(@SW_ENABLE, $Form1) GUIDelete($Form3) ExitLoop EndSwitch WEnd EndFunc Archive of version 1.0:
       
    • By JuanFelipe
      Hello guys!
      I have a problem with a script, in the past I made a program and it worked perfect, I recently used it again and it already stands still in one step, the problem is a Javascript event that changed but now I cannot execute it.
       
      <td colspan="2" align="center"><input type="button" id="Buscar" name="Buscar" value="Buscar" onclick="javascript:enviarForma(document.obtenercasosPersonaPorDocumento,'0');" class="boton"></td>  
      Previously I used this code and it worked, but now it does nothing
      $botonconsulta = _IEGetObjByName($oIE,"Buscar") _IEAction($botonconsulta, 'click') _IELoadWait($oIE)  
      Now I have tried the following codes but none works.
       
      ;==================== 1 _IEHeadInsertEventScript($oIE, "document", "onclick", "javascript:enviarForma(document.obtenercasosPersonaPorDocumento,'0');") ControlClick("SUPER CELAC", "", "[CLASS:Internet Explorer_Server; INSTANCE:1]") _IELoadWait($oIE) ;==================== 2 $forma = $oIE.document.obtenercasosPersonaPorDocumento $oIE.Navigate("JavaScript:enviarForma("&$forma&",""0"");") _IELoadWait($oIE) ;==================== 3 $boton = _IEGetObjById($oIE, "Buscar") $boton.document.parentwindow.execScript("enviarForma(document.obtenercasosPersonaPorDocumento,'0');", "javascript") I hope you can guide me, because I think the error is in the parameters that the javascript function receives but I don't know how to send it, here I leave the first part of the JavaScript function.
      function enviarForma(frm,tipoForma){ var bExisteDatoConsulta = false; var bError=true; var mensajeError=""; switch (tipoForma) { //--Forma documento case "0": if (validar_campo_no_vacio_no_print(frm.numeroDocumento)) { if (!isNum(frm.numeroDocumento.value)) { bError = false; mensajeError += "El número de documento debe ser un valor numérico\n"; } bExisteDatoConsulta = true; } else { mensajeError += "Debe digitar un número de documento\n"; } break;  Thanks!
×
×
  • Create New...