Leaderboard
Popular Content
Showing content with the highest reputation on 10/18/2020 in all areas
-
The help for FileOpen says: So what you call your "dashes" (probably some Unicode character among ‐‑‒–—― respectively 0x2010 HYPHEN, 0x2011 NON-BREAKING HYPHEN, 0x2012 FIGURE DASH, 0x2013 EN DASH, 0x2014 EM DASH or even 0x2015 HORIZONTAL BAR) get encoded as UTF8.1 point
-
The url for StringSize.au3 is in the code above, you need to download the file first to use the code above. https://www.autoitscript.com/forum/topic/114034-stringsize-m23-new-version-16-aug-11/1 point
-
Hello. It's easy. Check this example. #include <GUIConstantsEx.au3> Example() Func Example() ; Create a GUI with various controls. Local $hGUI = GUICreate("Example", 500, 300) GUISetState(@SW_SHOW, $hGUI) Local $tWave = DllStructCreate("short[1025]") Local $tMid = DllStructCreate("float[1025]") Local $tAmplitude = DllStructCreate("float[1025]") Local $tPhase = DllStructCreate("float[1025]") Local $iFs = 5120 Local $iLen = 1024 Local $iDX = (1.0 / $iFs) Local $iDF = ($iFs / 1024.0) Local $iDT = $iDX For $i = 1 To $iLen Local $t1 = 6.28 * $iDT * $i * 20 DllStructSetData($tWave, 1, (3276 * Sin($t1)), $i) DllStructSetData($tMid, 1, (DllStructGetData($tWave, 1, $i) / 3276.0), $i) Next Local $hFFT = DllOpen("fftdll.dll") DllCall($hFFT, "none", "initDraw", "handle", $hGUI) DllCall($hFFT, "none", "spectrum_a_p", "ptr", DllStructGetPtr($tMid), "ptr", DllStructGetPtr($tAmplitude), "ptr", DllStructGetPtr($tPhase)) DllCall($hFFT, "none", "display", "int", 25, "int", 30, "int", 100, "int", 450, "int", 2, "float", $iDX, "ptr", DllStructGetPtr($tMid), "int", 12, "int", 1, "int", 3, "int", 7) DllCall($hFFT, "none", "display", "int", 25, "int", 150, "int", 100, "int", 450, "int", 1, "float", $iDF, "ptr", DllStructGetPtr($tAmplitude), "int", 12, "int", 1, "int", 3, "int", 7) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE DllClose($hFFT) ExitLoop EndSwitch WEnd ; Delete the previous GUI and all controls. GUIDelete($hGUI) EndFunc ;==>Example pd: I'll update sintaxis highlight later (all around know about my internet issue 🤫) Saludos1 point
-
Couldn't see the image, this works for me: #include <Array.au3> #include <StringSize.au3> ;~ https://www.autoitscript.com/forum/topic/114034-stringsize-m23-new-version-16-aug-11/ Local $sGuiTitle = '11111111111111111111111111111' Local $aStringSize = _StringSize($sGuiTitle) ToolTip ( '1111111111111111111111111' & @Crlf, @DesktopWidth - $aStringSize[2], @DesktopHeight - (60 + $aStringSize[3]), $sGuiTitle, 0, 4 ) Sleep(3000)1 point
-
I created a little innoscript for you with which you can add an .a3x file, a starter .cmd and the suitable AutoIt.exe into a Setup. I extracted the code from one of my much more comprehensive scripts, but it should fit. I still use the Inno Setup Software 5.6.1. (there is a newer one available). -> Install the current version of Inno-Setup and create a project directory (e.g. c:\Innoprojects\MyTool) -> Copy the attached .zip file into this directory and unzip it there. -> Open MyTool.iss with the Inno-Editor and click on BUILD -> COMPILE (CTRL + F9) ==> The result is a setup file that installs (more precisely copies) the relevant files into a directory of your choice. ==> The AutoIt script 'MyTool' itself is just a dummy application and serves only for demonstration purposes. I named the project 'MyTool', but you can change the name and the .bmp's to whatever you like. If you still have questions, you are welcome to write me a PM (others of course as well). Maybe it would even be better to create an own thread in a more suitable forum area. Testfiles.zip1 point
-
XML and SVG and namespace difficulties
FlecheBleu reacted to TheXman for a topic
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> Remove the DOCTYPE line from your svg file and your script should work. The reason your script fails with the DOCTYPE line is because the .Load method generates an error due to the DTD. Therefore, you do not have a valid XML document object to work with. So any statements referencing the XML document object will fail also. Side Note: Unfortunately the SVG DTDs are a source of so many issues that the SVG WG has decided not to write one for the upcoming SVG 1.2 standard. In fact SVG WG members are even telling people not to use a DOCTYPE declaration in SVG 1.0 and 1.1 documents. Instead always include the 'version' and 'baseProfile' attributes on the root <svg> tag, and assign them appropriate values. https://dev.w3.org/SVG/profiles/2.0/publish/intro.html1 point -
You can use _Excel_RangeFind to find all instances, basic example: #include <Array.au3> #include <Excel.au3> Local $aSentence[3] = ["I'd like this sentence to be red", "I'd like this sentence to be black", "I'd like this sentence to be red again"] Local $oExcel = _Excel_Open() Local $oWorkbook = _Excel_BookNew($oExcel) ;~ Begin Creating Dummy Data for Example For $i = 2 To 15 Step 2 _Excel_RangeWrite($oWorkbook, 1, "Some dummy data" & @LF & "More dummy data" & @LF & "End dummy data.", _Excel_ColumnToLetter($i-1) & Floor(Random(1,4))) _Excel_RangeWrite($oWorkbook, 1, $aSentence[0] & @LF & $aSentence[1] & @LF & $aSentence[2], _Excel_ColumnToLetter($i) & Floor(Random(1,4))) Next ;~ End Creating Dummy Data ;~ Find all text items named "I'd like this sentence to be red" Local $aFindAll = _Excel_RangeFind($oWorkbook, $aSentence[0]) If @error Then Exit MsgBox(4096, "Search Error", '"' & $aSentence[0] & '" not found.') ;~ Loop through the search results and change the color text For $i = 0 To UBound($aFindAll) - 1 Local $oCell = $oWorkbook.Worksheets(1).Range($aFindAll[$i][2]) ;~ $oCell.Characters(Start Character Index, Number of Characters from Start Character Index) $oCell.Characters(1,Stringlen($aSentence[0]) + 1).Font.Color = -16776961 $oCell.Characters(StringLen($aSentence[0] & @LF),Stringlen($aSentence[1]) + 1).Font.Color = 0x000000 $oCell.Characters(StringLen($aSentence[0] & @LF & $aSentence[1] & @LF),Stringlen($aSentence[2]) + 1).Font.Color = -16776961 Next1 point
-
RegisterSuspendResumeNotification returns a value of type HPOWERNOTIFY which is a PVOID pointer, which in AutoIt translates to a standard "ptr". Therefore, RegisterSuspendResumeNotification must be implemented this way in AutoIt: DllCall( "User32.dll", "ptr", "RegisterSuspendResumeNotification", "handle", $hRecipient, "dword", $iFlags ) Valid flag values are: Global Const $DEVICE_NOTIFY_WINDOW_HANDLE = 0 Global Const $DEVICE_NOTIFY_CALLBACK = 2 As you're using the function in your code, the DllCall should look like this: $hPowerNotify = DllCall( "User32.dll", "ptr", "RegisterSuspendResumeNotification", "handle", $hGUI, "dword", $DEVICE_NOTIFY_WINDOW_HANDLE ) You can use $hPowerNotify to unregister the notifications. Untested since I'm on Windows 7 at the moment.1 point
-
SQL ADO Get Print Messages?
JockoDundee reacted to mLipok for a topic
Here is your script (little modified by me): #include <array.au3> #include "__UDF_Forum\ADO.au3" ; your ADO.au3 localization Global $oADODB_Connection = ObjCreate("ADODB.Connection") _Example() Func _Example() ; Error monitoring. This will trap all COM errors while alive. ; This particular object is declared as local, meaning after the function returns it will not exist. Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc") #forceref $oErrorHandler Local $sPassword = 'AutoIt' $oADODB_Connection.Open("PROVIDER=SQLOLEDB.1;SERVER=localhost\SQLExpress;uid=sa;pwd=" & $sPassword & ";") Local $objquery = $oADODB_Connection.Execute("if 1 = 1 print 'this is a test - hello'") #forceref $objquery Local $test = $objquery.Parent #forceref $test EndFunc ;==>_Example ; User's COM error function. Will be called if COM error occurs Func _ErrFunc($oError) Local $iErrorCol_Max = $oADODB_Connection.errors.Count If $iErrorCol_Max = 0 Then ConsoleWrite(@CRLF & _ "! ==> COM Error intercepted ==> NOT ADO related Error " & @CRLF & _ "-" & @TAB & "$oError.description is: " & @TAB & $oError.description & @CRLF & _ "-" & @TAB & "$oError.number is: " & @TAB & @TAB & $oError.number & " in HEX is 0x" & Hex($oError.number) & @CRLF & _ "-" & @TAB & "$oError.source is: " & @TAB & @TAB & $oError.source & @CRLF & _ "-" & @TAB & "$oError.windescription:" & @TAB & @TAB & $oError.windescription & @CRLF & _ "-" & @TAB & "$oError.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ "-" & @TAB & "$oError.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ "-" & @TAB & "$oError.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ "-" & @TAB & "$oError.scriptline is: " & @TAB & @TAB & $oError.scriptline & @CRLF & _ "-" & @TAB & "$oError.retcode is: " & @TAB & @TAB & "0x" & Hex($oError.retcode) & @CRLF & _ "! ==> COM End of Error dump." & @CRLF & _ @CRLF) Else Local $oErr For $iErrorCol_idx = 0 To $iErrorCol_Max - 1 If $iErrorCol_idx = 0 Then ConsoleWrite(@CRLF & _ "! ==> COM Error intercepted ==> ADO Error Collection: .errors.Count = " & $iErrorCol_Max & @CRLF & _ "") $oErr = $oADODB_Connection.errors.Item($iErrorCol_idx) ConsoleWrite(@CRLF & _ ">" & @TAB & "$oErr(" & $iErrorCol_idx & ").description is: " & @TAB & $oErr.description & @CRLF & _ ">" & @TAB & "$oErr(" & $iErrorCol_idx & ").number is: " & @TAB & @TAB & $oError.number & " in HEX is 0x" & Hex($oErr.number) & @CRLF & _ ">" & @TAB & "$oErr(" & $iErrorCol_idx & ").source is: " & @TAB & @TAB & $oErr.source & @CRLF & _ ">" & @TAB & "$oErr(" & $iErrorCol_idx & ").SQLState is: " & @TAB & @TAB & $oErr.SQLState & ' Description: ' & _SQLState_Description($oErr.SQLState) & @CRLF & _ ">" & @TAB & "$oErr(" & $iErrorCol_idx & ").NativeError is: " & @TAB & $oErr.NativeError & @CRLF & _ ">" & @TAB & " ErrorValueEnum description:" & @TAB & _ADO_MSDNErrorValueEnum_Description("0x" & Hex($oErr.NativeError)) & @CRLF & _ "-" & @TAB & "$oError.windescription:" & @TAB & @TAB & $oError.windescription & @CRLF & _ "-" & @TAB & "$oError.scriptline is: " & @TAB & @TAB & $oError.scriptline & @CRLF & _ "-" & @TAB & "$oError.helpfile is: " & @TAB & @TAB & $oError.helpfile & @CRLF & _ "-" & @TAB & "$oError.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ "-" & @TAB & "$oError.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ "-" & @TAB & "$oError.retcode is: " & @TAB & @TAB & "0x" & Hex($oError.retcode) & @CRLF & _ "-" & @TAB & "$oError.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _ "") Next $oADODB_Connection.errors.clear ConsoleWrite("! ==> COM End of Error Collections dump." & @CRLF) EndIf EndFunc ;==>_ErrFunc How many errors you see ? Why you need to fire Error to get Print Output ? Check this new Article on WIKI: https://www.autoitscript.com/wiki/ADO_Event_handling#First_example and here:1 point -
I can't believe there isn't a function for this, I was looking for one. Despite this being a really old thread, it showed up near the top of my search, so I'll put my solution here for posterity. A simple (6 lines) "while" loop will do the job: WinActivate("[TITLE:Google Chrome]") $currTab = WinGetTitle("[ACTIVE]") while StringInStr($currTab, "Yahoo!") = 0 Send('^{TAB}') $currTab = WinGetTitle("[ACTIVE]") WEnd1 point
-
Scrolling Window Capture
jimmy123j reacted to monoscout999 for a topic
I was trying to clean the bugs, but i still can not find a effective way to capture the bottom of the windows. maybe you can explain to us the method that you use in your Delphi code. This is what i was trying #include <WinAPI.au3> #include <GuiScrollBars.au3> #include <ScrollBarConstants.au3> #include <Array.au3> #include <GDIPlus.au3> #include <WindowsConstants.au3> ;~ Global Const $SRCCOPY = 0x00CC0020 ;Creating Random text. $Text = "Start of text" & @CRLF For $i = 0 To 300 $Text &= Random(0, 99999999999) $Text &= @CRLF Next $Text &= "End of text" ;Run Notepad and get handle. Run("Notepad.exe") $WinHndl = WinWait("[CLASS:Notepad]") If @error Then Exit ;Get Edit handle and put some text. $EditHndl = ControlGetHandle($WinHndl, "", "Edit1") ControlSetText($WinHndl, "", $EditHndl, $Text) ;Get Edit1 Vertical Scroll Min/Max range and page size. $aScrollRange = _GUIScrollBars_GetScrollRange($EditHndl, $SB_VERT) $iPageSize = _GUIScrollBars_GetScrollInfoPage($EditHndl, $SB_VERT) $iPages = Round(($aScrollRange[1] / $iPageSize) + 0.5) ; + 0.5 to round Up ;Getting width and Heigth. $aControlPos = ControlGetPos($WinHndl, "", $EditHndl) ;Getting ScrollBar Positions and exclude it from the capture. $tSCROLLBARINFO = _GUIScrollBars_GetScrollBarInfoEx($EditHndl, $OBJID_HSCROLL) $tpoint = DllStructCreate("int X;int Y") DllStructSetData($tpoint, "X", DllStructGetData($tSCROLLBARINFO, "Right")) DllStructSetData($tpoint, "Y", DllStructGetData($tSCROLLBARINFO, "Top")) _WinAPI_ScreenToClient($EditHndl, $tpoint) $Width = $aControlPos[2] ; DllStructGetData($tpoint, "X") $Height = DllStructGetData($tpoint, "Y") ;Preparing for capturing the screen. $hDC = _WinAPI_GetDC($EditHndl) $hCDC = _WinAPI_CreateCompatibleDC($hDC) $hBMP = _WinAPI_CreateCompatibleBitmap($hDC, $Width, $Height * $iPages) $hPen = _WinAPI_CreatePen($PS_SOLID, 2,0x0000FF) _WinAPI_SelectObject($hCDC, $hBMP) _WinAPI_SelectObject($hCDC, $hPen) $iPos = _GUIScrollBars_GetScrollPos($EditHndl, $SB_VERT) $iPosAux = _GUIScrollBars_GetScrollPos($EditHndl, $SB_VERT) $RelativeHeight = $Height ;Capturing the Screen. For $i = 0 To $iPages $iPosAux = _GUIScrollBars_GetScrollPos($EditHndl, $SB_VERT) If $iPosAux - $iPos < $iPageSize Then $RelativeHeight = ($iPosAux - $iPos) * $Height / $iPageSize EndIf $iPos = $iPosAux _WinAPI_BitBlt($hCDC, 0, $Height * $i, $Width, $Height, $hDC, 0,$RelativeHeight, $SRCCOPY) _WinAPI_DrawLine($hCDC,0,($Height * $i)-3,$Width,($Height * $i)-3) _WinAPI_PostMessage($EditHndl, $WM_VSCROLL, $SB_PAGEDOWN, 0) _WinAPI_PostMessage($EditHndl, $WM_VSCROLL, $SB_LINEDOWN, 0) Sleep(150) Next ;Release resources and save file. _WinAPI_ReleaseDC($EditHndl, $hDC) _WinAPI_DeleteDC($hCDC) _WinAPI_DeleteObject($hPen) _GDIPlus_Startup() $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBMP) _GDIPlus_ImageSaveToFile($hImage, @DesktopDir & "\TestCapture.bmp") _GDIPlus_Shutdown() _WinAPI_DeleteObject($hBMP)1 point