Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 09/20/2016 in all areas

  1. BugFix version - 27 Dec 23 Fixed: No default value set for the MaxWidth parameter - took 12 years for someone to notice it! New UDF and new examples below and in zip. I just realised that although I have posted versions of this UDF many times in Help topics, I had never actually posted a "final" version here in Example scripts - better late than never, I suppose! StringSize takes a text string and calculates the size of label required to hold it as well as formatting the string to fit. Now AutoIt will, of course, size a label automatically to fit a text string, but it will not format the string in any way - what you use as the string is what you get in the label. If you do set any label sizes the text will be wrapped, but you can only determine the correct size of the label by trial and error. StringSize will, however, reformat the string to fit in a given width and tell you the required height so that you can read it all - whatever the font type or size - and you do not have to do the formatting beforehand. Here is a simple example to show what I mean (you need the UDF in the same folder for all the examples): And here is an example showing how StringSize can deal with different fonts and text sizes: You can see that the GUI is perfectly sized each time and that the button is always the right size and in the right place. StringSize returns an array which contains the formatted text to display and the size of the label needed to display it. All you need to do is to use the array elements when you create your label. Try changing the values in $aFont and $aSize if you want to try you own favourites - but beware, StringSize will return an error if you make the size so large that it cannot fit a word into the label width. NEW A more complex example showing how formatted and unformatted text can be sized correctly. The width of GUI holding the unformatted text varies randomly in width (the current value is displayed at top right): NEW And a final example showing how you can get your text in the largest possible font to fit in a given space: Finally here is the UDF itself: And all 5 files in zip format: StringSize.zip I hope you find this useful - I certainly do. M23
    1 point
  2. genius257

    StringRegEx Help

    "X(?:[_][0-9])?" Or "X(?:[_][0-9]+)?"
    1 point
  3. BrewManNH

    *.BAT to *.AU3

    You do realize, I hope, that this thread is over 5 years old, and no one in the thread needs this information any longer.
    1 point
  4. Since there is only one ComboBox you can use FindFirst instead of FindAll. FindFirst finds the ComboBox directly while FindAll finds an array of ComboBox elements. This code is slightly shorter and faster: ;#include "..\..\Include\CUIAutomation2.au3" #include "CUIAutomation2.au3" $hWindow = WinGetHandle( "Google - Google Chrome" ) ; AutoIt Windows Info tool If Not $hWindow Then Exit ConsoleWrite( "$hWindow ERR" & @CRLF ) ConsoleWrite( "$hWindow OK" & @CRLF ) $hControl = ControlGetHandle( $hWindow, "", "[CLASS:Chrome_RenderWidgetHostHWND]" ) ; AutoIt Windows Info tool If Not $hControl Then Exit ConsoleWrite( "$hControl ERR" & @CRLF ) ConsoleWrite( "$hControl OK" & @CRLF ) ; Create UI Automation object $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation ) If Not IsObj( $oUIAutomation ) Then Exit ConsoleWrite( "$oUIAutomation ERR" & @CRLF ) ConsoleWrite( "$oUIAutomation OK" & @CRLF ) ; Get UI Automation element from control handle Local $pControl, $oControl $oUIAutomation.ElementFromHandle( $hControl, $pControl ) $oControl = ObjCreateInterface( $pControl, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oControl ) Then Exit ConsoleWrite( "$oControl ERR" & @CRLF ) ConsoleWrite( "$oControl OK" & @CRLF ) ; Condition to find ComboBox Local $pCondition ; Use Inspect.exe or Simple spy demo to verify that the search box is a ComboBox $oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $UIA_ComboBoxControlTypeId, $pCondition ) If Not $pCondition Then Exit ConsoleWrite( "$pCondition ERR" & @CRLF ) ConsoleWrite( "$pCondition OK" & @CRLF ) ; Find ComboBox Local $pUIElement, $oUIElement $oControl.FindFirst( $TreeScope_Descendants, $pCondition, $pUIElement ) $oUIElement = ObjCreateInterface( $pUIElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oUIElement ) Then Exit ConsoleWrite( "$oUIElement ERR" & @CRLF ) ConsoleWrite( "$oUIElement OK" & @CRLF ) ; Get Value object Local $pValue, $oValue $oUIElement.GetCurrentPattern( $UIA_ValuePatternId, $pValue ) $oValue = ObjCreateInterface( $pValue, $sIID_IUIAutomationValuePattern, $dtagIUIAutomationValuePattern ) If Not IsObj( $oValue ) Then Exit ConsoleWrite( "$oValue ERR" & @CRLF ) ConsoleWrite( "$oValue OK" & @CRLF ) ; Set search text ;Local $sText ;$oValue.CurrentValue( $sText ) ; This works ;ConsoleWrite( "$sText = " & $sText & @CRLF ) $oValue.SetValue( "AutoIt" ) ; This does not work but sets input focus to the search box Send( "AutoIt" ) ; Text to search Send( "{Enter}" ) ; Perform search
    1 point
  5. AutoBert

    close many child gui

    Insert a If statement for main GUI to exit
    1 point
  6. The code below shows how to automate a Google search in Chrome directly with the UI Automation interfaces (answer to a PM). Open Chrome and enable accessibility mode with chrome://accessibility. select a Google search page eg. https://www.google.co.uk/. Run this code to start a search: ;#include "..\..\Include\CUIAutomation2.au3" #include "CUIAutomation2.au3" $hWindow = WinGetHandle( "Google - Google Chrome" ) ; AutoIt Windows Info tool If Not $hWindow Then Exit ConsoleWrite( "$hWindow ERR" & @CRLF ) ConsoleWrite( "$hWindow OK" & @CRLF ) $hControl = ControlGetHandle( $hWindow, "", "[CLASS:Chrome_RenderWidgetHostHWND]" ) ; AutoIt Windows Info tool If Not $hControl Then Exit ConsoleWrite( "$hControl ERR" & @CRLF ) ConsoleWrite( "$hControl OK" & @CRLF ) ; Create UI Automation object $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation ) If Not IsObj( $oUIAutomation ) Then Exit ConsoleWrite( "$oUIAutomation ERR" & @CRLF ) ConsoleWrite( "$oUIAutomation OK" & @CRLF ) ; Get UI Automation element from control handle Local $pControl, $oControl $oUIAutomation.ElementFromHandle( $hControl, $pControl ) $oControl = ObjCreateInterface( $pControl, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oControl ) Then Exit ConsoleWrite( "$oControl ERR" & @CRLF ) ConsoleWrite( "$oControl OK" & @CRLF ) ; Condition to find ComboBox Local $pCondition ; Use Inspect.exe or Simple spy demo to verify that the search box is a ComboBox $oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $UIA_ComboBoxControlTypeId, $pCondition ) If Not $pCondition Then Exit ConsoleWrite( "$pCondition ERR" & @CRLF ) ConsoleWrite( "$pCondition OK" & @CRLF ) ; Find ComboBox Local $pUIElementArray, $oUIElementArray, $iElements $oControl.FindAll( $TreeScope_Descendants, $pCondition, $pUIElementArray ) $oUIElementArray = ObjCreateInterface( $pUIElementArray, $sIID_IUIAutomationElementArray, $dtagIUIAutomationElementArray ) $oUIElementArray.Length( $iElements ) If Not ( $iElements = 1 ) Then Exit ConsoleWrite( "$iElements ERR" & @CRLF ) ConsoleWrite( "$iElements OK" & @CRLF ) ; Get ComboBox element Local $pUIElement, $oUIElement $oUIElementArray.GetElement( 0, $pUIElement ) $oUIElement = ObjCreateInterface( $pUIElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) ; Get Value object Local $pValue, $oValue $oUIElement.GetCurrentPattern( $UIA_ValuePatternId, $pValue ) $oValue = ObjCreateInterface( $pValue, $sIID_IUIAutomationValuePattern, $dtagIUIAutomationValuePattern ) If Not IsObj( $oValue ) Then Exit ConsoleWrite( "$oValue ERR" & @CRLF ) ConsoleWrite( "$oValue OK" & @CRLF ) ; Set search text ;Local $sText ;$oValue.CurrentValue( $sText ) ; This works ;ConsoleWrite( "$sText = " & $sText & @CRLF ) $oValue.SetValue( "AutoIt" ) ; This does not work but sets input focus to the search box Send( "AutoIt" ) ; Text to search Send( "{Enter}" ) ; Perform search
    1 point
  7. mikell

    close many child gui

    Please try this Func Form1Close() GuiDelete(@GUI_WinHandle) EndFunc
    1 point
  8. Do it like i did in: ;https://autoit.de/index.php/Thread/83656-Button-Klick-erkennen-wenn-Funktion-l%C3%A4uft-so-wie-ein-Hotkey/?postID=669356#post669356 #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> TCPStartup() $gui = GUICreate("KLeines 1 X 1", 400, 130) $Start = GUICtrlCreateButton("&Start", 10, 10) $PauseResume = GUICtrlCreateButton("&Pause", 10, 40) $ResolveIP = GUICtrlCreateButton("&IP", 10, 70) $Label = GUICtrlCreateLabel("", 100, 70, 280, 22) $Anzeige = GUICtrlCreateLabel("", 10, 95, 380, 22) GUISetState() Global $sIPAddress While 1 _EventHandler() WEnd Func _EventHandler() $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE TCPShutdown() Exit Case $Start GUICtrlSetState($Start, $GUI_DISABLE) For $i = 1 To 10 For $j = 1 To 10 GUICtrlSetData($Anzeige, $j & " * " & $i & " = " & $i * $j) _MySleep(500) Next Next GUICtrlSetState($Start, $GUI_ENABLE) Case $PauseResume If GUICtrlRead($PauseResume) = "&Pause" Then GUICtrlSetData($PauseResume, "&Weiter") While GUICtrlRead($PauseResume) <> "&Pause" _MySleep(50) WEnd Else GUICtrlSetData($PauseResume, "&Pause") EndIf Case $ResolveIP $tdStart = TimerInit() $sIPAddress = TCPNameToIP("www.autoitscript.com") If @error Then GUICtrlSetData($Label, "Error code: " & @error) Else GUICtrlSetData($Label, $sIPAddress) EndIf ConsoleWrite('Time for resolve: ' & TimerDiff($tdStart) & @CRLF) EndSwitch EndFunc ;==>_EventHandler Func _MySleep($iMSec) Local $iStart = TimerInit() Do _EventHandler() Until TimerDiff($iStart) >= $iMSec EndFunc ;==>_MySleep
    1 point
  9. david1337, Glad you like the UDF - it is a pretty complex beast to master, but does have a lot of functionality. M23
    1 point
  10. david1337, Using MsgBox to display an array? This works better: Case $GUI_EVENT_CLOSE $aContent = _GUIListViewEx_ReturnArray($iLV_Index) _ArrayDisplay($aContent, "", Default, 8) Exit M23
    1 point
  11. Enough of this OS willy-waving - locked. M23
    1 point
  12. jchd

    Help with DLLCall

    I was unable to locate an API documentation. What are the C prototypes of the functions you'll be using? Note that the return type should be int64 and the path wstr (most probably).
    1 point
  13. you are right, they work on a separate network IP, at times even a different NIC and cable. They send the images via DICOM standards, that's all it's used for. No worries. I know you are not, but the tread is full of this type of attention/inclination. I actually agree with your comments
    1 point
  14. All these comments are, from my view, interesting ( it sounds better than "funny" ) windows-nt-2000 is also abandonware, so, ...that's that. Free. ( for the price of, "do not log in to your email", I guess ) In a more serious note, I work with CT, MRI, x rays, etc., they are called modalities and many still run on old OS ( win2000 mostly ), so, for me, being able to write scripts for such old OS, is at times handy, so, to this type of topic, I pay attention to. Now, from the topic at hand, to what this has become, ...truly unscientific. This is more of an alpha/dominant contest. Way out of topic. Well, that was answered ... by your self. So, that is done And now, this: ... I should have not clicked "Submit Reply", ..., I knew ...
    1 point
  15. I think you want... _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 3", 2, 2) If you want "Row 1: Col 3" to appear in Row 2, Col 2 you have to create an item for row 2 and add it as a subitem for that item. _GUICtrlListView_AddItem() creates the row and first item in the row. _GUICtrlListView_AddSubItem() creates additional subitems in the row. Items and subitems are oriented left to right, not top to bottom.
    1 point
  16. Tell me again how I am just a user of my Enterprise Win10 Build 14926.rs_prerelease.160910-1529 and you are the 'owner' of your Win98se, just because you are in prison does not mean that you run the place. I am going to say confidently, that you have close to ZERO first-hand knowledge of the way the new Win10 builds actually function and are spouting the telemetry and wares FUD from early releases. My current box phones home on exactly one occasion, and that's when i submit a comment to the WindowsInsiders. There are inherent flaws in win98se that will not be patched (not even if you are on MSFN every day of the week downloading every new hacked and backported patch) that are exposing you to literally hundreds of drive-bys from every kiddie scripter with the latest metasploit or kali packages. Also you have a metric shit ton of obsolete certs and crypto packages that can still be force negotiated even if better/newer/shinier are available. Just because your box is completely uninteresting does not mean it is not open wider than goatse. And I dont care if anyone takes offense, espousing the benefits of Win98SE is relegated to how great CS1.5 runs. The security is bollocks.
    1 point
  17. This: ConsoleWrite(hex(DriveGetSerial('c:')&@crlf)) outputs the same result as vol c: So its the equivalent to vol, you searched for.
    1 point
  18. Drop this part of your script: Local $oWorkbook = _Excel_BookOpen($oExcel, $sWorkbook) If @error Then MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookAttach Example", "Error opening workbook '" & $sWorkbook & "'." & @CRLF & "@error = " & @error & ", @extended = " & @extended) _Excel_Close($oExcel) Exit EndIf You either need _Excel_BookOpen OR _Excel_BookAttach.
    1 point
  19. Hello fellas! The other night night i was converting a Msdn function to autoit and I stumbled across this topic Which inspired me like crazy and I decided to take it a step further and require the user to make almost ZERO effort to export a c++ Msdn function and or a Structure to AutoIt Shoutout to toasterking So after 18-20 effective hours: The GUI is really simple, all you need is a link to a MSDN page and the program does the rest, most of the options is just for user preferences. On the inside I have spent a decent amount of work to make sure the code come out correctly, any particular event during the conversion will get fed-back to the user, so he or she will know if anything noticeable happen. Regular DllCall example http://i.imgur.com/HZLijeu.png Struct example http://i.imgur.com/l3j6wTR.png Expand spoiler for more pictures In the "Msdn Examples" folder you will find some examples of code i have generated, in most of them I only manually added 2-3 lines to make them work. If you dont know where to get these functions you can browse the MSDN Library https://msdn.microsoft.com/en-us/library/ee663300(v=vs.85).aspx and look for any function refrence, or just google "somethingsomething msdn" and the first result will almost always contain the function you are looking for. Here is some functions you can play around with https://msdn.microsoft.com/en-us/library/windows/desktop/ms724390(v=vs.85).aspx https://msdn.microsoft.com/en-us/library/windows/desktop/ms633519(v=vs.85).aspx https://msdn.microsoft.com/en-us/library/windows/desktop/ms645505(v=vs.85).aspx https://msdn.microsoft.com/en-us/library/windows/desktop/ms724408(v=vs.85).aspx I would really appreciate any kind of feedback, improvements or requests If you get any type of error just post the MSDN url + the error message and ID and I will troubleshoot it. Update 0.2 Fixed some minor issues Added highlight for a more pleasent view Fixed minor bugs Made it run faster when working with the same URL (It dosent load the page entierly) No struct search is now done when no POINTER is used in the call Added more options for the user Update 0.3 Removed _IeNavigate and fixed the template for DllCall not including function name Update 0.4 Switched method to InetGet from _Ie* H0tfix3s Update 0.5 Added more options for function-layout Removed old code Added more auto detection Now using @TmpDir instead of @ScriptDir for html files etc. Update 0.6 More Output logic added Added a detection for SAL aswell, since it seems to be inconsistent according to MSDN community and myself. Better feedback on what happend with parse Code cleanup / Removed old code /Tarre DllCall and Struct Generator V 0.6.zip DllCall and Struct Generator V 0.5.zip DllCall and Struct Generator V 0.4.zip
    1 point
  20. uncommon

    _Array2HTMLTable()

    I made a function, it does as the name implies. It will make an Autoit array into a HTML table. I looked around on the forms but could not find anything I liked so I made one. You can change the colors via Hex colors and can also turn off the headers. The function returns the string for a HTML doc and the table. Let me know what ya'll think. Update 4/8/14: Added <p> tag to make table centered, Just seemed to make more sence. ;#FUNCTION#============================================================================================================= ; Name...........: _Array2HTMLTable() ; Description ...: Returns HTML string with a table created from a Autoit array ; Syntax.........: ($aArray, $BodyBGColor = "#ffffff", $HighlightBGColor = "#F0F9FF", $HeaderBGColor = "#007EE5", $BodyTxtColor = "#000000", $HeaderTxtColor = "#ffffff", $HeadersOn = 1) ; Parameters ....: $aArray - The Array to use ; $BodyBGColor - [optional] The Hex color for the table body background. ; $HighlightBGColor - [optional] The Hex color for the highlight background. ; $HeaderBGColor - [optional] The Hex color for the table header background. ; $BodyTxtColor - [optional] The Hex color for the table body Text. ; $HeaderTxtColor - [optional] The Hex color for the table header Text. ; $HeadersOn - [optional] Turns off the header. Headers are the contents found on the first row of the Autoit array if this feature is turned off then ; the frist row of the autoit array is placed into the table body. ; Return values .: Success - The HTML string ; Failure - -1 or -2 depending on the problem ; Author ........: XThrax aka uncommon ; Remarks .......: CSS and JavaScript are use to make the table look nice. If you know a lot more about either you can add to it or manipulate it. I used the code I found on this website. ; http://webdesign.about.com/od/examples/l/bltables.htm ; Related .......: _IETableWriteToArray() ; Link ..........; ; Example .......; No ; ===================================================================================================================== Func _Array2HTMLTable($aArray, $BodyBGColor = "#ffffff", $HighlightBGColor = "#F0F9FF", $HeaderBGColor = "#007EE5", $BodyTxtColor = "#000000", $HeaderTxtColor = "#ffffff", $HeadersOn = 1) If IsArray($aArray) = 0 Then Return -1 Local $aTRlines = '' Local $aTHlines = '' Local $aTDlines = '' Local $BodyStart = 1 Local $TotalRows = UBound($aArray);rows Local $TotalColumns = UBound($aArray, 2);columns Local $CSS = 'table {margin: 1em; border-collapse: collapse; }' & @CRLF & _ 'td, th {padding: .3em; border: 1px #ccc solid; }' & @CRLF & _ 'thead {background: ' & $HeaderBGColor & '; }' & @CRLF & _ 'thead {color:' & $HeaderTxtColor & ';}' & @CRLF & _ 'tbody {background: ' & $BodyBGColor & '; }' & @CRLF & _ 'tbody {color: ' & $BodyTxtColor & '; }' & @CRLF & _ '#highlight tr.hilight { background: ' & $HighlightBGColor & '; } ' Local $JavaScript = "function tableHighlightRow() {" & @CRLF & _ " if (document.getElementById && document.createTextNode) {" & @CRLF & _ " var tables=document.getElementsByTagName('table');" & @CRLF & _ " for (var i=0;i<tables.length;i++)" & @CRLF & _ " {" & @CRLF & _ " if(tables[i].className=='hilite') {" & @CRLF & _ " var trs=tables[i].getElementsByTagName('tr');" & @CRLF & _ " for(var j=0;j<trs.length;j++)" & @CRLF & _ " {" & @CRLF & _ " if(trs[j].parentNode.nodeName=='TBODY') {" & @CRLF & _ " trs[j].onmouseover=function(){this.className='hilight';return false}" & @CRLF & _ " trs[j].onmouseout=function(){this.className='';return false}" & @CRLF & _ " }" & @CRLF & _ " }" & @CRLF & _ " }" & @CRLF & _ " }" & @CRLF & _ " }" & @CRLF & _ "}" & @CRLF & _ "window.onload=function(){tableHighlightRow();}" If $HeadersOn <> 1 Then $BodyStart = 0 Else If $TotalRows < 2 Then Return -2;there needs to be at least two rows if headers are on For $x = 0 To $TotalColumns - 1 $aTHlines = $aTHlines & ' <th>' & $aArray[0][$x] & '</th>' & @CRLF Next EndIf For $x = $BodyStart To $TotalRows - 1 $aTDlines = '' For $i = 0 To $TotalColumns - 1 $aTDlines = $aTDlines & ' <td>' & $aArray[$x][$i] & '</td>' & @CRLF Next $aTRlines = $aTRlines & '<tr>' & @CRLF & _ $aTDlines & _ '</tr>' & @CRLF Next $HTML = '<!DOCTYPE html><html>' & @CRLF & _ '<head> ' & @CRLF & _ '<Style>' & @CRLF & _ $CSS & @CRLF & _ '</Style>' & @CRLF & _ '<script>' & @CRLF & _ $JavaScript & @CRLF & _ '</script>' & @CRLF & _ '</head>' & @CRLF & _ '<body><p align="center"><table class="hilite" id="highlight" style="width:60%">' & @CRLF & _ '<thead>' & @CRLF & _ '<tr>' & @CRLF & _ $aTHlines & _ '</tr>' & @CRLF & _ '</thead>' & @CRLF & _ '</p><tbody>' & @CRLF & _ $aTRlines & _ '</tbody>' & @CRLF & _ '</table></body></html>' Return $HTML EndFunc ;==>_Array2HTMLTable _Array2HTMLTable.au3
    1 point
×
×
  • Create New...