Leaderboard
Popular Content
Showing content with the highest reputation on 09/19/2018 in all areas
-
The DOM allows to do anything with elements and their contents, but first we need to reach the corresponding DOM object, get it into a variable, and then we are able to modify it. * Well, this little tool (although it is not very nice aesthetically) allows you to get visually a "selector" usable to reference DOM objects. Once you have the "selector" of an element you can pass it to the javascript querySelector() function that will return a reference to that element. To use this tool you have to: 1) open the web page you want to inspect into IE browser 2) run this script (if it find more instances of IE running, it allows you to chose one) 3) move the mouse over the browser. The "selector" of the element below the pointer is catched automatically while hovering. To copy the selector in the clipboard just right click on the element. As you can see, while hovering, the element pointed by the mouse is highlighted with a thin red dotted frame to allow you to better "take aim" when the selector is copied to the clipboard a little acoustic signal is emitted as a confirm, then you can paste it in your listing where you need it. I hope it can come in handy and save you time when you need to automate a site .... have fun (debugged on Sept. 30 2018) #include <IE.au3> #include <GUIConstantsEx.au3> #include <GuiListBox.au3> #include <WindowsConstants.au3> #include <Misc.au3> ; for _IsPressed (23 END key) Global $hDLL = DllOpen("user32.dll") ; following global variables are automatically updated by events from the browser ; ------------------------------------------------------------------------------------- Global $g_iMouseX, $g_iMouseY ; coordinates of the mouse while mooving over the browser Global $bCopySelector = False ; becomes True when you right click on wanted element ; ------------------------------------------------------------------------------------- Global $oIE = _Get_IE() ; get IE instance to inspect If IsObj($oIE) Then $hIE = _IEPropertyGet($oIE, "hwnd") WinActivate($hIE) _InspectElements() EndIf DllClose($hDLL) Exit Func _InspectElements() ; it uses the global variable $oIE as source ; --- set IE to interact with AutoIt --- Local $oDocument Do ; wait for document Sleep(250) $oDocument = $oIE.document Until IsObj($oDocument) Local $oWindow = $oDocument.ParentWindow ; create a reference to the javascript eval method ; in the body section of the dovument $oWindow.setTimeout("document.body.JSeval = eval; ", 0) ; attach the $JSeval variable to the javascript eval method Local $JSeval Do $JSeval = Execute('$oIE.Document.body.JSeval') Until IsObj($JSeval) ; --------------------------------------------- ; Inject Javascript functions/elements to $oIE ; --------------------------------------------- ; Get the DOM path of an element (a CSS selector) ; ----------------------------------------------- ; This javascript function returns the CSS selector of the passed element. ; You can then use the returned path to get a reference to the pointed ; element by the QuerySelector() javascript function ; function copied from the following link: ; https://stackoverflow.com/questions/5728558/get-the-dom-path-of-the-clicked-a ; see answer by "Aleksandar Totic" (thanks to him) Local $sJScript = "" & _ " function getDomPath(el) {" & _ " if (!el) {" & _ " return;" & _ " }" & _ " var stack = [];" & _ " var isShadow = false;" & _ " while (el.parentNode != null) {" & _ " var sibCount = 0;" & _ " var sibIndex = 0;" & _ " for ( var i = 0; i < el.parentNode.childNodes.length; i++ ) {" & _ " var sib = el.parentNode.childNodes[i];" & _ " if ( sib.nodeName == el.nodeName ) {" & _ " if ( sib === el ) {" & _ " sibIndex = sibCount;" & _ " }" & _ " sibCount++;" & _ " }" & _ " }" & _ " var nodeName = el.nodeName.toLowerCase();" & _ " if (isShadow) {" & _ " nodeName += ""::shadow"";" & _ " isShadow = false;" & _ " }" & _ " if ( sibCount > 1 ) {" & _ " stack.unshift(nodeName + ':nth-of-type(' + (sibIndex + 1) + ')');" & _ " } else {" & _ " stack.unshift(nodeName);" & _ " }" & _ " el = el.parentNode;" & _ " if (el.nodeType === 11) {" & _ " isShadow = true;" & _ " el = el.host;" & _ " }" & _ " }" & _ " stack.splice(0,1);" & _ " return stack.join(' > ');" & _ " }" ; more infos here: https://www.kirupa.com/html5/finding_elements_dom_using_querySelector.htm ; Inject the above javascript function contained in the $sJScript variable into the document _JS_Inject($oIE, $sJScript) Local $_getDomPath ; a reference to call above function from AutoIt Do Sleep(250) $_getDomPath = $jsEval("getDomPath") Until IsObj($_getDomPath) ; ; ------------------- ; hook some IE events ; ------------------- Local $oEventObjects[2], $oEventsSource $oEventsSource = $oIE.document.documentElement ; element we want catch events from ; https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/aa769636(v=vs.85) $oEventObjects[0] = ObjEvent($oEventsSource, "_HTMLElementEvents2_", "HTMLElementEvents2") ; https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/aa768283(v%3dvs.85) $oEventObjects[1] = ObjEvent($oIE, "_IEEvent_", "DWebBrowserEvents2") ; open a GUI where to show some element's properties ; -------------------------------------------------- Local $hGUIMain = GUICreate("Info", 500, 140, -1, -1, -1, $WS_EX_TOPMOST) Local $hProperties = GUICtrlCreateEdit("", 0, 0, 500, 140) GUICtrlSetFont(-1, 9, -1, -1, "Courier New") GUISetState() ;Show GUI ; -------------------------------------------------- ; --------- ; Main loop ; --------- Local $iMouseX, $iMouseY, $oElement, $oNewElement, $sSelector Local $oGotElement, $sElementInfos Local $sSaved_StyleOutline, $sSaved_StyleOutline2 ; Loop until the user exits. While IsObj($oIE) Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop ; ---> end EndSwitch If ($g_iMouseX <> $iMouseX) Or ($g_iMouseY <> $iMouseY) Then $iMouseX = $g_iMouseX $iMouseY = $g_iMouseY ; $oElement = $oIE.document.elementFromPoint($iMouseX, $iMouseY) ; <-- this way is slower $oNewElement = $JSeval('document.elementFromPoint(' & $iMouseX & ',' & $iMouseY & ');') If $oNewElement <> $oElement Then If IsObj($oElement) Then $oElement.style.outline = $sSaved_StyleOutline $oElement = $oNewElement ; $bSelfie = False ; $iSelf_Timer = TimerInit() $sSaved_StyleOutline = $oElement.style.outline ; save new element's original outline style $sSelector = $_getDomPath($oElement) ; get CSS path If $sSelector <> "" Then ; We could use the $oNewElement, but just to proof that $sSelector is OK ; we get again a reference to the new pointed element using it's $sSelector $oGotElement = $JSeval('document.querySelector("' & $sSelector & '");') ; <-- how to use a selector $oGotElement.style.outline = "1px dashed red" ; mark new pointed element ; https://css-tricks.com/ $sElementInfos = "" & _ "nodeName: " & $oGotElement.nodeName & @CRLF & _ "id: " & $oGotElement.getAttribute('id') & @CRLF & _ "class: " & $oGotElement.getAttribute('class') & @CRLF & _ "type: " & $oGotElement.getAttribute('type') & @CRLF & _ "---------" & @CRLF & _ $sSelector ControlSetText($hGUIMain, "", $hProperties, $sElementInfos) EndIf EndIf EndIf ; $bCopySelector is setted to True by the right-click event on an element, ; see Volatile Func _HTMLElementEvents2_onContextmenu($oEvent) near script bottom If $bCopySelector And ($sSelector <> "") Then ; And (TimerDiff($iSelf_Timer) > $bSelfie_Delay) Then ; $sSaved_StyleOutline2 = $oGotElement.style.outline $oGotElement.style.outline = "5px dotted #ff0066" ; mark copied element ClipPut($sSelector) $sElementInfos &= @CRLF & "selector copied to ClipBoard" ControlSetText($hGUIMain, "", $hProperties, $sElementInfos) Beep(2000, 50) $bCopySelector = False Sleep(250) $oGotElement.style.outline = $sSaved_StyleOutline2 ; ToolTip('') EndIf If _IsPressed("23", $hDLL) Then ; END key pressed If IsObj($oElement) Then $oElement.style.outline = $sSaved_StyleOutline WinActivate($hGUIMain) ; WinSetState($hGUIMain, "", @SW_SHOW) $aWin = WinGetPos($hGUIMain) MouseMove($aWin[0] + $aWin[2] / 2, $aWin[1] + $aWin[3] / 2, 0) EndIf WEnd ; the end ; ------------------------------------------ For $i = 0 To UBound($oEventObjects) - 1 ; Tell IE we don't want to receive events. $oEventObjects[$i] .Stop $oEventObjects[$i] = 0 Next $oIE = 0 ; Remove IE from memory GUIDelete($hGUIMain) ; Remove GUI ; ------------------------------------------ EndFunc ;==>_InspectElements Func _Get_IE() ; Example 5 from the _IEAttach help ; Create an array of object references to all current browser instances ; The first array element will contain the number of instances found Local $aIE[1] $aIE[0] = 0 Local $i = 1, $oIEx While 1 $oIEx = _IEAttach("", "instance", $i) If @error = $_IEStatus_NoMatch Then ExitLoop ReDim $aIE[$i + 1] $aIE[$i] = $oIEx $aIE[0] = $i $i += 1 WEnd If $aIE[0] > 0 Then If $aIE[0] = 1 Then Return $aIE[1] ; only one IE is running, return this then ; ; Create a little list box to choose the IE instance from Local $hChoose_IE = GUICreate("IE Instances", 600, 350) Local $Label1 = GUICtrlCreateLabel($aIE[0] & " running Instances of IE browser found, click the one you want to attach to then click on 'ok'", 5, 5, 590, 20) Local $List1 = GUICtrlCreateList("", 5, 30, 590, 300, BitOR($LBS_STANDARD, $LBS_EXTENDEDSEL)) Local $hButton_choosed = GUICtrlCreateButton("OK", 5, 325, 590, 20) For $i = 1 To $aIE[0] GUICtrlSetData($List1, $i & ") " & _IEPropertyGet($aIE[$i], "locationurl")) Next GUISetState(@SW_SHOW) While 1 ; wait for a selection Switch GUIGetMsg() Case $GUI_EVENT_CLOSE GUIDelete($hChoose_IE) Return False Case $hButton_choosed $aSelected = _GUICtrlListBox_GetSelItems($List1) If $aSelected[0] Then GUIDelete($hChoose_IE) Return $aIE[$aSelected[1] + 1] Else MsgBox(0, "Info", "Please select an item") EndIf EndSwitch WEnd Else MsgBox(0, 'error', "Sorry" & @CRLF & @CRLF & "no running IE instances found") EndIf EndFunc ;==>_Get_IE ; this function creates a javascript script into the html document ; of the passed $oIE object using the createElement method. Func _JS_Inject($oIE, $sJScript, $bIsUrl = False) ; ; get a reference to the document object Local $objDocument = $oIE.document ; Local $oScript = $objDocument.createElement('script') ; $oScript.type = 'text/javascript' If $bIsUrl Then $oScript.src = $sJScript ; works if $sJScript is a link to a js listing (url) Else ; (https://stackoverflow.com/questions/35213147/difference-between-text-content-vs-inner-text) ; $oScript.innerText = $sJScript $oScript.TextContent = $sJScript ; works if $sJScript contains the listing itself EndIf ; $objDocument.getElementsByTagName('head').item(0).appendChild($oScript) ; $objDocument.getElementsByTagName('head').item(0).removeChild($oScript); ; EndFunc ;==>_JS_Inject ; ------------------------------------------------------------------- ; following function(s) are called by registered $oIE elements events ; ------------------------------------------------------------------- ; ; The function automatically fired by an event ; will receive as parameter an Event Obj. ; This obj has properties related to ; the object that fired the event. ; See following link: ; https://msdn.microsoft.com/en-us/library/aa703876(v=vs.85).aspx ; function called by the mousemove event ; we use this to update 2 global variables: Volatile Func _HTMLElementEvents2_onMousemove($oEvent) $g_iMouseX = $oEvent.clientX $g_iMouseY = $oEvent.clientY EndFunc ;==>_HTMLElementEvents2_onMousemove ; function called by the contextmenu event ; we use this to update 1 global variable ; and we also neutralize this event: Volatile Func _HTMLElementEvents2_onContextmenu($oEvent) $oEvent.cancelBubble = True ; event propagation cancelled $oEvent.returnValue = False ; prevent default behaviour $bCopySelector = True ; when True, selector will be copied to clipboard in main loop EndFunc ;==>_HTMLElementEvents2_onContextmenu ; https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/aa768280%28v%3dvs.85%29 Func _IEEvent_BeforeNavigate2($oIEpDisp, $sIEURL, $iIEFlags, $sIETargetFrameName, $sIEPostData, $iIEHeaders, $bIECancel) ;ConsoleWrite("Debug: navigate away cancelled." & @CRLF) ; https://stackoverflow.com/questions/6526876/how-to-cancel-or-dispose-current-navigation-at-webbrowser-element $oIE.stop EndFunc ;==>_IEEvent_BeforeNavigate2 Here is a simple example on how a "selector" can be used in AutoIt. suppose we want automate the login to the AutoIt site with our username and password. I've already prepared a very simple "template" where are missing some important parts without which the script can't work. Missing parts are the references to the elements of the AutoIt web page that we have to manage by our script. well, here is where the tool I have just posted here above comes to our help. follow this steps: 1) in IE open the AutoIt site at the forum page (https://www.autoitscript.com/forum/) 2) run the above tool (select the IE instance and/or bring it to front if needed) 3) when the script is "ready", move the mouse over the "Existing user? Sign In" string and right click the mouse button. Doing so the "selector" of that element is copied to the clipboard. Now we can paste it in our AutoLogIt.au3 script as value of the $sSignIn variable. 4) now click on the "Existing user? Sign In" to open the "Sig In" session from where we will copy selectors of each of the 2 input box Username and Password, in the same way as we have already done in step 3, and paste those selectors to the $sInputUserId and $sInputPasswd variables respectively. 5) do the same for the "Sign In" Button and paste it's selector to the $sSignInButn variable 6) of course also fill the $sMyUserId and $sMyPasswd variables with your data. That's It. Run the AutoLogIt script and it should Log you on automatically to the forum. AutoLogIt.au3 #include <ie.au3> $sMyUserId = "" ; <-- your userid here $sMyPasswd = "" ; <-- your password here ; set selectors here $sSignIn = "" ; <-- SigIn element selector here $sInputUserId = "" ; <-- UserId input selector here $sInputPasswd = "" ; <-- Password input selector here $sSignInButn = "" ; <-- Sig In button selector here $oIE = _IECreate("https://www.autoitscript.com/forum/") ; here is how to use the QuerySelector javascript function $hDOM_Element = $oIE.document.QuerySelector($sSignIn) ; get the "sign in" link element ; perform a click action on the above element $hDOM_Element.click() ; or _IEAction($hDOM_Element, "click") as well ; fill the username input $hDOM_Element = $oIE.document.QuerySelector($sInputUserId) $hDOM_Element.value = $sMyUserId ; fill the password input $hDOM_Element = $oIE.document.QuerySelector($sInputPasswd) $hDOM_Element.value = $sMyPasswd ; .... or also using the dot notation directly .... $oIE.document.QuerySelector($sSignInButn).click() Sleep(5000) ; this should logout $sMenu = "body > div:nth-of-type(2) > header > div > ul > li:nth-of-type(6) > a:nth-of-type(2)" $oIE.document.QuerySelector($sMenu).click() $sLogOut = "body > ul > li:nth-of-type(9) > a" $oIE.document.QuerySelector($sLogOut).click()2 points
-
[SOLVED] How to convert a outline.showlevels VBA code to Autoit
JLogan3o13 and one other reacted to water for a topic
"unbreakable" 2 minutes after the first DAU (dumbest assumable user) has laid his hand on your script it will be broken. Or even faster That's what happens to me all the time2 points -
HMW - Hide my Windows Current Version: v4 (2024-Oct-18) HMW is a free program to stash away the Windows on your desktop. With HMW you can set any program Window as hidden, while the program itself will run silently in the background. Additionally all the Hotkeys used can be customized to your needs. [*] With HMW you can improve your “Visual Privacy”. No-one looking at your desktop will see instantly what programs you’re running anymore. [*] You can hide away programs which have long processing runs, cluttering your desktop and impairing the overall usability. [*] HMW is fully portable, the settings are stored in a "hmw.ini" file created in the scriptdir. It works fine on my XP-32bit, Win7-64bit, Win8(.1)-64bit and Win10 machines. If you find bugs please let me know. The source and executable can be downloaded from my site: https://funk.eu Kudos to Ascend4nt, Prog@ndy, UEZ, Yashied, Tuape & wraithdu for parts of the code. Please let me know if you found some piece of code in the source for which I forgot to mention a credit. Enjoy, let me know what you think of HMW and with Best Regards1 point
-
File Delete Fail
FrancescoDiMuro reacted to careca for a topic
Im confused, what is $sFileZoekLog ? You mention a msgbox and the code 0, but isn't that from fileexists instead of filedelete?1 point -
@BigDaddyO Probably caused by some Javascript "voodoo" going on in the background.1 point
-
When you find that first point, you can logically remove the top left area from your search. you can then continue to run new searches in the remaining 3 quadrants Edit...I think it goes a row at a time. I'll need to review the help file.1 point
-
@BigDaddyO See prior discussion starting here --1 point
-
I've never had good success with pixel search. Have you tried image search? Assuming the pixels don't change on the app it should find what you're looking for the first time. I'll provide a link to a post were I helped another user to get it working. I only use it when there isn't an arcpy function for ArcMap10.6.1 point
-
@rakesh2804 Thanks for the kind reply Someone could code for you, but, less than someone has some spare time ( most of the users here have a work ), you have to know that he would like to be paid for his work. Some users here gave you little/big hints, but they can't code for you "just for fun", since when you ask for a working application, the fun goes "back" the seriousness of the work, and so, the time spent to think and to program couldn't be "unpaid". This is my opinion. By the way, coding becomes "child's play" when you get into it, studying how things work, and how you can do just one thing in a million ways, even better. Since AutoIt is a BASIC-like language, you can start from learning a bit of VBA, and C++. There are a lot of concepts which came from both of those programming languages. Help file is, and always be the "best friend" of the programmer, since you can find in it examples, and detailed information about the use of the functions, and basic concepts about AutoIt. I hope you'll have the time to learn AutoIt, since it is a fun programming language, and it is extremly powerful ( even thanks to this community ). So, best wishes to you, and happy programming Best Regards.1 point
-
Hi, This is not strictly true. When AutoIt creates a control using one of the GUICtrlCreate* functions it adds its details to an internal array and returns the index of that array as its "ControlID" - this value is used internally by AutoIt to identify the controlwhen you use any of the GUICtrl* functions. To allow as many controls as possible, AutoIt looks for the first available empty index in this array to add the new control - normally this means that the returned ControlIDs increase by 1 for each created control. This allows for some easy manipulation of groups of controls by using their ControlIds as the loop counter - as you can see here: #include <GUIConstantsEx.au3> $hGUI = GUICreate("Test", 500, 500) $iStart = GUICtrlCreateDummy() ConsoleWrite("Start : " & $iStart & @CRLF) ; Should be 3 For $i = 1 To 5 $iCID = GUICtrlCreateLabel("", 10, 10 + (50 * $i), 200, 40) ; Display the returned ControlID - I have no idea what Autoit does with elements 1 & 2 !!!!! GUICtrlSetData(-1, $iCID) ; Set colour to red GUICtrlSetBkColor(-1, 0xFFCCCC) Next $iEnd = GUICtrlCreateDummy() ConsoleWrite("End: " & $iEnd & @CRLF) ; Should be 9 $cAlter_1 = GUICtrlCreateButton("Change 1", 10, 450, 80, 30) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cAlter_1 ; Set label CIDs as the loop counter For $i = $iStart + 1 To $iEnd - 1 ; Change label colours GUICtrlSetBkColor($i, 0xCCFFCC) Next EndSwitch WEnd But look what happens if you delete a previously created control and then create another group of controls. Change the colour of the first group, then press the Delete, Create and Alter_2 buttons in order: #include <GUIConstantsEx.au3> Global $cLabel_6, $cLabel_10 $hGUI = GUICreate("Test", 500, 500) $cLabel_1 = GUICtrlCreateLabel("", 10, 10, 200, 40) ; Display the returned ControlID - I have no idea what Autoit does with elements 1 & 2 !!!!! GUICtrlSetData(-1, $cLabel_1) ; Set colour to red GUICtrlSetBkColor(-1, 0xFFCCCC) $cLabel_2 = GUICtrlCreateLabel("", 10, 60, 200, 40) GUICtrlSetData(-1, $cLabel_2) GUICtrlSetBkColor(-1, 0xFFCCCC) $cLabel_3 = GUICtrlCreateLabel("", 10, 110, 200, 40) GUICtrlSetData(-1, $cLabel_3) GUICtrlSetBkColor(-1, 0xFFCCCC) $cLabel_4 = GUICtrlCreateLabel("", 10, 160, 200, 40) GUICtrlSetData(-1, $cLabel_4) GUICtrlSetBkColor(-1, 0xFFCCCC) $cLabel_5 = GUICtrlCreateLabel("", 10, 210, 200, 40) GUICtrlSetData(-1, $cLabel_5) GUICtrlSetBkColor(-1, 0xFFCCCC) $cAlter_1 = GUICtrlCreateButton("Change 1", 10, 450, 80, 30) $cAlter_2 = GUICtrlCreateButton("Change 2", 360, 450, 80, 30) GUICtrlSetState($cAlter_2, $GUI_DISABLE) $cDelete = GUICtrlCreateButton("Delete", 110, 450, 80, 30) $cCreate = GUICtrlCreateButton("Create", 260, 450, 80, 30) GUICtrlSetState($cCreate, $GUI_DISABLE) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cAlter_1 ; Set label CIDs as the loop counter For $i = $cLabel_1 To $cLabel_5 ; Change left label colours GUICtrlSetBkColor($i, 0xCCFFCC) Next Case $cAlter_2 For $i = $cLabel_6 To $cLabel_10 ; Change right label colours - or does it? <<<<<<<<<<<<<<<<<<<<<<<<<<< GUICtrlSetBkColor($i, 0xFFFFCC) Next Case $cDelete ; Delete one of the GUICtrlDelete($cLabel_3) GUICtrlSetState($cCreate, $GUI_ENABLE) Case $cCreate $cLabel_6 = GUICtrlCreateLabel("", 260, 10, 200, 40) GUICtrlSetData(-1, $cLabel_6) GUICtrlSetBkColor(-1, 0xCCCCFF) $cLabel_7 = GUICtrlCreateLabel("", 260, 60, 200, 40) GUICtrlSetData(-1, $cLabel_7) GUICtrlSetBkColor(-1, 0xCCCCFF) $cLabel_8 = GUICtrlCreateLabel("", 260, 110, 200, 40) GUICtrlSetData(-1, $cLabel_8) GUICtrlSetBkColor(-1, 0xCCCCFF) $cLabel_9 = GUICtrlCreateLabel("", 260, 160, 200, 40) GUICtrlSetData(-1, $cLabel_9) GUICtrlSetBkColor(-1, 0xCCCCFF) $cLabel_10 = GUICtrlCreateLabel("", 260, 210, 200, 40) GUICtrlSetData(-1, $cLabel_10) GUICtrlSetBkColor(-1, 0xCCCCFF) GUICtrlSetState($cAlter_2, $GUI_ENABLE) EndSwitch WEnd Not quite what you expected eh? You can see that the first of the new labels has taken the ControlID of the deleted label in the first group and so all the buttons and some of the first group of labels change colour as well - as their ControlIDs are now included in the loop. The moral of the story? Be very careful when using ControlIDs as loop counters if any controls can be deleted anywhere in the script - and remember that deleting whole GUIs also deletes their controls automatically. How should you action groups of controls? Store their returned ControlIDs in an array and loop through them - that way you will only ever use the correct values. M231 point
-
... and _Excel_RangeFind to find the row with todays date.1 point
-
Look at the Excel UDF functions in the help file, starting with the following two functions. _Excel_RangeRead _Excel_RangeWrite1 point
-
How to create a GUI to Choose and install application for the chosen catagory?
rakesh2804 reacted to Subz for a topic
Don't have any time to comment this but here is a another dynamic version (only requires ini file updated) with radio buttons and checkboxes. Save following as: Software.ini. [Departments] All = Department Finance = Department HR = Department IT = Department Operation = Department Procurement = Department Projects = Department [Department: All] Microsoft Office = 2013 Adobe Flash = 17 Java Runtime = 18 [Department: Finance] Microsoft Office = 2016 Adobe Flash = 17 Java Runtime = 18 [Department: HR] Microsoft Office = 2016 Adobe Flash = 17 Java Runtime = 18 [Department: IT] Microsoft Office = 2010 Adobe Flash = 17 Java Runtime = 18 [Department: Operation] Microsoft Office = 2016 Adobe Flash = 17 Java Runtime = 18 [Department: Procurement] Microsoft Office = 2013 Adobe Flash = 17 Java Runtime = 18 [Department: Projects] Microsoft Office = 2016 Adobe Flash = 17 Java Runtime = 18 [Software: Microsoft Office] 2010 = @ScriptDir@\Microsoft\Office\2010\Setup.exe 2013 = @ScriptDir@\Microsoft\Office\2013\Setup.exe 2016 = @ScriptDir@\Microsoft\Office\2016\Setup.exe [Software: Adobe Flash] 16 = @ScriptDir@\Adobe\Flash\16\Setup.exe 17 = @ScriptDir@\Adobe\Flash\17\Setup.exe 18 = @ScriptDir@\Adobe\Flash\18\Setup.exe [Software: Java Runtime] 16 = @ScriptDir@\Oracle\JavaRT\16\Setup.exe 17 = @ScriptDir@\Oracle\JavaRT\17\Setup.exe 18 = @ScriptDir@\oracle\JavaRT\18\Setup.exe In the same folder run the following script: #include <Array.au3> #include <ComboConstants.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> Opt("ExpandVarStrings", 1) Global $g_sInifilepath = @ScriptDir & "\Software.ini" Global $g_aSoftware, $g_sDepartment Global $aDepartments = IniReadSection($g_sInifilepath, "Departments") If @error Then Exit _ArrayDelete($aDepartments, 0) _SelectDeparment() Func _SelectDeparment() Local $hGuiDepartment, $idDepartmentNext Local $yDepartments = 25 * UBound($aDepartments) + 45 Local $yDepartments = 45 $hGuiDepartment = GUICreate("Department", 165, 90 + (25 * UBound($aDepartments))) GUISetBkColor(0xFFFFFF) GUICtrlCreateLabel("Select Department", 15, 15, 135, 20) GUICtrlSetFont(-1, 12, 800, 0, "Calibri") GUICtrlSetColor(-1, 0x000000) For $i = 0 To UBound($aDepartments) - 1 Assign(StringStripWS($aDepartments[$i][0], 8), GUICtrlCreateRadio($aDepartments[$i][0], 15, $yDepartments, 135, 20)) GUICtrlSetFont(-1, 10, 800, 0, "Calibri") GUICtrlSetColor(-1, 0xFF0000) $yDepartments += 25 Next $idDepartmentNext = GUICtrlCreateButton("Next", 75, $yDepartments + 5, 75, 25) GUICtrlSetBkColor(-1, 0xA6CAF0) GUISetState() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE ExitLoop Case $idDepartmentNext For $i = 0 To UBound($aDepartments) - 1 ;~ Check which department is checked ;~ If no department is checked then continue displaying department selection dialogue If BitAND(GUICtrlRead(Eval($aDepartments[$i][0])), $GUI_CHECKED) = $GUI_CHECKED Then ;~ Check Ini file for "Department: <Department name>" to capture software assigned to this group. $g_aSoftware = IniReadSection($g_sInifilepath, "Department: " & GUICtrlRead(Eval($aDepartments[$i][0]), 1)) If @error Then MsgBox(16, "Department Error", 'Unable to find section "Department: ' & GUICtrlRead(Eval($aDepartments[$i][0]), 1)) ContinueLoop EndIf _ArrayDelete($g_aSoftware, 0) $g_sDepartment = GUICtrlRead(Eval($aDepartments[$i][0]), 1) GUIDelete($hGuiDepartment) _SelectSoftware() ExitLoop 2 EndIf Next EndSwitch WEnd EndFunc Func _SelectSoftware() Local $hSoftwareGui = GUICreate("Department: " & $g_sDepartment & " - Software", 330, 90 + (50 * UBound($g_aSoftware))) GUISetBkColor(0xFFFFFF) GUICtrlCreateLabel("Select Software", 15, 15, 135, 20) GUICtrlSetFont(-1, 14, 800, 0, "Calibri") GUICtrlSetColor(-1, 0x000000) Local $ySoftware = 45, $xVersions = 25, $yVersions = 65 For $i = 0 To UBound($g_aSoftware) - 1 $aVersions = IniReadSection($g_sInifilepath, "Software: " & $g_aSoftware[$i][0]) If @error Then ContinueLoop _ArrayDelete($aVersions, 0) Assign(StringStripWS($g_aSoftware[$i][0], 8), GUICtrlCreateCheckbox($g_aSoftware[$i][0], 15, $ySoftware, 135, 20)) GUICtrlSetFont(-1, 12, 800, 0, "Calibri") GUICtrlSetState(-1, $GUI_CHECKED) GUIStartGroup() For $j = 0 To UBound($aVersions) - 1 Assign(StringStripWS($g_aSoftware[$i][0] & $aVersions[$j][0], 8), GUICtrlCreateRadio($aVersions[$j][0], $xVersions, $yVersions, 115, 20)) GUICtrlSetFont(-1, 11, 800, 0, "Calibri") GUICtrlSetColor(-1, 0x000000) If $g_aSoftware[$i][1] = $aVersions[$j][0] Then GUICtrlSetState(-1, $GUI_CHECKED) $xVersions += 115 Next $xVersions = 25 $yVersions += 50 $ySoftware += 50 Next $idInstall = GUICtrlCreateButton("Install", 330 - 90, $yVersions - 15, 75, 25) GUICtrlSetFont(-1, 11, 800, 0, "Calibri") GUICtrlSetBkColor(-1, 0xA6CAF0) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $idInstall For $i = 0 To UBound($g_aSoftware) - 1 If BitAND(GUICtrlRead(Eval(StringStripWS($g_aSoftware[$i][0], 8))), $GUI_CHECKED) = $GUI_CHECKED Then $aVersions = IniReadSection($g_sInifilepath, "Software: " & $g_aSoftware[$i][0]) If @error Then ContinueLoop For $j = 0 To UBound($aVersions) - 1 If BitAND(GUICtrlRead(Eval(StringStripWS($g_aSoftware[$i][0] & $aVersions[$j][0], 8))), $GUI_CHECKED) = $GUI_CHECKED Then MsgBox(4096, $g_aSoftware[$i][0] & " - " & $aVersions[$j][0], "Install " & $g_aSoftware[$i][0] & ":" & $aVersions[$j][0] & " using the following command line" & @CRLF & $aVersions[$j][1]) EndIf Next EndIf Next EndSwitch WEnd EndFunc1 point -
How to create a GUI to Choose and install application for the chosen catagory?
rakesh2804 reacted to Jos for a topic
Hey, I was just kidding. I am not in this place to make money, just to have some sort of fun without commitments.1 point -
All functions from original Auto3Library by PaulIA were converted/implemented into standard AutoIt's Include files compatible with newer AutoIt. If you still need original Auto3Library for testing old scripts without need to rewrite them, here is latest Auto3Library version 2007-07-01 for you ... Auto3Lib_2007-07-01.rar1 point
-
Hi, I added another feature. If there are testX.au3 files (X is are digits) that is empty it will use this one: #include <File.au3> ; define your pathes Local $sDestinationPath = ; your path where these test files should be Local $sPathSciTE = ; your path to SciTE ; find the last test file Local $aTestFiles = _FileListToArray($sDestinationPath, "test*.au3", $FLTA_FILES) ; search existing test*.au3 Local $sTestFiles = _ArrayToString($aTestFiles) ; make a string of it $aTestFiles = StringRegExp($sTestFiles, "(?i)test(\d+)\.au3", $STR_REGEXPARRAYGLOBALMATCH) ; search all test*-files with digits between test and extension au3 For $i = 0 To UBound($aTestFiles) -1 $aTestFiles[$i] = Number($aTestFiles[$i]) ; make them all to numbers Next _ArraySort($aTestFiles) ; sort them ; find first empty file or get the last number + 1 Local $iNextNumber For $i = 0 To UBound($aTestFiles) -1 If FileGetSize($sDestinationPath & "\test" & $aTestFiles[$i] & ".au3") = 0 Then $iNextNumber = $aTestFiles[$i] ExitLoop EndIf Next If Not IsNumber($iNextNumber) Then $iNextNumber = $aTestFiles[UBound($aTestFiles) -1] + 1 ; that is the highest number + 1 ; create the next test file Local $sNewFile = $sDestinationPath & "\test" & $iNextNumber & ".au3" Local $File = FileOpen($sNewFile, $FO_OVERWRITE) ; open the file in overwrite mode FileWrite($File, ClipGet()) ; put the clipboard inside FileClose($File) ; close the file ; open the test file in SciTE If Not WinExists("[CLASS:SciTEWindow]") Then ShellExecute($sPathSciTE) ; that's for re-opening current opened files too before While Not WinExists("[CLASS:SciTEWindow]") Sleep(100) WEnd RunWait('"' & $sPathSciTE & '" "' & $sNewFile & '"', $sDestinationPath, @SW_HIDE) ; now open that file Simpel1 point
-
Those are VERY OLD includes. I believe they've been merged into the Strings.au3 and GUIListbox.au3 UDFs.1 point
-
Hi. This is my version. It starts with a hotkey in another tool I always have running: #include <File.au3> ; define your pathes Local $sDestinationPath = @DesktopDir Local $sPathSciTE = ; FILL IN YOUR PATH HERE ; find the last test file Local $aTestFiles = _FileListToArray($sDestinationPath, "test*.au3", $FLTA_FILES) ; search existing test*.au3 Local $sTestFiles = _ArrayToString($aTestFiles) ; make a string of it $aTestFiles = StringRegExp($sTestFiles, "(?i)test(\d+)\.au3", $STR_REGEXPARRAYGLOBALMATCH) ; search all test*-files with digits between test and extension au3 For $i = 0 To UBound($aTestFiles) -1 $aTestFiles[$i] = Number($aTestFiles[$i]) ; make them all to numbers Next _ArraySort($aTestFiles) ; sort them Local $iLastNumber = $aTestFiles[UBound($aTestFiles) - 1] ; that is the highest number ; create the next test file Local $sNewFile = $sDestinationPath & "\test" & $iLastNumber + 1 & ".au3" ; adding 1 to the last file Local $File = FileOpen($sNewFile, $FO_OVERWRITE) ; open the file in overwrite mode FileWrite($File, ClipGet()) ; put the clipboard inside FileClose($File) ; close the file ; open the test file in SciTE If Not WinExists("[CLASS:SciTEWindow]") Then ShellExecute($sPathSciTE) ; so all last opened tabs are opened too While Not WinExists("[CLASS:SciTEWindow]") Sleep(100) WEnd RunWait('"' & $sPathSciTE & '" "' & $sNewFile & '"', $sDestinationPath, @SW_HIDE) My test.au3 files are counted. This way I get the next file. And as @BrewManNH said it is opening SciTE directly. Simpel1 point
-
This functions lets you check if a window is responding or not. Equal to checking if a Window goes white after a while using your eye #include <WinAPISys.au3> ; #FUNCTION# ==================================================================================================================== ; Name ..........: IsWindowNotResponding ; Description ...: Checks if a Window is not responding ; Syntax ........: IsWindowNotResponding($hWindow[, $iTimeout = 5000]) ; Parameters ....: $hWindow - A window handle. ; $iTimeout - [optional] Shouldn't matter, Timeout in milliseconds. Default is 5000. ; Return values .: @error set by _WinAPI_SendMessageTimeout ; Author ........: Damon Harris (TheDcoder) ; Remarks .......: The way it works is that it exploits SendMessageTimeout's SMTO_ABORTIFHUNG option. ; Do more research on Process.Responding and how it works (C# function for checking if a window is responding) ; Link ..........: https://git.io/vbcvJ ; Example .......: If IsWindowNotResponding($hWindow) Then DoSomething() ; =============================================================================================================================== Func IsWindowNotResponding($hWindow, $iTimeout = 5000) _WinAPI_SendMessageTimeout($hWindow, 0, 0, 0, $iTimeout, $SMTO_ABORTIFHUNG) Return @error EndFunc1 point
-
Here another fast hack: #include <GUIConstantsEx.au3> $hGUI = GUICreate("Test", 300, 200) $label = GUICtrlCreateLabel("www.autoitscript.com", 50, 80, 200, 30) GUICtrlSetFont(-1, 16, 100, 4) GUICtrlSetColor(-1, 0x000000) GUISetState() $set_1 = False $set_2 = False While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ExitLoop Case $label ShellExecute("http://www.autoitscript.com") ;open web site when clicking label EndSwitch ;change color of label when mouse hovers it $array = GUIGetCursorInfo($hGUI) If $array[4] = $label Then If Not $set_1 Then ;avoid flickering GUICtrlSetColor(-1, 0x0000FF); RRGGBB $set_1 = True $set_2 = False EndIf Else If Not $set_2 Then ;avoid flickering GUICtrlSetColor(-1, 0x000000) $set_1 = False $set_2 = True EndIf EndIf WEnd GUIDelete() Br, UEZ1 point