Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 02/13/2024 in all areas

  1. Introduction In AutoIt, we often have to deal with data structured like tables. Depending on the source, we sometimes have to write a lot of code to convert the data into a form that we can continue working with. Subsequently, working with this data is not necessarily any easier, as instead of accessing the descriptive names of the data attributes, we have to deal with numerical indices where it is very easy to lose track. Both problems are addressed by the UDF. In the basic approach, the UDF works with a table object (just an AutoIt map) in which the data is separated from the header. This enables cleaner processing of the data. It offers functions to read in data from various sources (CSV, array, string with fixed-width-columns, strings with their own column separators). Within this call, the data is separated from the header or header data is added to it in the first place. The data is then processed according to its format (with csv quotes and escapes removed, with fixed-width spaces removed...). In addition, the user can define how exactly the data should be processed for each column individually. He is completely free to do this. In this way, the data is already given the final format in which it is to be further processed when it is read in. The data can then be handled on a column-based or attribute-based basis. In other words, instead of using indices, the attribute names of the data can simply be used - this makes the code clearer. Example (much more examples provided >>here<<) We want to evaluate the open ports on a computer with AutoIt. The command line command for this is netstat -t and gives us the following output (Depending on the system, the output may look slightly different for you): Active Internet connections (w/o servers) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 116 192.168.64.110:ssh 192.168.29.200:65069 ESTABLISHED tcp 0 0 192.168.64.110:ssh 192.168.29.200:65068 ESTABLISHED To continue processing the data in a meaningful way, we may need to carry out the following steps in AutoIt: Delete the first useless lines Extract the header row (it is treated differently from the data) Create an array with the correct dimension to hold the data Separate the data either by spaces or by fixed column widths Removal of unnecessary spaces from the data Converting the Recv-Q and Send-Q column to a numeric data type (for sorting etc.) Separation of address data into IP address and port This can mean a lot of (error-prone) code effort. With this UDF, however, you can solve the whole thing in a single call as follows: $sString = 'Active Internet connections (w/o servers)' & @CRLF & _ '' & @CRLF & _ 'Proto Recv-Q Send-Q Local Address Foreign Address State' & @CRLF & _ 'tcp 0 116 192.168.64.110:ssh 192.168.29.200:65069 ESTABLISHED' & @CRLF & _ 'tcp 0 0 192.168.64.110:ssh 192.168.29.200:65068 ESTABLISHED' ; Transfer data to table type by using the size of every column: Global $mData = _td_fromFixWidth($sString, _ "left 6; Number 7; Number 7; StringSplit($x, ':', 2) 24;StringSplit($x, ':', 2) 24;", _ ; column definitions "1-2", _ ; skip row 1 to 2 True) ; display data _td_display($mData) and we get the result: If you now use functions such as _td_toObjects(), you can process the individual data with expressions such as $aData.Proto or $aData.State. This should be much clearer than having to deal with array indices. Functions >>sourcecode and download on github<<
    3 points
  2. Hello guys. I recently saw some posts that Windows 10 provides OCR API. So I decided to create a UDF. What's UWPOCR? UWPOCR UDF is a simple library to use Universal Windows Platform Optical character recognition API. Features. Get Text From Image File. Get Text From GDI+ Bitmap. Easy to use. Usage: #include "..\UWPOCR.au3" _Example() Func _Example() Local $sOCRTextResult = _UWPOCR_GetText(FileOpenDialog("Select Image", @ScriptDir & "\", "Images (*.jpg;*.bmp;*.png;*.tif;*.gif)")) MsgBox(0,"",$sOCRTextResult) EndFunc Get Words Rect(Example): More examples here. Check UWPOCR UDF on GitHub. Saludos
    1 point
  3. ... lets do some marketing first: pardon the image size of 225% scale on another monitor The idea is to have some DPI awareness in our GUIs and with this all you have to do is prefix "_HiDpi_" to your current code. Simple. This version ( HiDpi v. 0.2023.7.29(b) stable.zip ) is stable but only system aware. ( pictures above ) This next version ( HiDpi v. 0.2023.8.3(a) under development.zip ) is what I've got so far in regards of per-monitor awareness This one ( HiDpi v. 0.2023.8.4(ResizeTestbed) under development.zip ) is for the brave of heart. I'm looking for ideas. This is a testbed for anyone wanting to contribute regarding resizing controls. I have now started to use _WinAPI_DPI.au3 because I feel that this UDF is ready for that UDF. Therefore, too many and too big files for copy and paste. And that is good. Means that the UDF is getting closer to stable. FAQ (of sorts) Q: When did you come up with this ? A: Never. These are helper functions for _WinAPI_SetDPIAwareness.au3 but I did not get to finish. Nonetheless it's functional as is and applies to most of the cases in need of DPI awareness. Per-monitor would need more involved coding and I only have so much time and know how for now. Q: Will you open a ticket and ask to be included in the standard UDFs ? A: No. This is a just for now. Eventually the functionality would be a standard feature without the need of this. Q: Will you add ... A: Only in the case that either, I realize is needed and code it or, you code it and ask to be included in this bundle of functions UDF Q: This is not working ... A: The best way to go about a problem with this code is to open it's own thread in GUI Help and Support and post there with a mention of me. I'll read and answer there. Q: Are you going to share "logo4.gif", "SampleAVI.avi", etc. A: You are right. I forgot to say that the example file will work as expected if created in "..\Examples\GUI\HiDpi_v_n.n.n.n\", as a subfolder of where "SampleControls.au3" is at. There it will find all the files required for the example. Because after all, this example is that example but "_HiDpi_fied" ( so to say ). Q: Is there a tool that will magically update all my old scripts ? A: I've posted a script to get you closer but is not magical. Should work just fine for simple GUIs. Q: Are you going to work on a Per-monitor version ? A: yes, as time permits.
    1 point
  4. ok then. Your solution was the best for your setup, that unfortunately I don't have ( one of those ) to try out. Thanks @simplercoder000
    1 point
  5. @argumentum I tried it and doesn't shows any GUI windows. The output also doesn't prints any errors.
    1 point
  6. for example, this is the way it looks in each of my 2 monitors: placed one on top of the other. 100% and 225%. Even if you have one in Win7. And, sorry, I meant the one here at this post ( https://www.autoitscript.com/forum/topic/210604-tester-needed/#comment-1522028 ) not the first one. My bad.
    1 point
  7. A watchdog app would not work as tcplisten() fails to bind every time, even on a reboot, until I recompiled. It also doesn't make sense to change the port since a simple recompile allowed the script to begin binding with the same IP and port again. The port is hardcoded on my compiled script, as well as the c++ app on the main machine. It is not something we want to reconfigure often, as we need all machines to use the same version in the field. I'm 99% sure this isn't actually a code problem, but an OS problem, because like I said, it worked fine for over 30 days on these two machines and is still working fine on the other 47 machines, and simply recompiling the code with no change allows it to start functioning again.
    1 point
  8. before you settle for what you've found, please try and let me know. Thanks
    1 point
  9. Yes, sure Here's my previous example located here after patching it with HiDPI_Changes.au3 + adding two lines to enable the High DPI awareness: ;################################################################################################### ;### Start Added by HiDPI_Changes Utility ### #include <GDIPlus.au3> ;### Added by Res_HiDpi Global Const $_HiDPI_iScale = _HiDPI_IRatio() If @OSVersion = 'WIN_10' Then DllCall("User32.dll", "bool", "SetProcessDpiAwarenessContext" , "HWND", "DPI_AWARENESS_CONTEXT" -2) If @OSVersion = 'WIN_81' Or 'WIN_7' Then DllCall("User32.dll", "bool", "SetProcessDPIAware") MsgBox(0,'Returned DPI value', $_HiDPI_iScale) ;???does this work==>GUIRegisterMsg(0x02E0, "_HiDPI_IRatio") Func _HiDPI_IRatio() _GDIPlus_Startup() Local $hGfx = _GDIPlus_GraphicsCreateFromHWND(0) If @error Then Return SetError(1, @extended, 1) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetDpiX", "handle", $hGfx, "float*", 0) If @error Then Return SetError(2, @extended, 1) Local $iDPI = $aResult[2] _GDIPlus_GraphicsDispose($hGfx) Return $iDPI / 96 EndFunc ;==>_HiDPI_IRatio ;### End Added by HiDPI_Changes Utility ### ;################################################################################################### ; #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 220*$_HiDPI_iScale, 172*$_HiDPI_iScale, 195*$_HiDPI_iScale, 124*$_HiDPI_iScale) $Button1 = GUICtrlCreateButton("Button1", 32*$_HiDPI_iScale, 112*$_HiDPI_iScale, 75*$_HiDPI_iScale, 33*$_HiDPI_iScale) $Button2 = GUICtrlCreateButton("Button2", 114*$_HiDPI_iScale, 112*$_HiDPI_iScale, 75*$_HiDPI_iScale, 33*$_HiDPI_iScale) $Input1 = GUICtrlCreateInput("Input1", 48*$_HiDPI_iScale, 72*$_HiDPI_iScale, 121*$_HiDPI_iScale, 21*$_HiDPI_iScale) $Label1 = GUICtrlCreateLabel("Autoit are awesome !", 64*$_HiDPI_iScale, 24*$_HiDPI_iScale, 103*$_HiDPI_iScale, 17*$_HiDPI_iScale) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd
    1 point
  10. Hi, First of all I hope this forum doesn't forbidden pumping old threads. I have checked the value returned by '_HiDPI_IRatioGDIPlus' function and the value is '1' but when querying from the registry key the returned value are '1.5' so both values are little bit different. This little bit different are leading my GUI controls to not sorted well. This thread here contains a way to get current value of DPI used on the system via a registry key: Also please note that the High DPI won't be enabled unless it's been requested to be enabled by the user: So adding these two lines into my GUI script, after Jos's magic regex script has finished their work I can finally get my auto patched script working with High DPI feature ! If @OSVersion = 'WIN_10' Then DllCall("User32.dll", "bool", "SetProcessDpiAwarenessContext" , "HWND", "DPI_AWARENESS_CONTEXT" -2) If @OSVersion = 'WIN_81' Or 'WIN_7' Then DllCall("User32.dll", "bool", "SetProcessDPIAware") Please note that I have only tested this in Windows 7 x64
    1 point
  11. for now, play with EndFunc ;==>_HiDpi_GUICreate <<<< righ after this line add GUISetFont(4) ; add this. Change the font to something functional ?
    1 point
  12. ...yes, it's a pickle. This UDF am putting together is just helper functions for the rest of the code that I scrapped off the forum. Its "GuiCtrls_HiDpi" (UDF in progress). Unfortunately, right now, I'm really busy with work. I'll have a deep look at it as soon as I can install Win7 and give it full attention. Do pardon. I thought that the stable version was sufficiently functional.
    1 point
  13. I don't have a Win 7 to have a go at it The error was fortunately easy to correct but to see on a screen, I'll need to have a Win 7 to look at. It'll take me a few days to investigate. Then again, if _HiDpi_GetDpiForWindow() failed it means that the OS does not recognize it. @UEZ, help
    1 point
  14. I don't know how did I miss this thread, maybe I haven't search well, thank you! The High DPI issue must be treated as serious problem since not all users have the same screen sizes. I say this because I even notice that some internal AutoIt tools like Koda (Form Designer) or AutoIt3Wrapper GUI has the HiDPI issues.
    1 point
  15. Geeze, I don't know why I did it, but I went on a tangent with the button type while I was eating my pop-tart. I didn't research it much or do extensive testing but it seems to work. Func _ctrl_Button_isType($hWnd, $iStyle = Default) If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd) EndIf Local Const $BS_PUSHBUTTON = 0x0008 ; hmm, why isn't this in the constants? If ($iStyle == Default) Then $iStyle = _WinAPI_GetWindowLong($hWnd, $GWL_STYLE) ; I'm probably missing some but I got lazy Local $iRetVal = BitAND($iStyle, BitOR( _ $BS_BITMAP, _ $BS_DEFPUSHBUTTON, _ $BS_DEFSPLITBUTTON, _ $BS_FLAT, _ $BS_ICON, _ $BS_NOTIFY, _ $BS_OWNERDRAW, _ $BS_PUSHBUTTON, _ $BS_SPLITBUTTON)) Switch $iRetVal Case $BS_BITMAP, $BS_DEFPUSHBUTTON, $BS_DEFSPLITBUTTON, _ $BS_FLAT, $BS_ICON, $BS_NOTIFY, $BS_OWNERDRAW, _ $BS_PUSHBUTTON, $BS_SPLITBUTTON Return SetExtended($iRetVal, "PUSHBUTTON") EndSwitch $iRetVal = BitAND($iStyle, BitOR( _ $BS_3STATE, _ $BS_AUTO3STATE, _ $BS_AUTOCHECKBOX, _ $BS_CHECKBOX)) Switch $iRetVal Case $BS_3STATE, $BS_AUTO3STATE, $BS_AUTOCHECKBOX, $BS_CHECKBOX Return SetExtended($iRetVal, "CHECKBOX") EndSwitch $iRetVal = BitAND($iStyle, BitOR($BS_AUTORADIOBUTTON, $BS_RADIOBUTTON)) If $iRetVal = $BS_AUTORADIOBUTTON Or $iRetVal = $BS_RADIOBUTTON Then Return SetExtended($iRetVal, "RADIOBUTTON") EndIf $iRetVal = BitAND($iStyle, $BS_GROUPBOX) If $iRetVal = $BS_GROUPBOX Then Return SetExtended($iRetVal, "GROUPBOX") EndIf $iRetVal = BitAND($iStyle, BitOR($BS_COMMANDLINK, $BS_DEFCOMMANDLINK)) If $iRetVal = $BS_COMMANDLINK Or $iRetVal = $BS_DEFCOMMANDLINK Then Return SetExtended($iRetVal, "LINKBUTTON") EndIf Return SetError(1, $iRetVal, "") EndFunc
    1 point
  16. Recently I have noticed that Google time server frequently failed to respond to my time requests. So I switched to pool.ntp.org.
    1 point
  17. Another day, another update - new controls today! LRKnobs basically the same as a knob, but there is a center point maked on them. The name may change at some point, just unsure how to best describe them ATM. Vertical and horizontal meters. These are to be used with GuiCtrlsetData(), but I just realised you can still set these with the mouse wheel 😒. This will be fixed with the next update.
    1 point
  18. 1 point
  19. ...who allowed you two to come out of the chat room ! If you're not on topic, don't spam the thread.
    1 point
  20. This is the latest version of the script I have which has an UDF to do the changes for a list of GUI functions. There is still a lot of work to be done but maybe somebody wants to take it on... #cs ScriptName: HiDPI_Changes.au3 Description: Add the HiRes scaling to the GUI Functions #ce Global $Ifile = "" If $CMDLINE[0] Then $Ifile = $cmdline[1] While Not FileExists($Ifile) $Ifile = FileOpenDialog("File not found, select scriptfile to process :", Default, "AutoIt3 script (*.au3)", 1) If @error = 1 Then $rc = MsgBox(4100, "HiDPI process", "do you want to stop the process?") If $rc = 6 Then Exit EndIf ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $Ifile = ' & $Ifile & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console WEnd Global $ofile = StringReplace($Ifile, ".au3", "_hidpi.au3") Global $iSource = FileRead($Ifile) ; Check if GDIPlus.au3 is already present Global $GDI_Include = StringRegExp($iSource, "(?i)[""'<]\s*?GDIPlus.au3\s*?[""'>]") ; Add the required part at the top of the output script Global $oSource = ';###################################################################################################' & @CRLF $oSource &= ';### Start Added by HiDPI_Changes Utility ###' & @CRLF If Not $GDI_Include Then $oSource &= '#include <GDIPlus.au3> ;### Added by Res_HiDpi' & @CRLF $oSource &= 'Global Const $_HiDPI_iScale = _HiDPI_IRatio()' & @CRLF $oSource &= ';???does this work==>GUIRegisterMsg(0x02E0, "_HiDPI_IRatio")' & @CRLF $oSource &= 'Func _HiDPI_IRatio()' & @CRLF $oSource &= ' _GDIPlus_Startup()' & @CRLF $oSource &= ' Local $hGfx = _GDIPlus_GraphicsCreateFromHWND(0)' & @CRLF $oSource &= ' If @error Then Return SetError(1, @extended, 1)' & @CRLF $oSource &= ' Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetDpiX", "handle", $hGfx, "float*", 0)' & @CRLF $oSource &= ' If @error Then Return SetError(2, @extended, 1)' & @CRLF $oSource &= ' Local $iDPI = $aResult[2]' & @CRLF $oSource &= ' _GDIPlus_GraphicsDispose($hGfx)' & @CRLF $oSource &= ' Return $iDPI / 96' & @CRLF $oSource &= 'EndFunc ;==>_HiDPI_IRatio' & @CRLF $oSource &= ';### End Added by HiDPI_Changes Utility ###' & @CRLF $oSource &= ';###################################################################################################' & @CRLF $oSource &= ';' & @CRLF ; Add the input script $oSource &= $iSource Insert_Scale("GUICreate",$oSource) Insert_Scale("GUICtrlCreateButton",$oSource) Insert_Scale("GUICtrlCreateCheckbox",$oSource) Insert_Scale("GUICtrlCreateCombo",$oSource) Insert_Scale("GUICtrlCreateEdit",$oSource) Insert_Scale("GUICtrlCreateInput",$oSource) Insert_Scale("GUICtrlCreateLabel",$oSource) ; Write outputfile FileDelete($ofile) FileWrite($ofile, $oSource) Func Insert_Scale($iFunction, ByRef $uSource) ; Statements with 5 parameters filled in $uSource = StringRegExpReplace($uSource, "(?i)(" & $iFunction & "\(['""\$].*?['""]?)(,\s*?\d*\s*?)(,\s*?\d*\s*?)(,\s*?\d*\s*?)(,\s*?\d*\s*?)(\)|,)", "$1$2*$_HiDPI_iScale$3*$_HiDPI_iScale$4*$_HiDPI_iScale$5*$_HiDPI_iScale$6") $uSource = StringRegExpReplace($uSource, "(?i)(" & $iFunction & "\(['""\$].*?['""]?)(,\s*?\d*\s*?)(,\s*?\d*\s*?)(,\s*?(?:default|-1)\s*?)(,\s*?\d*\s*?)(\)|,)", "$1$2*$_HiDPI_iScale$3*$_HiDPI_iScale$4$5*$_HiDPI_iScale$6") $uSource = StringRegExpReplace($uSource, "(?i)(" & $iFunction & "\(['""\$].*?['""]?)(,\s*?\d*\s*?)(,\s*?\d*\s*?)(,\s*?(?:default|-1)\s*?)(,\s*?(?:default|-1)\s*?)(\)|,)", "$1$2*$_HiDPI_iScale$3*$_HiDPI_iScale$4$5$6") ; Statements with 4 parameters filled in $uSource = StringRegExpReplace($uSource, "(?i)(" & $iFunction & "\(['""\$].*?['""]?)(,\s*?\d*\s*?)(,\s*?\d*\s*?)(,\s*?\d*\s*?)(\)|,)", "$1$2*$_HiDPI_iScale$3*$_HiDPI_iScale$4*$_HiDPI_iScale$5") $uSource = StringRegExpReplace($uSource, "(?i)(" & $iFunction & "\(['""\$].*?['""]?)(,\s*?\d*\s*?)(,\s*?\d*\s*?)(,\s*?(?:default|-1)\s*?)(\)|,)", "$1$2*$_HiDPI_iScale$3*$_HiDPI_iScale$4*$5") ; Statements with 3 parameters filled in $uSource = StringRegExpReplace($uSource, "(?i)(" & $iFunction & "\(['""\$].*?['""]?)(,\s*?\d*\s*?)(,\s*?\d*\s*?)(\)|,)", "$1$2*$_HiDPI_iScale$3*$_HiDPI_iScale$4") ; Statements with 2 parameters filled in $uSource = StringRegExpReplace($uSource, "(?i)(" & $iFunction & "\(['""\$].*?['""]?)(,\s*?\d*\s*?)(\)|,)", "$1$2*$_HiDPI_iScale$3") Return EndFunc
    1 point
  21. EX: Flash Player 24.0.0.194.exe Local $search = FileFindFirstFile("Flash Player*.exe") If $search = -1 Then MsgBox(0, "Error", "No files/directories matched the search pattern") Exit Else Local $file = FileFindNextFile($search) $Exe = @ScriptDir & '\' & $file ShellExecuteWait($Exe, '-install') MsgBox(64, 'FlashPlayer', 'Complete!') EndIf This is what i use to install flash player, only the numbers after this change, so this works every time. I guess for you you could use FileFindFirstFile("erwin Data Modeler*.exe") StringInStr($vElement, "32-bit")>0 Then
    1 point
  22. Got it, Thanks @Starf0x Func GetFileList($dir) ; List all the files and folders in the desktop directory using the default parameters. Local $aFileList = _FileListToArray($dir, "*") If @error = 1 Then MsgBox($MB_SYSTEMMODAL, "", "Path was invalid.") Exit EndIf If @error = 4 Then MsgBox($MB_SYSTEMMODAL, "", "No file(s) were found.") Exit EndIf ; Display the results returned by _FileListToArray. ;_ArrayDisplay($aFileList, "$aFileList") For $vElement In $aFileList if StringInStr($vElement, "erwin Data Modeler")>0 and StringInStr($vElement, "32-bit")>0 Then return $vElement EndIf Next return "0" EndFunc ;==>Example
    1 point
×
×
  • Create New...