Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 10/25/2017 in all areas

  1. Gianni

    TSP art generator

    After reading this page, (http://www.drububu.com/illustration/tsp/index.html) I was curious and I put together this script. it is not a "stand alone" script, as it uses some third parties programs*, but in few steps it acomplish the conversion to the TSP art. The generated images are quite nice, but you have to try more attempts to find the right combinations of parameters for different source images. Best results can easily obtained with schematic black and wite images. Drag and drop for example something like in this link. Also, set the "Variable thickness line" option and try with the image at this link for another example: (https://images.fineartamerica.com/images/artworkimages/mediumlarge/1/david-michelangelo-murphy-elliott.jpg) Since used programs generate also some temporay files, please save this script and the dependencies into a single folder so to avoid the scattering of files around and also allowing the main script to find the needed programs. Example of an TSP art generated with this script and related programs (the image on the left is converted in the image on the right) just drag and drop images on the GUI of the script and all is done automatically. * Here are the links to download the needed "dependencies": ( just put all the stuff in a single folder along with the script.) voronoi.exe http://www.drububu.com/illustration/tsp/voronoi.zip stippler.dll also contained in the above archive concorde.exe http://www.math.uwaterloo.ca/tsp/concorde/downloads/codes/cygwin/concorde.exe.gz this program needs the cygwin dll (a very nice one) (I've used 7zip to open this archive) cygwin1.dll https://cygwin.com/snapshots/ get one x86 cygwin1-xxxxxxxx.dll.xz (only dll) svg_extract.exe http://www.drububu.com/illustration/tsp/svg_extract.zip tsp2svg.exe http://www.drububu.com/illustration/tsp/tsp2svg.zip here the script: ; TSP Art generator #include <FileConstants.au3> #include <WinAPISys.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiEdit.au3> #include <GDIPlus.au3> If Not _CheckDependencies() Then Exit ; can't run without dependencies. Global $bDropped, $sFile, $bDropAllowed = True ; create a blank file, or empty it if it's already created Global $hTail, $sLogFile = FileGetShortName(@ScriptDir & "\LogFile.txt") _GDIPlus_Startup() ; just for image format conversion to PNG (if needed) $Form1 = GUICreate("TSP art generator", 500, 650, -1, -1, -1, $WS_EX_ACCEPTFILES) ; --- options $Combo1 = GUICtrlCreateCombo("", 350, 505, 60, 25) GUICtrlCreateLabel("Sampling points", 415, 510, 80, 25) GUICtrlSetData($Combo1, "1000|2000|4000|6000|8000|10000|20000|40000|60000", "4000") ; some sampling rate $Checkbox1 = GUICtrlCreateCheckbox("Variable thickness line", 350, 535, 145, 25) $Checkbox2 = GUICtrlCreateCheckbox("Color (voronoi only)", 350, 565, 145, 25) ; --- Log viewer Global $hLog = GUICtrlCreateEdit("", 5, 500, 340, 145, BitOR($WS_VSCROLL, $WS_HSCROLL, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_MULTILINE, $ES_READONLY)) ; log viewer GUICtrlSetBkColor(-1, 0x000000) GUICtrlSetColor(-1, 0x00FF00) GUICtrlSetFont(-1, 9, -1, -1, "Courier New") ; following is a transparent control over the browser control ; purpose is to avoid that the drop event is captured by the browser control $hGlass = GUICtrlCreateLabel("", 0, 0, 500, 650) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) ; This is like a glass over the following underlying browser Control GUICtrlSetCursor(-1, 2) ; Cursor is an arrow (instead of the default I-beam) ; --- Embed a browser control Global $oIE = ObjCreate("Shell.Explorer.2") $hIE = GUICtrlCreateObj($oIE, 5, 5, 490, 490) $oIE.navigate("about:blank") AutoItSetOption("GUIOnEventMode", 1) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") GUIRegisterMsg($WM_DROPFILES, "WM_DROPFILES") GUISetState(@SW_SHOW, $Form1) _LogPrint(@CRLF & _ "Hello," & @CRLF & _ "Drag and dropping images here above," & @CRLF & _ "will be converted into a TSP Art." & @CRLF & _ "have fun...") ; --- Main loop While 1 $nMsg = GUIGetMsg() Select Case $nMsg = $GUI_EVENT_CLOSE _Exit() Case $bDropped = True $bDropped = False $bDropAllowed = False ; Drop not allowed while generating _Generate_PST_Art() $bDropAllowed = True EndSelect WEnd ; --- Call externa programs the right sequence Func _Generate_PST_Art() _EmptyLog() ; empty the temporary log file _checkFileFormat($sFile) ; if dropped image isn't a PNG convert it to PNG _ShowInBrowser($sFile) ; show dropped image in the browser control ; step 1) Transform PNG image into a voronoi svg image ; ============================================================================ If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then ; variable thickness line? $sOptions = "" Else $sOptions = " -f " ; fixed radus EndIf If GUICtrlRead($Checkbox2) = $GUI_CHECKED Then ; color points for voronoi? $sOptions = " -c " & $sOptions EndIf ; _call_External_Program(".\voronoi.exe " & $sOptions & "-s " & GUICtrlRead($Combo1) & " -n -I " & $sFile & " -O out.svg", True) _call_External_Program(FileGetShortName(@ScriptDir & '\voronoi.exe') & $sOptions & ' -s ' & GUICtrlRead($Combo1) & ' -n -I ' & $sFile & ' -O out.svg', True) _ShowInBrowser(FileGetShortName(@ScriptDir & "\out.svg")) ; show generated voronoi image in the browser control ; ; step 2) Extract points from the voronoi svg image and save to positions.tsp file ; for later input by the concorde TSP solver ; ============================================================================ _call_External_Program(FileGetShortName(@ScriptDir & '\svg_extract.exe') & " out.svg") _LogPrint("... going to next step ...") ; ; step 3) Resolve the Traveling Salesman Problem using the very good ; concorde.exe program (it needs the presence of the cygwin1.dll to work) ; ============================================================================ _call_External_Program(FileGetShortName(@ScriptDir & "\concorde.exe") & " -V -o tour.cyc positions.tsp", True) _LogPrint("... going to next step ...") ; ; step 3a) some adjustments to the tour.cyc file generated by concorde.exe ; ============================================================================ $hfile = FileOpen(FileGetShortName(@ScriptDir & '\tour.cyc')) Local $sContent = FileRead($hfile) FileClose($hfile) FileDelete(FileGetShortName(@ScriptDir & '\tour.cyc')) $sContent = StringReplace($sContent, Chr(0x20), Chr(0x0A)) _LogPrint("Replaced 0x20 with 0x0A " & @extended & " times.") $sContent = StringReplace($sContent, Chr(0x0A) & Chr(0x0A), Chr(0x0A)) _LogPrint("Replaced 0x0A 0x0A with 0x0A " & @extended & " times." & @CRLF) Local $x = StringInStr($sContent, Chr(0x0A)) ; first 0A $sContent = StringMid($sContent, $x + 1) ; remove first data (it's the number of points, not a point) $hfile = FileOpen(FileGetShortName(@ScriptDir & '\tour.cyc'), $FO_OVERWRITE + $FO_BINARY) FileWrite($hfile, $sContent) ; save adjusted data FileFlush($hfile) FileClose($hfile) ; ; step 4) "merge" data from out.svg and tour.cyc into the final tsp_art.svg file ; ============================================================================ If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then $sOptions = " +w" ; variable thickness line Else $sOptions = "" ; fixed thickness line EndIf $sOptions = FileGetShortName(@ScriptDir & "\tsp2svg.exe") & " out.svg tour.cyc" & $sOptions _call_External_Program($sOptions) _ShowInBrowser(FileGetShortName(@ScriptDir & "\tsp_art.svg")) _LogPrint(@CRLF & _ "+-----------------------------------+" & @CRLF & _ "| End of conversion --> tsp_art.svg |" & @CRLF & _ "+-----------------------------------+" & @CRLF) EndFunc ;==>_Generate_PST_Art ; === Functions Func _call_External_Program($sCommand, $bVerbose = False) Local $sLine If $bVerbose = True Then $sCommand = @ComSpec & " /c " & $sCommand & ">>" & $sLogFile & " 2>>&1" EndIf Local $hPid = Run($sCommand, ".", @SW_HIDE) If Not $hPid Then _LogPrint("Error on run external program" & @CRLF) Return SetError(1) EndIf Do If $bVerbose Then $sLine = FileReadLine($hTail) If Not @error Then _LogPrint($sLine) EndIf EndIf Until Not ProcessExists($hPid) If $bVerbose Then $sLine = "..." ; "Task execution terminated ...." Do _LogPrint($sLine) $sLine = FileReadLine($hTail) Until @error EndIf EndFunc ;==>_call_External_Program Func _LogPrint($sLine) If StringLen(GUICtrlRead($hLog)) > 25000 Then ; Max Len of a CtrlBox is 30000 char _GUICtrlEdit_SetText($hLog, StringRight(GUICtrlRead($hLog), 20000)) ; short the content of CtrlBox to 20000 char EndIf _GUICtrlEdit_AppendText($hLog, $sLine & @CRLF) EndFunc ;==>_LogPrint Func WM_DROPFILES($hWnd, $iMsg, $wParam, $lParam) If $bDropAllowed Then Local $sExt = ".bmp|.png|.jpg|.gif" ; img drop filtering thanks to @UEZ Local $aFileList = _WinAPI_DragQueryFileEx($wParam) If Not @error Then For $i = 1 To $aFileList[0] If StringInStr($sExt, StringRegExpReplace($aFileList[$i], ".*(\.+)", "$1")) Then $bDropped = True $sFile = FileGetShortName($aFileList[$i]) ExitLoop EndIf Next Else _LogPrint("Error on drop" & @CRLF) EndIf _WinAPI_DragFinish($wParam) _LogPrint("Droped: " & $sFile & @CRLF) Return 0 EndIf EndFunc ;==>WM_DROPFILES Func _ShowInBrowser($sImg) ; setup Javascript engine with also embeded the "entity" library If StringRight($sImg, 3) = "svg" Then Else EndIf ; *** create a minimal 'html' page listing for the browser control Local $sHTML = "<HTML><HEAD>" & @CRLF & _ "<meta http-equiv=""X-UA-Compatible"" content=""IE=edge"" />" & @CRLF & _ "</HEAD>" & @CRLF & _ "<body>" & @CRLF & _ '<img src="' & $sImg & '" style="width:100%; height:100%;" />' & @CRLF & _ "</body>" & @CRLF & _ "</HTML>" & @CRLF ; html closing tags ; *** end of html page listing ; _LogPrint(">_" & @CRLF) $oIE.navigate('about:blank') While Not String($oIE.readyState) = 'complete' ; wait for about:blank Sleep(100) WEnd $oIE.document.Write($sHTML) ; inject lising directly to the HTML document: $oIE.document.close() ; close the write stream Sleep(1000) $oIE.document.execCommand("Refresh") EndFunc ;==>_ShowInBrowser Func _checkFileFormat($sFile) Local $hImage = _GDIPlus_ImageLoadFromFile($sFile) Local $aFormat = _GDIPlus_ImageGetRawFormat($hImage) If $aFormat[1] <> "PNG" Then _ConvertToPNG($hImage) _GDIPlus_ImageDispose($hImage) EndFunc ;==>_checkFileFormat Func _ConvertToPNG(ByRef $hImage) Local $CLSID = _GDIPlus_EncodersGetCLSID('PNG') $sFile = FileGetShortName(@ScriptDir & "\Input.png") _GDIPlus_ImageSaveToFileEx($hImage, $sFile, $CLSID) EndFunc ;==>_ConvertToPNG Func _EmptyLog() FileClose($hTail) $hTail = FileOpen($sLogFile, $FO_OVERWRITE) FileWrite($hTail, "Start log: " & @YEAR & '/' & @MON & '/' & @MDAY & ' ' & @HOUR & ':' & @MIN & ':' & @SEC & @CRLF) FileFlush($hTail) FileClose($hTail) $hTail = FileOpen($sLogFile) ; read only EndFunc ;==>_EmptyLog Func _CheckDependencies() Local $iDependencie = 0 $iDependencie += FileExists(@ScriptDir & "\voronoi.exe") ; http://www.drububu.com/illustration/tsp/voronoi.zip $iDependencie += FileExists(@ScriptDir & "\stippler.dll") ; " also contained in the above archive $iDependencie += FileExists(@ScriptDir & "\concorde.exe") ; http://www.math.uwaterloo.ca/tsp/concorde/downloads/codes/cygwin/concorde.exe.gz $iDependencie += FileExists(@ScriptDir & "\cygwin1.dll") ; get one from here https://cygwin.com/snapshots/ get cygwin1-xxxxxxxxx.dll.xz $iDependencie += FileExists(@ScriptDir & "\svg_extract.exe") ; http://www.drububu.com/illustration/tsp/svg_extract.zip $iDependencie += FileExists(@ScriptDir & "\tsp2svg.exe") ; http://www.drububu.com/illustration/tsp/tsp2svg.zip Return $iDependencie = 6 EndFunc ;==>_CheckDependencies Func _Exit() _GDIPlus_Shutdown() FileClose($hTail) AutoItSetOption("GUIOnEventMode", 0) GUIRegisterMsg($WM_DROPFILES, "") Exit EndFunc ;==>_Exit
    4 points
  2. [BUGFIX VERSION] - 6 Apr 24 Fixed: UDF failed if header colours were initialised but not specifically set. New UDF in the zip below. -------------------------------------------------------------------------------------- Note: This is a new recoded and expanded version of my earlier UDF of the same name. If you move to this new version there might well be several script-breaking changes, particularly when setting which columns are to be editable. Please read the "Beginner's Guide" and look at the included example scripts to see where things have changed. -------------------------------------------------------------------------------------- This UDF allows you to do much more with ListView controls (either native or UDF created): Edit the content with plain text, combos or date-time pickers - and edit the headers too Move rows within the ListView Drag rows both within the ListView and to other ListViews in the same GUI (or not as required) Insert and delete columns and rows Sort columns by simply clicking the header Colour individual ListView items and headers Only select a single cell rather then the entire row Save and load entire ListViews For the advanced user: If you use certain Windows message handlers (In particular WM_NOTIFY) in your script, please read the function headers for the equivalent handlers within the UDF. Here is the UDF, with 6 examples and the guide, in zip format: GUIListViewEx.zip Credit to: martin (basic drag code), Array.au3 authors (array functions), KaFu and ProgAndy (font function), LarsJ (colouring code) Happy to take compliments or criticism - preferably the former! M23
    1 point
  3. Zedna

    Barcode - UDF

    OPENBARCODES project http://grandzebu.net/index.php?page=/informatique/codbar-en/codbar.htm all is under GPL - GNU license , open source and completely free... I translated original Pascal functions to PowerBuilder syntax which is very similar to AutoIt (BARCODE_powerbuilder.zip). Now I translated all barcode functions to AutoIt syntax (barcode_autoit.zip). BarCode UDF + example --> you must install aproppriate TTF fonts into Windows first. barcode.au3 barcode_test.au3 print.au3 code128.ttf code25I.ttf code39.ttf ean13.ttf Available functions: barcode_128() barcode_ean8() barcode_ean13() barcode_25i() barcode_39() ; TTF fonts must be installed in system first #AutoIt3Wrapper_run_obfuscator=y #Obfuscator_parameters=/so #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> #include <print.au3> #include <barcode.au3> $barcode_test = GUICreate("BarCode Test", 601, 174, -1, -1) GUICtrlCreateLabel("Input:", 11, 10, 30, 17) $Input = GUICtrlCreateInput("", 41, 8, 120, 21) GUICtrlCreateLabel("Output:", 171, 10, 38, 17) $Output = GUICtrlCreateInput("", 209, 8, 120, 21) GUICtrlSetState(-1, $GUI_DISABLE) $print = GUICtrlCreateButton("Print", 340, 7, 39, 23) GUICtrlCreateLabel("Type:", 387, 10, 28, 17) $type = GUICtrlCreateCombo("", 417, 8, 91, 25, BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL)) GUICtrlSetData(-1, "Code 128|EAN 8|EAN 13|Code 2 of 5 i|Code 3 of 9", "Code 128") GUICtrlCreateLabel("Size:", 517, 10, 25, 17) $size = GUICtrlCreateCombo("", 543, 8, 47, 25, BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL)) GUICtrlSetData(-1, "12|18|24|36|48|60|72", "48") $barcode = GUICtrlCreateLabel("", 10, 39, 580, 130) GUICtrlSetFont(-1, 48, 400, 0, "Code 128") GUICtrlSetBkColor(-1, 0xFFFFFF) GUISetState(@SW_SHOW) GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $type ChangeFont() ApplyBarcode() Case $size ChangeFont() Case $print Print() EndSwitch WEnd Func WM_COMMAND($hWinHandle, $iMsg, $wParam, $lParam) If _WinAPI_HiWord($wParam) = $EN_CHANGE And _WinAPI_LoWord($wParam) = $Input Then ApplyBarcode() EndIf EndFunc Func ChangeFont() Switch GUICtrlRead($type) Case 'Code 128' $font_name = 'Code 128' Case 'EAN 8','EAN 13' $font_name = 'Code EAN13' Case 'Code 2 of 5 i' $font_name = 'Code 2 of 5 interleaved' Case 'Code 3 of 9' $font_name = 'Code 3 de 9' EndSwitch GUICtrlSetFont($barcode, GUICtrlRead($size), 400, 0, $font_name) EndFunc Func ApplyBarcode() Switch GUICtrlRead($type) Case 'Code 128' $barcode_data = barcode_128(GUICtrlRead($Input)) Case 'EAN 8' $barcode_data = barcode_ean8(GUICtrlRead($Input)) Case 'EAN 13' $barcode_data = barcode_ean13(GUICtrlRead($Input)) Case 'Code 2 of 5 i' $barcode_data = barcode_25i(GUICtrlRead($Input)) Case 'Code 3 of 9' $barcode_data = barcode_39(GUICtrlRead($Input)) EndSwitch GUICtrlSetData($Output, $barcode_data) GUICtrlSetData($barcode, $barcode_data) EndFunc ; print given text on default printer in given size by all available barcode types Func Print() $sPrinter = _GetDefaultPrinter() If $sPrinter = "" Then Return $hPrintDC = _WinAPI_CreateDC("winspool", $sPrinter) _InitPrinter($hPrintDC, "Printing Barcodes from AutoIt") ; print job name $hFont = _CreateFont_Simple('Arial', 12, $FW_BOLD) $hFontOld = _WinAPI_SelectObject($hPrintDC, $hFont) _TextOut_Centered($hPrintDC, 500, 'Input data: ' & GUICtrlRead($Input), 0xFF0000) _WinAPI_SelectObject($hPrintDC, $hFontOld) _WinAPI_DeleteObject($hFont) $hFont = _CreateFont_Simple('Courier', 10, $FW_NORMAL) $hFontOld = _WinAPI_SelectObject($hPrintDC, $hFont) _WinAPI_SetTextColor($hPrintDC, 0x000000) _TextOut_Centered($hPrintDC, 1400, 'Code 128') _TextOut_Centered($hPrintDC, 2400, 'EAN 8') _TextOut_Centered($hPrintDC, 3400, 'EAN 13') _TextOut_Centered($hPrintDC, 4400, 'Code 2 of 5 i') _TextOut_Centered($hPrintDC, 5400, 'Code 3 of 9') _WinAPI_SelectObject($hPrintDC, $hFontOld) _WinAPI_DeleteObject($hFont) $hFont = _CreateFont_Simple('Code 128', GUICtrlRead($size), $FW_NORMAL) $hFontOld = _WinAPI_SelectObject($hPrintDC, $hFont) _TextOut_Centered($hPrintDC, 1500, barcode_128(GUICtrlRead($Input))) _WinAPI_SelectObject($hPrintDC, $hFontOld) _WinAPI_DeleteObject($hFont) $hFont = _CreateFont_Simple('Code EAN13', GUICtrlRead($size), $FW_NORMAL) $hFontOld = _WinAPI_SelectObject($hPrintDC, $hFont) _TextOut_Centered($hPrintDC, 2500, barcode_ean8(GUICtrlRead($Input))) _WinAPI_SelectObject($hPrintDC, $hFontOld) _WinAPI_DeleteObject($hFont) $hFont = _CreateFont_Simple('Code EAN13', GUICtrlRead($size), $FW_NORMAL) $hFontOld = _WinAPI_SelectObject($hPrintDC, $hFont) _TextOut_Centered($hPrintDC, 3500, barcode_ean13(GUICtrlRead($Input))) _WinAPI_SelectObject($hPrintDC, $hFontOld) _WinAPI_DeleteObject($hFont) $hFont = _CreateFont_Simple('Code 2 of 5 interleaved', GUICtrlRead($size), $FW_NORMAL) $hFontOld = _WinAPI_SelectObject($hPrintDC, $hFont) _TextOut_Centered($hPrintDC, 4500, barcode_25i(GUICtrlRead($Input))) _WinAPI_SelectObject($hPrintDC, $hFontOld) _WinAPI_DeleteObject($hFont) $hFont = _CreateFont_Simple('Code 3 de 9', GUICtrlRead($size), $FW_NORMAL) $hFontOld = _WinAPI_SelectObject($hPrintDC, $hFont) _TextOut_Centered($hPrintDC, 5500, barcode_39(GUICtrlRead($Input))) _WinAPI_SelectObject($hPrintDC, $hFontOld) _WinAPI_DeleteObject($hFont) _DeInitPrinter($hPrintDC) EndFunc History: 2012-06-01 - only Code 128 translated 2012-06-03 - all functions translated 2012-06-04 - added Print + some inner optimizations Original idea comes from this topic: Previous downloads (AutoIt): 31 BARCODE_powerbuilder.zip barcode_autoit.zip Printing Barcodes from AutoIt.pdf
    1 point
  4. For quite some time now, I have had it in mind to redo and upgrade Cyberslug's GuiBuilder (also called AutoBuilder). Well, that time is finally here. Why you ask? {1} I have always preferred its no nonsense simplicity that allows you to get down and dirty with coding quickly, not hampered by other elements taking up screen space, etc. {2} It is the main reason I am still coding with AutoIt v3.3.0.0 ... the last supported version by GuiBuilder. Haven't others made attempts at updating GuiBuilder? And why not help them? {3} Yes they have. The latest probably being GuiBuilderNxt by jaberwacky, who I did assist to a minor degree. {4] While I have great respect for the work he did, and that done by others, they were not really working on the type of update I wanted. I just wanted an update, with very few extra bells & whistles. {5] I also want a version that I can maintain, that is written in a structure I understand more easily than it currently is. In short, I want it written in the style I code in. To do that, it is necessary that I set aside time, to dissect the last version of GuiBuilder (which was the one I updated to support AutoIt v3.3.0.0), so that I can more fully understand what is going on. In the past, my updates, have just been simplistic tweaks to existing code, without understanding anymore than I had to. This time, it will be entirely different. {6} I don't work well with the way other people code, and it will be enough of a struggle deciphering things as it is. But seriously, why not just use one of the existing GUI creators? {7} I am well aware of all those, but none have the simplicity and directness I want. Apart from basic GUI elements, I manually code everything or copy & paste from prolific examples I have built up over the years. I like to keep things simple, and that extends to less clutter on the desktop working environment ... less to look at. Is this project a collaborative one? {8} NO, not at this stage. It may become that, to some degree, if I get stumped by something. After I have finished the project though, it will be open to others to extend, so at that point it could become collaborative under a slightly different name ... remembering all the points I mentioned previously for my version - maintenance etc. Finally. {9} GuiBuilder or AutoBuilder as it was called at one point, was the very first GUI creator for AutoIt, which you can read about here. I would like to do justice to it and Cyberslug, the original creator, for it was a very important part of AutoIt when it first came out, and was for a very long time, part of the AutoIt install, even for a while after Koda was first included. When it was eventually superseded, I well remember Jon asking if anyone was willing to update it, so that it could be kept as part of the AutoIt install, but as an example only. Some time later, I tweaked it, so that it would work with AutoIt v3.3.0.0, but I didn't revamp the code, which was pretty much all over the shop, so ultimately it wasn't suitable as an example. So here's hoping. Especially as life has a habit of intruding and sending things awry. Wish me luck! P.S. It is my intention to report here from time to time, on how things are going .... maybe even provide some code, discuss difficulties, plans, methods, etc. Source.au3 (last version, Prototype 0.9, supports AutoIt v3.3.0.0 and Win XP) (no resources provided yet, just for reference) Screenshot of v0.9
    1 point
  5. You can convert the PDF to text using XPDF tools -- https://www.xpdfreader.com/download.html
    1 point
  6. @Earthshine Thanks for the information. I will try it out and let you know the results.
    1 point
  7. Use InetGet to download the file. Then manipulate it outside of the browser.
    1 point
  8. Have you searched the forums? A quick look found these threads --
    1 point
  9. $token = StringRegExpReplace($sData, '^.*?token":"([^"]+).*', "$1")
    1 point
  10. if it is always between the 3rd and 4th quotes $str = '{"token":"B6LdPUAgg14..","expires":15081,"ssl":true}' consolewrite(stringmid($str , StringInStr($str , '"' , 0 , 3) + 1 , StringInStr($str , '"' , 0 , 4) - StringInStr($str , '"' , 0 , 3) - 1)) and another that gets the thing after token, sans regex $str = '{"token":"B6LdPUAgg14..","expires":15081,"ssl":true}' consolewrite(stringleft(stringsplit($str, '"token":"' , 3)[1] , stringinstr(stringsplit($str, '"token":"' , 3)[1] , '"' , 1) - 1))
    1 point
  11. Martino, What do you find difficult about retrieving the array using the _ReturnArray function? You just call the function using the handle/ControlID of the ListView. As to checking the content for format etc, you can do this 2 ways: check after each individual edit action as the _EventMonitor function returns an array of the changed elements; or read the content into an array as above and check each element at that time. Let me know which of the two you prefer and I will amend my example above to show how it can be done. M23
    1 point
  12. Notice how different this is from " I'm searching a way to do xor and shift and if possible also other operations."? Providing people with all the information they need helps us help you How about a detailed explanation and example of what you would like to accomplish?
    1 point
  13. Dog ate your help file? See BitXor and related functions here: https://www.autoitscript.com/autoit3/docs/functions/BitXOR.htm
    1 point
  14. Martino, F.Y.I. after looking at your code... Please note, do NOT call a blocking function (InputBox and MsgBox) from within a registered function or a function called by a registered function. Also, you are trying to delete and recreate your gui from a function that will return to a registered function. That may also cause problems. kylomas
    1 point
  15. Hello. basically You need to traslate this to AutoIt. #include <windows.h> #include <wincrypt.h> #include <wintrust.h> #include <stdio.h> #include <tchar.h> #pragma comment(lib, "crypt32.lib") #define ENCODING (X509_ASN_ENCODING | PKCS_7_ASN_ENCODING) typedef struct { LPWSTR lpszProgramName; LPWSTR lpszPublisherLink; LPWSTR lpszMoreInfoLink; } SPROG_PUBLISHERINFO, *PSPROG_PUBLISHERINFO; BOOL GetProgAndPublisherInfo(PCMSG_SIGNER_INFO pSignerInfo, PSPROG_PUBLISHERINFO Info); BOOL GetDateOfTimeStamp(PCMSG_SIGNER_INFO pSignerInfo, SYSTEMTIME *st); BOOL PrintCertificateInfo(PCCERT_CONTEXT pCertContext); BOOL GetTimeStampSignerInfo(PCMSG_SIGNER_INFO pSignerInfo, PCMSG_SIGNER_INFO *pCounterSignerInfo); int _tmain(int argc, TCHAR *argv[]) { WCHAR szFileName[MAX_PATH]= L"C:\\Program Files (x86)\\VideoLAN\\VLC\\vlc.exe"; HCERTSTORE hStore = NULL; HCRYPTMSG hMsg = NULL; PCCERT_CONTEXT pCertContext = NULL; BOOL fResult; DWORD dwEncoding, dwContentType, dwFormatType; PCMSG_SIGNER_INFO pSignerInfo = NULL; PCMSG_SIGNER_INFO pCounterSignerInfo = NULL; DWORD dwSignerInfo; CERT_INFO CertInfo; SPROG_PUBLISHERINFO ProgPubInfo; SYSTEMTIME st; ZeroMemory(&ProgPubInfo, sizeof(ProgPubInfo)); __try { /* if (argc != 2) { _tprintf(_T("Usage: SignedFileInfo <filename>\n")); return 0; } */ #ifdef UNICODE lstrcpynW(szFileName, argv[1], MAX_PATH); #else if (mbstowcs(szFileName, argv[1], MAX_PATH) == -1) { printf("Unable to convert to unicode.\n"); __leave; } #endif // Get message handle and store handle from the signed file. fResult = CryptQueryObject(CERT_QUERY_OBJECT_FILE, szFileName, CERT_QUERY_CONTENT_FLAG_PKCS7_SIGNED_EMBED, CERT_QUERY_FORMAT_FLAG_BINARY, 0, &dwEncoding, &dwContentType, &dwFormatType, &hStore, &hMsg, NULL); if (!fResult) { _tprintf(_T("CryptQueryObject failed with %x\n"), GetLastError()); __leave; } // Get signer information size. fResult = CryptMsgGetParam(hMsg, CMSG_SIGNER_INFO_PARAM, 0, NULL, &dwSignerInfo); if (!fResult) { _tprintf(_T("CryptMsgGetParam failed with %x\n"), GetLastError()); __leave; } // Allocate memory for signer information. pSignerInfo = (PCMSG_SIGNER_INFO)LocalAlloc(LPTR, dwSignerInfo); if (!pSignerInfo) { _tprintf(_T("Unable to allocate memory for Signer Info.\n")); __leave; } // Get Signer Information. fResult = CryptMsgGetParam(hMsg, CMSG_SIGNER_INFO_PARAM, 0, (PVOID)pSignerInfo, &dwSignerInfo); if (!fResult) { _tprintf(_T("CryptMsgGetParam failed with %x\n"), GetLastError()); __leave; } // Get program name and publisher information from // signer info structure. if (GetProgAndPublisherInfo(pSignerInfo, &ProgPubInfo)) { if (ProgPubInfo.lpszProgramName != NULL) { wprintf(L"Program Name : %s\n", ProgPubInfo.lpszProgramName); } if (ProgPubInfo.lpszPublisherLink != NULL) { wprintf(L"Publisher Link : %s\n", ProgPubInfo.lpszPublisherLink); } if (ProgPubInfo.lpszMoreInfoLink != NULL) { wprintf(L"MoreInfo Link : %s\n", ProgPubInfo.lpszMoreInfoLink); } } _tprintf(_T("\n")); // Search for the signer certificate in the temporary // certificate store. CertInfo.Issuer = pSignerInfo->Issuer; CertInfo.SerialNumber = pSignerInfo->SerialNumber; pCertContext = CertFindCertificateInStore(hStore, ENCODING, 0, CERT_FIND_SUBJECT_CERT, (PVOID)&CertInfo, NULL); if (!pCertContext) { _tprintf(_T("CertFindCertificateInStore failed with %x\n"), GetLastError()); __leave; } // Print Signer certificate information. _tprintf(_T("Signer Certificate:\n\n")); PrintCertificateInfo(pCertContext); _tprintf(_T("\n")); // Get the timestamp certificate signerinfo structure. if (GetTimeStampSignerInfo(pSignerInfo, &pCounterSignerInfo)) { // Search for Timestamp certificate in the temporary // certificate store. CertInfo.Issuer = pCounterSignerInfo->Issuer; CertInfo.SerialNumber = pCounterSignerInfo->SerialNumber; pCertContext = CertFindCertificateInStore(hStore, ENCODING, 0, CERT_FIND_SUBJECT_CERT, (PVOID)&CertInfo, NULL); if (!pCertContext) { _tprintf(_T("CertFindCertificateInStore failed with %x\n"), GetLastError()); __leave; } // Print timestamp certificate information. _tprintf(_T("TimeStamp Certificate:\n\n")); PrintCertificateInfo(pCertContext); _tprintf(_T("\n")); // Find Date of timestamp. if (GetDateOfTimeStamp(pCounterSignerInfo, &st)) { _tprintf(_T("Date of TimeStamp : %02d/%02d/%04d %02d:%02d\n"), st.wMonth, st.wDay, st.wYear, st.wHour, st.wMinute); } _tprintf(_T("\n")); } } __finally { // Clean up. if (ProgPubInfo.lpszProgramName != NULL) LocalFree(ProgPubInfo.lpszProgramName); if (ProgPubInfo.lpszPublisherLink != NULL) LocalFree(ProgPubInfo.lpszPublisherLink); if (ProgPubInfo.lpszMoreInfoLink != NULL) LocalFree(ProgPubInfo.lpszMoreInfoLink); if (pSignerInfo != NULL) LocalFree(pSignerInfo); if (pCounterSignerInfo != NULL) LocalFree(pCounterSignerInfo); if (pCertContext != NULL) CertFreeCertificateContext(pCertContext); if (hStore != NULL) CertCloseStore(hStore, 0); if (hMsg != NULL) CryptMsgClose(hMsg); } return 0; } BOOL PrintCertificateInfo(PCCERT_CONTEXT pCertContext) { BOOL fReturn = FALSE; LPTSTR szName = NULL; DWORD dwData; __try { // Print Serial Number. _tprintf(_T("Serial Number: ")); dwData = pCertContext->pCertInfo->SerialNumber.cbData; for (DWORD n = 0; n < dwData; n++) { _tprintf(_T("%02x "), pCertContext->pCertInfo->SerialNumber.pbData[dwData - (n + 1)]); } _tprintf(_T("\n")); // Get Issuer name size. if (!(dwData = CertGetNameString(pCertContext, CERT_NAME_SIMPLE_DISPLAY_TYPE, CERT_NAME_ISSUER_FLAG, NULL, NULL, 0))) { _tprintf(_T("CertGetNameString failed.\n")); __leave; } // Allocate memory for Issuer name. szName = (LPTSTR)LocalAlloc(LPTR, dwData * sizeof(TCHAR)); if (!szName) { _tprintf(_T("Unable to allocate memory for issuer name.\n")); __leave; } // Get Issuer name. if (!(CertGetNameString(pCertContext, CERT_NAME_SIMPLE_DISPLAY_TYPE, CERT_NAME_ISSUER_FLAG, NULL, szName, dwData))) { _tprintf(_T("CertGetNameString failed.\n")); __leave; } // print Issuer name. _tprintf(_T("Issuer Name: %s\n"), szName); LocalFree(szName); szName = NULL; // Get Subject name size. if (!(dwData = CertGetNameString(pCertContext, CERT_NAME_SIMPLE_DISPLAY_TYPE, 0, NULL, NULL, 0))) { _tprintf(_T("CertGetNameString failed.\n")); __leave; } // Allocate memory for subject name. szName = (LPTSTR)LocalAlloc(LPTR, dwData * sizeof(TCHAR)); if (!szName) { _tprintf(_T("Unable to allocate memory for subject name.\n")); __leave; } // Get subject name. if (!(CertGetNameString(pCertContext, CERT_NAME_SIMPLE_DISPLAY_TYPE, 0, NULL, szName, dwData))) { _tprintf(_T("CertGetNameString failed.\n")); __leave; } // Print Subject Name. _tprintf(_T("Subject Name: %s\n"), szName); fReturn = TRUE; } __finally { if (szName != NULL) LocalFree(szName); } return fReturn; } LPWSTR AllocateAndCopyWideString(LPCWSTR inputString) { LPWSTR outputString = NULL; outputString = (LPWSTR)LocalAlloc(LPTR, (wcslen(inputString) + 1) * sizeof(WCHAR)); if (outputString != NULL) { lstrcpyW(outputString, inputString); } return outputString; } BOOL GetProgAndPublisherInfo(PCMSG_SIGNER_INFO pSignerInfo, PSPROG_PUBLISHERINFO Info) { BOOL fReturn = FALSE; PSPC_SP_OPUS_INFO OpusInfo = NULL; DWORD dwData; BOOL fResult; __try { // Loop through authenticated attributes and find // SPC_SP_OPUS_INFO_OBJID OID. for (DWORD n = 0; n < pSignerInfo->AuthAttrs.cAttr; n++) { if (lstrcmpA(SPC_SP_OPUS_INFO_OBJID, pSignerInfo->AuthAttrs.rgAttr[n].pszObjId) == 0) { // Get Size of SPC_SP_OPUS_INFO structure. fResult = CryptDecodeObject(ENCODING, SPC_SP_OPUS_INFO_OBJID, pSignerInfo->AuthAttrs.rgAttr[n].rgValue[0].pbData, pSignerInfo->AuthAttrs.rgAttr[n].rgValue[0].cbData, 0, NULL, &dwData); if (!fResult) { _tprintf(_T("CryptDecodeObject failed with %x\n"), GetLastError()); __leave; } // Allocate memory for SPC_SP_OPUS_INFO structure. OpusInfo = (PSPC_SP_OPUS_INFO)LocalAlloc(LPTR, dwData); if (!OpusInfo) { _tprintf(_T("Unable to allocate memory for Publisher Info.\n")); __leave; } // Decode and get SPC_SP_OPUS_INFO structure. fResult = CryptDecodeObject(ENCODING, SPC_SP_OPUS_INFO_OBJID, pSignerInfo->AuthAttrs.rgAttr[n].rgValue[0].pbData, pSignerInfo->AuthAttrs.rgAttr[n].rgValue[0].cbData, 0, OpusInfo, &dwData); if (!fResult) { _tprintf(_T("CryptDecodeObject failed with %x\n"), GetLastError()); __leave; } // Fill in Program Name if present. if (OpusInfo->pwszProgramName) { Info->lpszProgramName = AllocateAndCopyWideString(OpusInfo->pwszProgramName); } else Info->lpszProgramName = NULL; // Fill in Publisher Information if present. if (OpusInfo->pPublisherInfo) { switch (OpusInfo->pPublisherInfo->dwLinkChoice) { case SPC_URL_LINK_CHOICE: Info->lpszPublisherLink = AllocateAndCopyWideString(OpusInfo->pPublisherInfo->pwszUrl); break; case SPC_FILE_LINK_CHOICE: Info->lpszPublisherLink = AllocateAndCopyWideString(OpusInfo->pPublisherInfo->pwszFile); break; default: Info->lpszPublisherLink = NULL; break; } } else { Info->lpszPublisherLink = NULL; } // Fill in More Info if present. if (OpusInfo->pMoreInfo) { switch (OpusInfo->pMoreInfo->dwLinkChoice) { case SPC_URL_LINK_CHOICE: Info->lpszMoreInfoLink = AllocateAndCopyWideString(OpusInfo->pMoreInfo->pwszUrl); break; case SPC_FILE_LINK_CHOICE: Info->lpszMoreInfoLink = AllocateAndCopyWideString(OpusInfo->pMoreInfo->pwszFile); break; default: Info->lpszMoreInfoLink = NULL; break; } } else { Info->lpszMoreInfoLink = NULL; } fReturn = TRUE; break; // Break from for loop. } // lstrcmp SPC_SP_OPUS_INFO_OBJID } // for } __finally { if (OpusInfo != NULL) LocalFree(OpusInfo); } return fReturn; } BOOL GetDateOfTimeStamp(PCMSG_SIGNER_INFO pSignerInfo, SYSTEMTIME *st) { BOOL fResult; FILETIME lft, ft; DWORD dwData; BOOL fReturn = FALSE; // Loop through authenticated attributes and find // szOID_RSA_signingTime OID. for (DWORD n = 0; n < pSignerInfo->AuthAttrs.cAttr; n++) { if (lstrcmpA(szOID_RSA_signingTime, pSignerInfo->AuthAttrs.rgAttr[n].pszObjId) == 0) { // Decode and get FILETIME structure. dwData = sizeof(ft); fResult = CryptDecodeObject(ENCODING, szOID_RSA_signingTime, pSignerInfo->AuthAttrs.rgAttr[n].rgValue[0].pbData, pSignerInfo->AuthAttrs.rgAttr[n].rgValue[0].cbData, 0, (PVOID)&ft, &dwData); if (!fResult) { _tprintf(_T("CryptDecodeObject failed with %x\n"), GetLastError()); break; } // Convert to local time. FileTimeToLocalFileTime(&ft, &lft); FileTimeToSystemTime(&lft, st); fReturn = TRUE; break; // Break from for loop. } //lstrcmp szOID_RSA_signingTime } // for return fReturn; } BOOL GetTimeStampSignerInfo(PCMSG_SIGNER_INFO pSignerInfo, PCMSG_SIGNER_INFO *pCounterSignerInfo) { PCCERT_CONTEXT pCertContext = NULL; BOOL fReturn = FALSE; BOOL fResult; DWORD dwSize; __try { *pCounterSignerInfo = NULL; // Loop through unathenticated attributes for // szOID_RSA_counterSign OID. for (DWORD n = 0; n < pSignerInfo->UnauthAttrs.cAttr; n++) { if (lstrcmpA(pSignerInfo->UnauthAttrs.rgAttr[n].pszObjId, szOID_RSA_counterSign) == 0) { // Get size of CMSG_SIGNER_INFO structure. fResult = CryptDecodeObject(ENCODING, PKCS7_SIGNER_INFO, pSignerInfo->UnauthAttrs.rgAttr[n].rgValue[0].pbData, pSignerInfo->UnauthAttrs.rgAttr[n].rgValue[0].cbData, 0, NULL, &dwSize); if (!fResult) { _tprintf(_T("CryptDecodeObject failed with %x\n"), GetLastError()); __leave; } // Allocate memory for CMSG_SIGNER_INFO. *pCounterSignerInfo = (PCMSG_SIGNER_INFO)LocalAlloc(LPTR, dwSize); if (!*pCounterSignerInfo) { _tprintf(_T("Unable to allocate memory for timestamp info.\n")); __leave; } // Decode and get CMSG_SIGNER_INFO structure // for timestamp certificate. fResult = CryptDecodeObject(ENCODING, PKCS7_SIGNER_INFO, pSignerInfo->UnauthAttrs.rgAttr[n].rgValue[0].pbData, pSignerInfo->UnauthAttrs.rgAttr[n].rgValue[0].cbData, 0, (PVOID)*pCounterSignerInfo, &dwSize); if (!fResult) { _tprintf(_T("CryptDecodeObject failed with %x\n"), GetLastError()); __leave; } fReturn = TRUE; break; // Break from for loop. } } } __finally { // Clean up. if (pCertContext != NULL) CertFreeCertificateContext(pCertContext); } return fReturn; } I really have not time to do it. but I hope you got it. Saludos
    1 point
  16. https://stackoverflow.com/questions/667017/how-to-check-if-a-file-has-a-digital-signature https://security.stackexchange.com/questions/50959/how-to-check-executable-code-signing-signatures https://github.com/SummitRoute/osslsigncode-fork
    1 point
  17. A directory doesn't have its own free space. The unused or free or available space on a drive is returned by DriveSpaceFree. Total ≥ Free ! A 16Gb USB key has around 16Gb total space once formatted but has anything between that and 0 free space, depending on the size already used by files and directories. DirGetSize sums up the size of all files and directories found under a given path.
    1 point
  18. Still my favorite, via @rover
    1 point
  19. Hi, Give you some solution for tab control from me. FlatTab.au3 #include-once #include <GDIPlus.au3> #include <Array.au3> #include "GUICtrlOnHover.au3" Global $FlatUIColor = DllStructCreate("struct;float back;float fore;float frame;endstruct;") $FlatUIColor.back = 0x3C4649 $FlatUIColor.fore = 0x23A86D ;0x3498db $FlatUIColor.frame = 0x2D2F31 Global Const $tObjTabEx = "hwnd hwnd;byte ctrl;byte ctab;" & _ "byte count;byte current;int next;" & _ "int width;int x;int y;" Global Const $tObjTabBtnEx = "byte ctrl;byte ctab;byte idtab;" & _ "wchar text[255];" Global $____aTabList[1] = [0] Global $____aTabBtnList[1] = [0] Func FlatTab_Create($hWnd, $Left, $Top, $Width, $Height) GUISwitch($hWnd) Local $oObj = DllStructCreate($tObjTabEx) _ArrayAdd($____aTabList, $oObj) $____aTabList[0] += 1 $oObj.hwnd = $hWnd $oObj.ctrl = GUICtrlCreatePic("", $Left, $Top+25, $Width, $Height-50) GUICtrlSetResizing($oObj.ctrl, 802) GUICtrlSetState($oObj.ctrl, 128) $oObj.ctab = GUICtrlCreateTab(-99, -99, 1, 1) GUICtrlSetState($oObj.ctab, 128) Local $aBmp = _GDIPlus_BitmapCreateFromScan0($Width, $Height-50) Local $hGfx = _GDIPlus_ImageGetGraphicsContext($aBmp) Local $hPen = _GDIPlus_PenCreate($FlatUIColor.frame+0xFF000000, 4) Local $hBrush = _GDIPlus_BrushCreateSolid($FlatUIColor.frame+0xFF000000) _GDIPlus_GraphicsDrawRect($hGfx, 0, 0, $Width, $Height-50, $hPen) _GDIPlus_GraphicsFillRect($hGfx, 0, 0, $Width, $Height-50, $hBrush) _GDIPlus_GraphicsClear($hGfx, $FlatUIColor.frame+0xFF000000) Local $hBmp = _GDIPlus_BitmapCreateDIBFromBitmap($aBmp) _GDIPlus_BitmapDispose($aBmp) _GDIPlus_GraphicsDispose($hGfx) _GDIPlus_PenDispose($hPen) _WinAPI_DeleteObject(GUICtrlSendMsg($oObj.ctrl, 0x0172, 0, $hBmp)) _WinAPI_DeleteObject($hBmp) $oObj.width = $Width $oObj.x = $Left $oObj.y = $Top $oObj.current = "" $oObj.count = 0 $oObj.next = $Left Return $oObj EndFunc Func FlatTab_AddTab($Ctrl, $Text) GUISwitch($Ctrl.hwnd) GUICtrlCreateTabItem("") Local $oObj = DllStructCreate($tObjTabBtnEx) _ArrayAdd($____aTabBtnList, $oObj) $____aTabBtnList[0] += 1 $oObj.ctrl = GUICtrlCreatePic("", $Ctrl.next, $Ctrl.y, 80, 25) GUICtrlSetResizing($oObj.ctrl, 802) _GUICtrl_OnHoverRegister($oObj.ctrl, 'FlatTab_EventHover', 'FlatTab_EventHover', 'FlatTab_EventClick', 'FlatTab_EventClick') $oObj.count +=1 $oObj.idtab = GUICtrlCreateTabItem($oObj.count) $oObj.text = $Text If $Ctrl.current <> "" Then Local $Prev = FlatTab_GetObjTabBtnFromCtrl($Ctrl.current) FlatTab_Draw($Prev.ctrl, $Prev.text, 0xFFFFFFFF, $FlatUIColor.fore+0xFF000000) EndIf FlatTab_Draw($oObj.ctrl, $Text, 0xFFFFFFFF, $FlatUIColor.frame+0xFF000000) $Ctrl.current = $oObj.ctrl $oObj.ctab = $Ctrl.ctab $Ctrl.next += 80 GUICtrlSetState($oObj.idtab, 16) Return $oObj.idtab EndFunc Func FlatTab_EventHover($Ctrl, $Mode) Local $Obj1 = FlatTab_GetObjTabFromCtrl($Ctrl) If $Obj1.current = $Ctrl Then Return Local $Obj2 = FlatTab_GetObjTabBtnFromCtrl($Ctrl) Switch $Mode Case 1 FlatTab_Draw($Ctrl, $Obj2.text, 0xFFFFFFFF, $FlatUIColor.fore+0xFF151515) Case 2 FlatTab_Draw($Ctrl, $Obj2.text, 0xFFFFFFFF, $FlatUIColor.fore+0xFF000000) EndSwitch EndFunc Func FlatTab_EventClick($Ctrl, $Mode) If $Mode = 2 Then Local $Obj1 = FlatTab_GetObjTabFromCtrl($Ctrl) If $Obj1.current = $Ctrl Then Return Local $Obj2 = FlatTab_GetObjTabBtnFromCtrl($Ctrl) Local $Obj3 = FlatTab_GetObjTabBtnFromCtrl($Obj1.current) FlatTab_Draw($Ctrl, $Obj2.text, 0xFFFFFFFF, $FlatUIColor.frame+0xFF000000) FlatTab_Draw($Obj3.ctrl, $Obj3.text, 0xFFFFFFFF, $FlatUIColor.fore+0xFF000000) GUICtrlSetState($Obj2.idtab, 16) $Obj1.current = $Ctrl EndIf EndFunc Func FlatTab_GetObjTabFromCtrl($Ctrl) Local $Obj2, $Index Local $Obj = FlatTab_GetObjTabBtnFromCtrl($Ctrl) If $____aTabList[0] = 0 Then Return False For $Index = $____aTabList[0] To 1 Step -1 $Obj2 = $____aTabList[$Index] If $Obj2.ctab == $Obj.ctab Then Return $____aTabList[$Index] Next Return False EndFunc Func FlatTab_GetObjTabBtnFromCtrl($Ctrl) Local $Obj, $Index If $____aTabBtnList[0] = 0 Then Return False For $Index = $____aTabBtnList[0] To 1 Step -1 $Obj = $____aTabBtnList[$Index] If $Obj.ctrl == $Ctrl Then Return $____aTabBtnList[$Index] Next Return False EndFunc Func FlatTab_Draw($iCtrl, $Text, $Color = 0xFFFFFFFF, $BgColor = 0x00FFFFFF) Local $hWnd = _WinAPI_GetParent(GUICtrlGetHandle($iCtrl)) Local $aPos = ControlGetPos($hWnd, "", $iCtrl) Local $hFormat = _GDIPlus_StringFormatCreate() Local $hFamily = _GDIPlus_FontFamilyCreate("Segoe UI Semibold") Local $hFont = _GDIPlus_FontCreate($hFamily, 10, 0) Local $tLayout = _GDIPlus_RectFCreate(0, 0, $aPos[2], $aPos[3]) _GDIPlus_StringFormatSetAlign($hFormat, 1) _GDIPlus_StringFormatSetLineAlign($hFormat, 1) Local $aBitmaps = _GDIPlus_BitmapCreateFromScan0($aPos[2], $aPos[3]) Local $aGfxCtxt = _GDIPlus_ImageGetGraphicsContext($aBitmaps) _GDIPlus_GraphicsSetSmoothingMode($aGfxCtxt, 2) _GDIPlus_GraphicsSetTextRenderingHint($aGfxCtxt, 5) _GDIPlus_GraphicsClear($aGfxCtxt, $BgColor) Local $hBrushColor = _GDIPlus_BrushCreateSolid($Color) _GDIPlus_GraphicsDrawStringEx($aGfxCtxt, $Text, $hFont, $tLayout, $hFormat, $hBrushColor) Local $aHBitmaps = _GDIPlus_BitmapCreateDIBFromBitmap($aBitmaps) _GDIPlus_BrushDispose($hBrushColor) _GDIPlus_FontDispose($hFont) _GDIPlus_BitmapDispose($aBitmaps) _GDIPlus_GraphicsDispose($aGfxCtxt) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _WinAPI_DeleteObject(GUICtrlSendMsg($iCtrl, 0x0172, 0, $aHBitmaps)) _WinAPI_DeleteObject($aHBitmaps) EndFunc FlatTab_Example.au3 #include "FlatTabEx.au3" #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> _GDIPlus_Startup(); Global $hGUI = GUICreate("FlatTab Example", 450, 290); GUISetBkColor(0x3C4649, $hGUI); GUISetFont(10, 400, 0, "Segoe UI", $hGUI, 5); Global $Tab = FlatTab_Create($hGUI, 10, 10, 430, 290); ;================================================= FlatTab_AddTab($Tab, "Tab 1"); GUICtrlCreateLabel("This is Tab 1", 30, 50); GUICtrlSetColor(-1, 0xFFFFFF); GUICtrlCreateButton("Button 1", 30, 100, 75, 25); GUICtrlCreateButton("Button 2", 120, 100, 75, 25); ;================================================= FlatTab_AddTab($Tab, "Tab 2"); GUICtrlCreateLabel("This is Tab 2", 30, 50); GUICtrlSetColor(-1, 0xFFFFFF); GUICtrlCreateButton("Button 3", 210, 100, 75, 25); GUICtrlCreateButton("Button 4", 30, 150, 75, 25); ;================================================= FlatTab_AddTab($Tab, "Tab 3"); GUICtrlCreateLabel("This is Tab 3", 30, 50); GUICtrlSetColor(-1, 0xFFFFFF); GUICtrlCreateButton("Button 5", 120, 150, 75, 25); GUICtrlCreateButton("Button 6", 210, 150, 75, 25); ;================================================= GUICtrlCreateTabItem(""); GUISetState(); Do Sleep(10); Until GUIGetMsg() = -3;
    1 point
  20. Another way: Func _FirstFriday($iYear, $iMonth) Local $iDOW = _DateToDayOfWeek($iYear, $iMonth, 1) - 1 Return _DateAdd("D", ($iDOW = 6 ? 6 : 5 - $iDOW), StringFormat("%04i/%02i/01", $iYear, $iMonth)) EndFunc For $y = 2010 To 2020 For $m = 1 To 12 ConsoleWrite(_FirstFriday($y, $m) & @LF) Next Next
    1 point
  21. Here is an example that finds the first specified day (Friday) of each month. #include <Date.au3> Local $iDayNumOfWeek = 6 ; The day number of the start of the week. (6 - Friday) For $j = 1 To 12 ConsoleWrite("1st " & _DateDayOfWeek($iDayNumOfWeek, 1) & ": " & @YEAR & "/" & $j & "/" & _DateFirstDayOfMonth($iDayNumOfWeek, @YEAR, $j) & @CRLF) Next Func _DateFirstDayOfMonth($FstFriMon = 6, $Year = @YEAR, $iMonth = @MON) For $i = 1 To _DateDaysInMonth($Year, $iMonth) If _DateToDayOfWeek($Year, $iMonth, $i) = $FstFriMon Then ExitLoop Next Return $i EndFunc ;==>_DateFirstDayOfMonth
    1 point
×
×
  • Create New...