Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/04/2013 in all areas

  1. BrewManNH

    GUIToolTip UDF rewrite

    I have been working on rewriting the GUIToolTip UDF that comes standard with AutoIt3. Most of the work has involved removing all instances of "magic" numbers and creating working examples for the help file. I have also rewritten most of the ToolTip function entries in the help file to better explain how they work, and how to use them. The original UDF worked well for the most part, but unfortunately there were no examples in the help file and the descriptions for the functions and/or what they did was sorely lacking. Attached is an archive that contains the updated GUIToolTip.au3 UDF, the ToolTipConstants.au3 file, the updated help file entries for the functions, and example scripts for as many of the UDF's functions that I could get working. There is also a script breaking changes document in the archive that describes what was changed and how it will affect any scripts written to use the functions previously. As of this writing, I can almost guarantee that if you have a script that used the original UDF it will NOT work with this one. By that I don't mean it won't work well, I mean it won't work at all, so make sure you read the script breaking changes information. There are some functions in the original UDF that I couldn't get working even with the rewrite, mostly that is because I lack the knowledge necessary to make them work, or they just don't work as written and I can't tell the difference. Any of the functions that don't have example scripts in the help file entries I couldn't get to work, except for the function _GUIToolTip_ToolToArray, which appears to be mostly used as an internal function but I left it as is in case someone ever used it for a script. The new UDF removes the function _GUIToolTip_TTFToBits as it is no longer needed for anything and adds a new function called _GUIToolTip_Deactivate. Please look over the functions, the examples, and the help file entries and give some feedback as to what can be improved, changed, removed etc. Also, please take a look at the functions that I couldn't make work and let me know if you can get them working and an example showing what it does and how it should work. The more eyes looking at this the better it will be in the end. Thanks. GUIToolTip.zip
    3 points
  2. I'm basing the basics (mostly just the XML structure) of this script off one of FireFox's: '?do=embed' frameborder='0' data-embedContent>> I felt the need to make it more flexible, via the Microsoft.xmldom. Using this object, not only can you create excel XML files, you can also update them. XPaths are used for everything, so it's easy to add additional rows/columns/sheets on the fly...I'll add another function to read in an already present file in a bit (just added in), but that function would be as simple as loading the contents into the object. Multiple internal functions, but all you need are: Func EXml_LoadFile($sCallersFile) Func EXml_CreateFile() Func EXml_AddCell($oCallersXML,$sCallersSheetName,$iCallersCellCol,$iCallersCellRow,$sCallersCellData)...this one creates the cell, or updates it if already present Func EXml_SaveFile($oCallersXML,$sCallersFileName) Example Usage #include "EXml.au3" ; Set for overwrite of variable ;~ Global $gsEXml_DocProp_Author = "someAuthor" ;~ Global $gsEXml_DocProp_LastAuthor = "LastAuthorText" ;~ Global $gsEXml_DocProp_Created = "CreatedText" ;~ Global $gsEXml_DocProp_Company = "CompnayText" ;~ Global $gsEXml_DocProp_Version = "VersionText" $oXML = EXml_CreateFile() ; Can load, if the XML file is already present ;~ $oXML = EXml_LoadFile(@DesktopDir & "\test.xml") ; Add cell params: $oXMl, $sSheetName, $iColumn, $iRow, $sCellContents EXml_AddCell($oXML,"SheetName",5,10,"SomeValue1") EXml_AddCell($oXML,"SheetName",5,9,"SomeValue2") EXml_AddCell($oXML,"SheetNameTWO",1,2,"SomeValue3") EXml_AddCell($oXML,"SheetName",5,10,"SomeValueEDIT") EXml_AddCell($oXML,"SheetName",15,6,"SomeValue4") EXml_SaveFile($oXML,@DesktopDir & "\test.xml") Run(@ComSpec & " /c " & @DesktopDir & "\test.xml") ;~ ConsoleWrite(StringRegExpReplace($oXML.xml, "><",">" & @CRLF & "<") & @CRLF) Exit Notice, that you can add cells in at any order, you are not constrained to add everything in order. Where EXml.au3 is: #include-once #include <File.au3> Global $gsEXml_DocProp_Author = "AuthorText" Global $gsEXml_DocProp_LastAuthor = "LastAuthorText" Global $gsEXml_DocProp_Created = "CreatedText" Global $gsEXml_DocProp_Company = "CompnayText" Global $gsEXml_DocProp_Version = "VersionText" Func EXml_LoadFile($sCallersFile) Local $oXML = ObjCreate("Microsoft.XMLDOM") $oXML.Load($sCallersFile) Return $oXML EndFunc Func EXml_CreateFile() ;~ _FileCreate($sCallersFile) Local $oXML = ObjCreate("Microsoft.XMLDOM") $oXML.LoadXML('<?xml version="1.0"?><?mso-application progid="Excel.Sheet"?><Workbook />') Local $oWorkBook = $oXML.selectSingleNode("/Workbook") Local $oDocumentProperties = EXml_CreateFile_DocumentProperties($oXML,$oWorkBook) Local $oOfficeDocumentSettings = EXml_CreateFile_OfficeDocumentSettings($oXML,$oWorkBook) Local $oExcelWorkbook = EXml_CreateFile_ExcelWorkbook($oXML,$oWorkBook) Local $oStyles = EXml_CreateFile_Styles($oXML,$oWorkBook) With $oWorkBook .setAttribute("xmlns","urn:schemas-microsoft-com:office:spreadsheet") .setAttribute("xmlns:o","urn:schemas-microsoft-com:office:office") .setAttribute("xmlns:x","urn:schemas-microsoft-com:office:excel") .setAttribute("xmlns:ss","urn:schemas-microsoft-com:office:spreadsheet") .setAttribute("xmlns:html","http://www.w3.org/TR/REC-html40") .appendChild($oDocumentProperties) .appendChild($oOfficeDocumentSettings) .appendChild($oExcelWorkbook) .appendChild($oStyles) EndWith Return $oXML EndFunc Func EXml_AddCell($oCallersXML,$sCallersSheetName,$iCallersCellCol,$iCallersCellRow,$sCallersCellData) Local $oWorkBook = $oCallersXML.selectSingleNode("/Workbook") Local $oWorkSheet = $oCallersXML.selectSingleNode("//Worksheet[@ss:Name='" & $sCallersSheetName & "']") If Not IsObj($oWorkSheet) Then ; Create Worksheet, as needed $oWorkSheet = EXml_AddCell_CreateWorkSheet($oCallersXML,$sCallersSheetName) $oWorkBook.appendChild($oWorkSheet) EndIf Local $oTable = $oWorkSheet.selectSingleNode("./Table") Local $oRow = $oTable.selectSingleNode("./Row[@ss:Index='" & $iCallersCellRow & "']") If Not IsObj($oRow) Then ; Create Row, as needed $oRow = EXml_AddCell_CreateRow($oCallersXML,$oTable,$iCallersCellRow) $oRows = $oTable.selectNodes("./Row") If $oRows.length Then For $o In $oRows If Number($o.getAttribute("ss:Index")) > $iCallersCellRow Then $oTable.insertBefore($oRow,$o) ExitLoop EndIf Next Else $oTable.appendChild($oRow) EndIf EndIf Local $oCell = $oRow.selectSingleNode("./Cell[@ss:Index='" & $iCallersCellCol & "']") If Not IsObj($oCell) Then $oCell = EXml_AddCell_CreateCell($oCallersXML,$oTable,$iCallersCellCol,$sCallersCellData) $oCells = $oRow.selectNodes("./Cell") If $oCells.length Then For $o In $oCells If Number($o.getAttribute("ss:Index")) > $iCallersCellCol Then $oRow.insertBefore($oCell,$o) ExitLoop EndIf Next Else $oRow.appendChild($oCell) EndIf Else EXml_AddCell_UpdateCell($oCell,$sCallersCellData) EndIf Return $oCallersXML EndFunc Func EXml_SaveFile($oCallersXML,$sCallersFileName) $oCallersXML.save($sCallersFileName) EndFunc #region INTERNAL Func EXml_CreateFile_DocumentProperties($oCallersXML, $oCallersWorkbook) With $oCallersXML Local $oDocProps = .createElement("DocumentProperties") Local $oAuthor = .createElement("Author") Local $oLastAuthor = .createElement("LastAuthor") Local $oCreated = .createElement("Created") Local $oCompany = .createElement("Company") Local $oVersion = .createElement("Version") EndWith $oAuthor.text = $gsEXml_DocProp_Author $oLastAuthor.text = $gsEXml_DocProp_LastAuthor $oCreated.text = $gsEXml_DocProp_Created $oCompany.text = $gsEXml_DocProp_Company $oVersion.text = $gsEXml_DocProp_Version With $oDocProps .setAttribute("xmlns","urn:schemas-microsoft-com:office:office") .appendChild($oAuthor) .appendChild($oLastAuthor) .appendChild($oCreated) .appendChild($oCompany) .appendChild($oVersion) EndWith Return $oCallersWorkbook.appendChild($oDocProps) EndFunc Func EXml_CreateFile_OfficeDocumentSettings($oCallersXML, $oCallersWorkbook) With $oCallersXML Local $oOfficeDocumentSettings = .createElement("OfficeDocumentSettings") Local $oAllowPNG = .createElement("AllowPNG") EndWith With $oOfficeDocumentSettings .setAttribute("xmlns","urn:schemas-microsoft-com:office:office") .appendChild($oAllowPNG) EndWith Return $oCallersWorkbook.appendChild($oOfficeDocumentSettings) EndFunc Func EXml_CreateFile_ExcelWorkbook($oCallersXML, $oCallersWorkbook) With $oCallersXML Local $oExcelWorkbook = .createElement("ExcelWorkbook") Local $oWindowHeight = .createElement("WindowHeight") Local $oWindowWidth = .createElement("WindowWidth") Local $oWindowTopX = .createElement("WindowTopX") Local $oWindowTopY = .createElement("WindowTopY") Local $oProtectStructure = .createElement("ProtectStructure") Local $oProtectWindows = .createElement("ProtectWindows") EndWith $oWindowHeight.text = 8160 $oWindowWidth.text = 21570 $oWindowTopX.text = 0 $oWindowTopY.text = 0 $oProtectStructure.text = "False" $oProtectWindows.text = "False" With $oExcelWorkbook .setAttribute("xmlns","urn:schemas-microsoft-com:office:excel") .appendChild($oWindowHeight) .appendChild($oWindowWidth) .appendChild($oWindowTopX) .appendChild($oWindowTopY) .appendChild($oProtectStructure) .appendChild($oProtectWindows) EndWith Return $oCallersWorkbook.appendChild($oExcelWorkbook) EndFunc Func EXml_CreateFile_Styles($oCallersXML, $oCallersWorkbook) With $oCallersXML Local $oStyles = .createElement("Styles") Local $oStyle = .createElement("Style") Local $oAlignment = .createElement("Alignment") $oAlignment.setAttribute("ss:Vertical","Bottom") Local $oBorders = .createElement("Borders") Local $oFont = .createElement("Font") $oFont.setAttribute("ss:FontName","Calibri") $oFont.setAttribute("x:Family","Swiss") $oFont.setAttribute("ss:Size","11") $oFont.setAttribute("ss:Color","#000000") Local $oInterior = .createElement("Interior") Local $oNumberFormat = .createElement("NumberFormat") Local $oProtection = .createElement("Protection") EndWith With $oStyle .setAttribute("ss:ID","Default") .setAttribute("ss:Name","Normal") .appendChild($oAlignment) .appendChild($oBorders) .appendChild($oFont) .appendChild($oInterior) .appendChild($oNumberFormat) .appendChild($oProtection) EndWith $oStyles.appendChild($oStyle) Return $oCallersWorkbook.appendChild($oStyles) EndFunc Func EXml_AddCell_CreateWorkSheet($oCallersXML,$sCallersWorkSheetName) With $oCallersXML Local $oWorkSheet = .createElement("Worksheet") Local $oTable = .createElement("Table") EndWith $oWorkSheet.setAttribute("ss:Name",$sCallersWorkSheetName) With $oTable .setAttribute("ss:ExpandedColumnCount",0) .setAttribute("ss:ExpandedRowCount",0) .setAttribute("x:FullColumns",1) .setAttribute("x:FullRows",1) .setAttribute("ss:DefaultColumnWidth",60) .setAttribute("ss:DefaultRowHeight",15) EndWith $oWorkSheet.appendChild($oTable) Return $oWorkSheet EndFunc Func EXml_AddCell_CreateRow($oCallersXML,$oCallersTable,$iCallersCellRow) Local $oRow = $oCallersXML.createElement("Row") With $oRow .setAttribute("ss:AutoFitHeight",0) .setAttribute("ss:Index",$iCallersCellRow) EndWith If Number($oCallersTable.getAttribute("ss:ExpandedRowCount")) < $iCallersCellRow Then $oCallersTable.setAttribute("ss:ExpandedRowCount",$iCallersCellRow) EndIf Return $oRow EndFunc Func EXml_AddCell_CreateCell($oCallersXML,$oCallersTable,$iCallersCellCol,$sCallersData) Local $oCell = $oCallersXML.createElement("Cell") Local $oData = $oCallersXML.createElement("Data") With $oData .setAttribute("ss:Type","String") .text = $sCallersData EndWith With $oCell .setAttribute("ss:Index",$iCallersCellCol) .appendChild($oData) EndWith If Number($oCallersTable.getAttribute("ss:ExpandedColumnCount")) < $iCallersCellCol Then $oCallersTable.setAttribute("ss:ExpandedColumnCount",$iCallersCellCol) EndIf Return $oCell EndFunc Func EXml_AddCell_UpdateCell($oCallersCell,$sCallersCellData) With $oCallersCell.selectSingleNode("./Data") .text = $sCallersCellData EndWith EndFunc #endregion INTERNAL Debugging is still required when working with > 1 Sheets. Things to add...styles on sheets, rows, cells.
    1 point
  3. http://support.microsoft.com/kb/193625
    1 point
  4. To confuse the OP
    1 point
  5. MHz

    Ctrl - Shift key stuck

    You change Send("my_value") to _SendEx("my_value") Here is a change to your code with the use of the linked code that BrewManNH posted to sleep until the Shift-Ctrl-Alt keys are released. I guess it shows that using the keyboard while using Send can activate the issue with key state. Best to deactivate the hotkey while the sleep happens else the queue can still be added to. #include < Misc.au3 > HotKeySet("^+9", "Encl") While 1 Sleep(10000) WEnd Func Encl() ClipPut("") HotKeySet(@HotKeyPressed) While _IsPressed("10") Or _IsPressed("11") Or _IsPressed("12") Sleep(10) WEnd Send("^x") Sleep(200) local $ClipEncl = ClipGet() Switch @HotKeyPressed Case "^+9" $ClipEncl = '(' & $ClipEncl & ')' EndSwitch ClipPut($ClipEncl) Send("^v") HotKeySet(@HotKeyPressed, "Encl") EndFunc I have not been able to create the issue with testing this though if you like playing your keyboard like a piano then the _SendEx() is probably best to use to ensure all sends are covered.
    1 point
  6. Just follow that specific thread and wait for updates/documentation and ask your request(s) in the UIA thread and I will answer them For the moment its just by reading that specific thread and the sourcecode of the UDF. UIA is a large framework and with the UDF I am trying to simplifying it (and leave the power to the powerusers that can read the UDF)
    1 point
  7. remin, There certainly is! $Form2 = GUICreate("Case", 120, 215, 100, 100) $bUpper = GUICtrlCreateButton("Upper", 16, 50, 89, 25) $bLower = GUICtrlCreateButton("Lower", 16, 75, 89, 25) $bTitle = GUICtrlCreateButton("Title", 16, 100, 89, 25) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE GUIDelete($Form2) Case $bUpper To $bTitle ; This assumes you have created all the buttons in immediate succession ; Run this now before every case WinActivate($gActiveWin) Send("^x") local $tempcontrol = ClipGet() If $tempcontrol = "" Then MsgBox(0,"","Nothing Selected") ContinueLoop ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< EndIf ; Now run the specific code for each case Switch $nMsg Case $bUpper Local $Result = StringUpper(ClipGet()) Case $bLower Local $Result = StringLower(ClipGet()) Case $bTitle Local $Result = etc etc EndSwitch ; And run this after every case ClipPut($Result) Send("^v") EndSwitch WEnd M23
    1 point
  8. Well this simply runs a batch file that waits for the process to close and then performs a file move by moving the new executable to the old filename. Simple. So if you can think of something that can go wrong during this process then it will.
    1 point
  9. Hi, Something like this? $hGUI = GuiCreate("My GUI", 200, 200) $hButtonCompare = GUICtrlCreateButton("Compare", 100, 100, 50) GUISetState(@SW_SHOW, $hGUI) Do $aMsg = GUIGetMsg() Select case $aMsg = $hButtonCompare Do If DownloadStringFromServer() <> "" Then ConsoleWrite("String is availble" & @CRLF) Sleep(3000) Else ConsoleWrite("String not available!" & @CRLF) Sleep(5000) EndIf Until False EndSelect Until False Func DownloadStringFromServer() Local $a = Random(1,10,1) If Mod($a, 2) = 0 Then Return "" Else Return "String" EndIf EndFunc
    1 point
  10. Melba23

    Auto file copier

    rapfreak, Change the "ExitLoop 2" line to read "ExitLoop". M23
    1 point
  11. Blue_Drache

    Ctrl - Shift key stuck

    Why not just ... not use the shift? Use Ctrl+9 ...
    1 point
  12. MHz

    Ctrl - Shift key stuck

    AutoIt has always suffered from what we call ShiftState. I am not aware of the ctrl key or alt key doing this though I do not see everything. Can you not avoid shift, you know the thing that supports locking shift? Edit: or is it shiftlock, got me thinking now.
    1 point
  13. BrewManNH

    Ctrl - Shift key stuck

    http://www.autoitscript.com/wiki/FAQ#Why_does_the_Ctrl_key_get_stuck_down_after_I_run_my_script.3F
    1 point
  14. I happened to find another solution for this. Just thought to share with the community. #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Include <GuiListView.au3> Opt('MustDeclareVars', 1) Example() Func Example() GUICreate("Reversed Listview", 220, 250) Local $hListView = GUICtrlCreateListView("|col1|col2|col3", 10, 10, 200, 150, -1) ; I put blank for the checkbox-header's text _GUICtrlListView_SetExtendedListViewStyle(GUICtrlGetHandle($hListView), BitOR($LVS_EX_GRIDLINES,$LVS_EX_CHECKBOXES)) _GUICtrlListView_SetColumnOrder($hListView, "1|2|3|0");Set the order so the checkbox column is on the right side GUICtrlCreateListViewItem("|1|col22|col23", $hListView) GUICtrlCreateListViewItem("|2|col12|col13", $hListView) GUICtrlCreateListViewItem("|3|col32|col33", $hListView) GUISetState() While 1 If GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit WEnd EndFunc ;==>Example
    1 point
×
×
  • Create New...