Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 03/10/2019 in all areas

  1. I create purebasic language functions similar to autolt I let the members of the furom improve the concept with a beginning of idea I included some functions it works very well for the moment I let you modify and give your ideas thank add in your purebasic source code (IncludeFile "AutoitCoding.PB") and program as on autolt it remains full of function to program the concept is to improve the languages remain similar AutoIt Code : 415 kb with UPX Interpreted Language $Time=TimerInit() MsgBox (16,"Autoit",StringIsDigit ("123a")) MsgBox (16,"Autoit",StringIsDigit ("123")) $VarBin=StringToBinary("Hello") MsgBox (64,"Autoit",@Hour) MsgBox (64,"Autoit",@TempDir) MsgBox (64,"Autoit",$VarBin) MsgBox (64,"Autoit",BinaryToString($VarBin)) MsgBox (0,"Autoit",StringLen ("bonjour")) MsgBox (1,"Autoit",@DesktopCommonDir) MsgBox (2,"Autoit",@ProgramFilesDir) Sleep (1000) MsgBox (3,"Autoit",FileGetSize("test.pb")) MsgBox (4,"Autoit",Random (1,10,1)) $Variable=FileGetSize("test.pb") MsgBox (0,"Autoit",$Variable) ;InetGet ("https://jardinage.lemonde.fr/images/dossiers/2018-07/language-chat-170054.jpg","image.jpg") MsgBox (0,"Autoit",StringReplace ("Hella","a","o")) MsgBox (0,"Autoit",StringTrimLeft ("Hello",1)) MsgBox (0,"Autoit",StringTrimRight("Hello",1)) If FileExists ("test.pb") Then MsgBox(0,"Title","the file exist") Else MsgBox(0,"Title","the file does not exist") EndIf MsgBox(0,"Autoit",FileGetTime ("UPX.exe",1,1)) MsgBox(0,"Autoit",FileGetTime ("UPX.exe",1,1)) MsgBox(0,"Autoit",FileGetVersion("UPX.exe")) MsgBox(0,"Autoit",TimerDiff($Time)) If IsAdmin() Then MsgBox(0,"Autoit", "IsAdmin You are administrator !.") Else MsgBox(0,"Autoit", "IsAdmin You are not administrator !.") EndIf MsgBox(0,"Autoit",String (10)) MsgBox(0,"Autoit",Ping ("google.fr")) ;################## StringSplit $Split = StringSplit("ABC*DEFG*JKL","*") MsgBox(0,"Autoit",$Split[1]) MsgBox(0,"Autoit",$Split[2]) MsgBox(0,"Autoit",$Split[3]) ;################## StringSplit IniWrite("setup3.ini", "General", "Title", "AutoIt") $inivar= IniRead("setup3.ini", "General", "Title",Default) MsgBox (0,"Autoit",$inivar) PureBasic Code : Executable Size : 12 kb with UPX Real Compiler ( Your source code is secure ) IncludeFile "AutoitCoding.PB" ;MsgBox (16,"Autoit",StringIsDigit ("123a")) ;StringIs.PB be sure to activate it in AutoitCoding.PB this increases the size of the executable ;MsgBox (16,"Autoit",StringIsDigit ("123")) ;StringIs.PB be sure to activate it in AutoitCoding.PB this increases the size of the executable ;InetGet ("https://jardinage.lemonde.fr/images/dossiers/2018-07/language-chat-170054.jpg","image.jpg") ; InetFonctions be sure to activate it in AutoitCoding.PB this increases the size of the executable ;##################Mouse Dim xy (1) MouseGetPos (xy()) Debug "Pos : X : "+xy(0)+" Y : "+xy(1) Debug WinGetHandle ("Notepad") ;################## ProcessList Dim ProcessName.s(1) ; Create array Dim PID.s(1) ; Create array ProcessList (ProcessName (),PID ()) MsgBox(0,"Autoit","ProcessName: "+ProcessName(10)+" YourPID: "+PID (10)) ;################## ProcessList For i = 0 To ArraySize (ProcessName ()) Debug ProcessName (i)+" PID : "+ PID (i) Next MsgBox (0,"Autoit",ProcessorArch ()) Time$=TimerInit() VarBin$=StringToBinary("Hello") MsgBox (0,"Autoit",ComSpec ()) MsgBox (64,"Autoit",GetCPUName ()) MsgBox (64,"Autoit",CpuSerialNumber ()) MsgBox (64,"Autoit",AutoItVersion ()) MsgBox (64,"Autoit","Hello"+CRLF ()+"Hello") MsgBox (64,"Autoit",Hours ()) MsgBox (64,"Autoit",TempDir ()) MsgBox (64,"Autoit",VarBin$) MsgBox (64,"Autoit",BinaryToString(VarBin$)) MsgBox (48,"Autoit",StringLenS ("bonjour")) MsgBox (1,"Autoit",DesktopCommonDir ()) MsgBox (2,"Autoit",ProgramFilesDir ()) Sleep (1000) MsgBox (3,"Autoit",FileGetSize("test.pb")) MsgBox (4,"Autoit",Randoms (1,10)) Variable$=FileGetSize("test.pb") MsgBox (0,"Autoit",Variable$) MsgBox (0,"Autoit",StringReplace ("Hella","a","o")) MsgBox (0,"Autoit",StringTrimLeft ("Hello",1)) MsgBox (0,"Autoit",StringTrimRight("Hello",1)) If FileExists ("test.pb") MsgBox(0,"Autoit","the file exist") Else MsgBox(0,"Autoit","the file does not exist") EndIf MsgBox(0,"Autoit",FileGetTime ("UPX.exe",1,"%mm/%dd/%yyyy %hh:%ii:%ss")) MsgBox(0,"Autoit",FileGetTime ("UPX.exe",1,"%hh:%ii:%ss")) MsgBox(0,"Autoit",FileGetVersion("UPX.exe",#FV_FileVersion)) MsgBox(0,"Autoit",TimerDiff(Time$)) If IsAdmin() MsgBox(0,"Autoit", "IsAdmin You are administrator !.") Else MsgBox(0,"Autoit", "IsAdmin You are not administrator !.") EndIf MsgBox(0,"Autoit",String(10)) MsgBox(0,"Autoit",Ping ("google.fr")) iLife = 42 If IsNumber(iLife) MsgBox(0, "", "Is Number") Else MsgBox(0, "", "Is not Number") EndIf ;################## StringSplit Dim Split.s(1) ; Create array StringSplit (split(), "ABC*DEFG*JKL", "*") MsgBox(0,"Autoit",Split(0)) MsgBox(0,"Autoit",Split(1)) MsgBox(0,"Autoit",Split(2)) ;################## StringSplit IniWrite("setup3.ini", "General", "Title", "AutoIt") inivar$= IniRead("setup3.ini", "General", "Title") MsgBox (0,"Autoit",inivar$) ;Bonus Function MsgBox(0,"Autoit",HostNameToIp ("google.fr")) there is a slight difference but nothing important I am counting on you to improve the project and add functions ! ( Disadvantage purebasic is paying you can not have all ) Functions compatible : Msgbox Sleep FileGetSize ClipPut ClipGet Randoms DirCopy DirCreate DirRemove StringReplace StringLen Add Fonctions : (11/03/2019) StringTrimLeft StringTrimRight FileCopy FileMove StringUpper StringLower Add Fonctions : (12/03/2019) StringIsFloat StringIsAlpha StringIsDigit StringReverse BinaryToString StringToBinary FileExists Msgbox ADD : MB_ICONERROR = 16 MB_ICONQUESTION = 32 MB_ICONWARNING = 48 MB_ICONINFORMATION=64 You can control the size of the executable Division of executable size by 10 ( 119 kb to 12 kb) ( I separated the functions in several file activated if necessary ) ;IncludeFile "FonctionsIncludes\StringIs.PB" I separated the functions into several activated files If necessary remove ;IncludeFile "FonctionsIncludes\InetFonctions.PB" ; I separated the functions into several activated files If necessary remove Add Functions: (20/03/2019) String IsAdmin TimerDiff (thank @JiBe) TimerInit (thank @JiBe) Ping FileGetVersion add : #FV_FileVersion #FV_FileDescription #FV_LegalCopyright #FV_InternalName #FV_OriginalFilename #FV_ProductName #FV_ProductVersion #FV_CompanyName #FV_LegalTrademarks #FV_SpecialBuild #FV_PrivateBuild #FV_Comments #FV_Language FileGetTime Flag : 0 Last modified (default) 1 Created 2 Last accessed Msgbox ADD : MB_DEFBUTTON2 = 256 Flag MB_DEFBUTTON3 = 512 Flag MB_DEFBUTTON4 = 768 Flag MB_SYSTEMMODAL = 4096 Flag MB_TASKMODAL = 8192 Flag MB_DEFAULT_DESKTOP_ONLY = 131072 Flag MB_RIGHT = 524288 Flag MB_RTLREADING = 1048576 Flag MB_SETFOREGROUND = 65536 Flag MB_TOPMOST = 262144 Flag MB_SERVICE_NOTIFICATION = 2097152 Flag Bonus Functions : HostNameToIp Add Functions: (22/03/2019) ----------------------- ADD Macros : (thank @AZJIO) DesktopCommonDir () MyDocumentsDir () ProgramFilesDir () ScriptFullPath () ScriptName () ScriptDir () ----------------------- OSVersions () Add Functions: (26/03/2019) ----------------------- ADD Macros : TempDir () Hours () Min () Sec () MDAY () MON () Years () LF () CR () CRLF () ----------------------- Functions: Floor Ceiling Stringlen ( Update :Return Number) StringlenS (Temporary function asks for reflection) Add Functions: 06/04/2019 Macro : AutoItVersion () ; it's for fun haha SystemDir () UserProfileDir () AppDataDir () ComSpec () ; Bug fixed UserName () LogonServer () HomeShare () HomeDrive () HomePath () HomeDrive () LocalAppDataDir () UserProfilDir () Bonus Macro : ProcessorsThreadNumber () Functions : Change of procedure in macro (optimization) Optimization of msgbox Fix a constant messagebox Beep StringSplit ( thank @AZJIO ) FileGetAttrib Bonus features : CpuSerialNumber() GetCPUName() Add Functions: 16/04/2019 Optimization UserName () Optimization CpuName () change of the name of the function GetCpuName () ProcessList () : Return PID Return ProcessName ProcessClose (); PID or ProcessName IniWrite () IniRead () Macro : ProcessorArch () DesktopHeights () DesktopWidths () DesktopRefresh () DesktopDepths () AutoItX64 () Add Functions: 19/04/2019 Functions: ( THANK @AZJIO ) IniDelete () DriveGetType() DriveGetLabel() DriveGetSerial() DriveSpaceFree() DriveSpaceTotal() DriveGetFileSystem() Add Functions: 30/04/2019 Minor bug fixes : DriveGetLabel() fixed function thank AZJIO DriveGetFileSystem() fixed function thank AZJIO ADD Functions : BlockInput () thank AZJIO FileGetShortName() FileGetLongName() MouseGetPos () WinGetHandle () Sqrt () Add Functions: 23/05/2019 ProcessExists () ClosePID () IniReadSectionNames() WinWait ();2 in 1 finds the same handle with a title or a partial text WinExists ();2 in 1 finds the same handle with a title or a partial text WinWaitClose ();2 in 1 finds the same handle with a title or a partial text WinWaitActive ();2 in 1 finds the same handle with a title or a partial text WinGetProcess ();2 in 1 finds the same handle with a title or a partial text HandleToHex ();x86 management Imitate autoit HexToHandle () ADD Macro : ScriptDir () Complete rewrite of functions with optimization : ProcessList () ProcessClose () WinGetHandle () Delete function : CountProcess () FileGetSize () ;Old function All the old function are put in the OldFonctions.pb file Add Fonctions : (18/07/2019) WinMinimizeAll() Winkill ();title or a partial text SearchHandle ();Bonus function to simplify your life look for the handle of a window with a title or a text patiel WinSetStade ();title or a partial text or Handle #SW_HIDE = 0 #SW_SHOW = 5 #SW_MINIMIZE = 6 #SW_MAXIMIZE = 3 #SW_RESTORE = 9 #SW_DISABLE = 4 #SW_ENABLE = 1 WinActive () Title or Handle WinList (); With the zero flag you can see the invisible windows and the flag 1 for visible windows more simplify than the original Default option : VisibleWindow = 1 WinSetTitle () Title or Handle Update : WinExists () Handle Management WinGetProcess () Handle Management Add Fonctions : (09/04/2020) IsHWnd (Return 0 or 1) PixelGetColor (x,y) WinSetTrans ;title or a partial text 0 To 255 Optimization of the msgbox function smaller and faster code (old msgbox function put in oldfunction.pb) Msgbox Fix minors bug MouseMoveSpeed Function under construction MouseClick Function under construction HibernateAllowed() Suspend() ShutdownPrivilege() Shutdown (Flag) #SD_LOGOFF=0 #SD_SHUTDOWN=1 #SD_REBOOT=2 #SD_FORCE=4 #SD_POWERDOWN=8 #SD_FORCEHUNG=16 #SD_STANDBY=32 #SD_HIBERNATE=64 ProcessSetPriority (Process.s, priority) #PROCESS_LOW =0 #PROCESS_BELOWNORMAL =1 #PROCESS_NORMAL =2 #PROCESS_ABOVENORMAL =3 #PROCESS_HIGH =4 #PROCESS_REALTIME =5 EnvSet () EnvGet () FileRecycleEmpty() add file in GuiExampleAutoitCoding (Hybrid Code) example method for window GuiExampleAutoitCoding (Hybrid Code) update files start of code to convert autoit to pb in construction Add Fonctions : (01/12/2022) #PB_OS_Windows_11 code upgrade OSVersion() WinActivate(hWnd) adding a new function thank @AZJIO #MB_SERVICE_NOTIFICATION1 I changed the name not compatible with purebasic 6 I added a 1 (msgbox) DriveGetLabel bugfix for version 6 of purebasic DriveGetFileSystem bugfix for version 6 of purebasic ProcessorArch () optimization of the function and addition of flag for Purebasic 6 ARM64 ARM ProcessorArch () the old function is moved to the file Old Functions.pb ProcessorArch () bug fixed stack has been corrupted ProcessorArch () add to file Example.pb InitNetwork remove Deprecated function HostNameToIp optimization of the function and addition of flag 0 HostNameToIp the old function is moved to the file Old Functions.pb Ping () optimization of the function and addition of flag and timeout Ping () fix minor bug flag 0 return ping flag 1 return PingStatus also returns errors 1 = Host disconnected 2 = Host unreachable 3 = Wrong destination 4 = Other errors flag 2 return DataSize timeout = 4000 like the original the setting support written web address and ip address (www.google.com or 127.0.0.1) Ping () the old function is moved to the file Old Functions.pb remove ExampleGui I moved the files in the same folder it is more manageable Add Fonctions : (05/09/2024) New Functions Added: DllOpen Implemented a new function DllCall Implemented a new function DllClose Implemented a new function iniWrite: Implemented a new function for writing to INI files. iniRead: Introduced a revised version of the basic function for reading INI files. CpuIdentifier() Combine some values to create a pseudo-unique identifier Function Rewrite: iniDelete: Updated the iniDelete function to enhance management of sections and keys. Ping improve performance Compatibility improved PureBasic 6.11 LTS Legacy Code Management: Moved obsolete functions to Oldfunctions.pb to streamline current codebase. Moved Macro Username to Oldfunctions.pb Moved Macro Blockinput to Oldfunctions.pb Bug fix : (05/09/2024) Bug fix : corrected IniRead procedure to return string instead of numeric value UPX official website to compress the executable : https://upx.github.io/ PureAutoitInclude.7z
    1 point
  2. ProgAndy

    FreeImage Library

    I am proud to announce an UDF collection for FreeImage. The Library contains all functions of the 3.15.0.0-release (the documentaition is located here (PDF) ) If you need more informatin about the functions, you have to read the PDF since i did not include comments in the AU3-file. If you want to download it, click here: [uDF] FreeImage library Downloads: And now an example for resizing an image (it saves the resized image in a new file, e.g. image.png will be saved as image_rsz.png) #include <FreeImage.au3> _FreeImage_LoadDLL(@ScriptDir&"\FreeImage.dll") _FreeImage_Initialise() $sFile = "800x600.jpg" ; new sizes $width = 400 $height = 300 $FIF = _FreeImage_GetFileTypeU($sFile) If $FIF = $FIF_UNKNOWN Then $FIF = _FreeImage_GetFIFFromFilenameU($sFile) EndIf $hImage = _FreeImage_LoadU($FIF, $sFile) $hImageResized = _FreeImage_Rescale($hImage, $width, $height, $FILTER_LANCZOS3) $dot = StringInStr($sFile,".",1,-1) $Name = StringLeft($sFile,$dot-1) $Ext = StringMid($sFile,$dot) _FreeImage_SaveU($FIF, $hImageResized, $Name &"_rsz"&$Ext) _FreeImage_Unload($hImage) _FreeImage_Unload($hImageResized) _FreeImage_DeInitialise()</div>And an other example for Flip and Rotate: #include <FreeImage.au3> Global $ImageHandle=-1, $WorkingFileName, $FIF _FreeImage_LoadDLL(@ScriptDir&"\FreeImage.dll") _FreeImage_Initialise() Func OnAutoItExit() If $ImageHandle <>-1 Then _FreeImage_Unload($ImageHandle) _FreeImage_DeInitialise() EndFunc GUICreate("FreeImage Test GUI",800,700) $ShowPic = GUICtrlCreatePic("",0,0, 800,600) $btnOpen = GUICtrlCreateButton("Choose File", 10, 610, 100, 30) GUICtrlSetTip(-1,"Only a copy of the image will be used") $btnFlipH = GUICtrlCreateButton("Flip Horizontal", 120, 610, 100, 30) $btnFlipV = GUICtrlCreateButton("Flip Vertical", 230, 610, 100, 30) $btnRotate = GUICtrlCreateButton("Rotate ...", 340, 610, 100, 30) GUISetState() While 1 Switch GUIGetMsg() Case -3 Exit Case $btnOpen _OpenImage() Case $btnFlipH If $ImageHandle <> -1 Then _FreeImage_FlipHorizontal($ImageHandle) _FreeImage_SaveU($FIF, $ImageHandle, $WorkingFileName) _ShowImage() EndIf Case $btnFlipV If $ImageHandle <> -1 Then _FreeImage_FlipVertical($ImageHandle) _FreeImage_SaveU($FIF, $ImageHandle, $WorkingFileName) _ShowImage() EndIf Case $btnRotate If $ImageHandle <> -1 Then $hImageNew = _FreeImage_RotateClassic($ImageHandle, Number(InputBox("Rotate", "angle for rotation", 90))) _FreeImage_SaveU($FIF, $hImageNew, $WorkingFileName) _FreeImage_Unload($ImageHandle) $ImageHandle = $hImageNew _ShowImage() EndIf EndSwitch WEnd Func _OpenImage() Local $sFile = FileOpenDialog("Choose Image","", "Image Files (*.jpg;*.jpeg;*.bmp;*.gif)", 3) If @error Then Return If $ImageHandle <> -1 Then _FreeImage_Unload($ImageHandle) Local $dot = StringInStr($sFile,".",1,-1) Local $Name = StringLeft($sFile,$dot-1) Local $Ext = StringMid($sFile,$dot) $WorkingFileName = $Name &"_FI4AU3"&$Ext FileCopy($sFile,$WorkingFileName) $FIF = _FreeImage_GetFileTypeU($WorkingFileName) If $FIF = $FIF_UNKNOWN Then $FIF = _FreeImage_GetFIFFromFilenameU($WorkingFileName) EndIf $ImageHandle = _FreeImage_LoadU($FIF, $sFile) _ShowImage() EndFunc Func _ShowImage() Local $Width, $Height _SizeProportional($Width, $Height, 800, 600, _FreeImage_GetWidth($ImageHandle), _FreeImage_GetHeight($ImageHandle)) GUICtrlSetPos($ShowPic,0,0,$Width, $Height) GUICtrlSetImage($ShowPic, $WorkingFileName) EndFunc Func _SizeProportional(ByRef $Width, ByRef $Height, $WDesired, $HDesired, $WSrc, $HSrc) ; Prog@ndy Local $RatioDes = ($WDesired / $HDesired) Local $CurrentRatio = ($WSrc / $HSrc) If $CurrentRatio > $RatioDes Then ; scale height $Width = $WDesired $Height = $WDesired / $CurrentRatio Else ; scale width $Width = $HDesired * $CurrentRatio $Height = $HDesired EndIf EndFunc ;==>_SizeProportional
    1 point
  3. Actually you can just keep the file handle open and use readfile on it @extended will contain the characters read like so.. ;Pseudo code Global $g_sFile = "C:\Logfile.txt" Global $g_hFile = FileOpen($g_sFile) ;Read Permissions Global $g_iRetries = 60 ;Exits after 60 seconds with no new data If $g_hFile < 0 Then MsgBox(0, "Error", "Can't open " & $g_sFile) Exit EndIf Global $g_sRead = "" While $g_iRetries > 0 $g_sRead &= FileRead($g_hFile, -1) ;@extended is set to the number of bytes/characters returned If @extended = 0 Then $g_iRetries -= 1 sleep(1000) Else ;There is new data!! ConsoleWrite($g_sRead & @CRLF) $g_sRead = "" $g_iRetries = 60 ; reset wait count Endif WEnd FileClose($g_hFile)
    1 point
  4. @Colduction Sure, but that's not an excuse. If you keep asking for code without putting any effort trying to do and, most important, to understand what you are trying to do, then you'll never understand what you are doing, and you'll always need someone who spoon the code for you (even if it's not a good thing to do here). Do something, and if you need help, then post your code here.
    1 point
  5. I really don't like spoonfeeding. Roll your own and show us the result 😉
    1 point
  6. Use FileGetSize() in a loop with sleep(1000) to get filesize. If it changes, open the file for read, position to EOF - deltasize with filesetpos() Fileread() and display in messagebox
    1 point
  7. Look at _WinAPI_GetProcessCommandLine () in help file. The example works perfect. You will be able to adjust for what you need.
    1 point
  8. 1 point
  9. Try this : Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) Local $tNMHDR, $hdlWindowFrom, $intMessageCode $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hdlWindowFrom = DllStructGetData($tNMHDR, "hWndFrom") $intMessageCode = DllStructGetData($tNMHDR, "Code") If $hdlWindowFrom = $hdlListView and $intMessageCode = $NM_RCLICK Then Local $aSel = _GUICtrlListView_GetSelectedIndices ($hdlListView, True) If $aSel[0] = 0 Then ToggleMenu (False,False,True,False,False) Else Local $sStatus = ReadStatus ($hdlListView,$aSel) If $sStatus = "ON" Then ToggleMenu (True,$aSel[0] > 1 ? False : True,True,False,True) ElseIf $sStatus = "OFF" Then ToggleMenu (True,$aSel[0] > 1 ? False : True,True,True,False) Else ToggleMenu (True,$aSel[0] > 1 ? False : True,True,True,True) EndIf EndIf EndIf Return $GUI_RUNDEFMSG EndFunc Func ToggleMenu ($bDel, $bEdit, $bAdd, $bON, $bOFF) If $bDel Then GUICtrlSetState($mDel, $GUI_ENABLE) If not $bDel Then GUICtrlSetState($mDel, $GUI_DISABLE) If $bEdit Then GUICtrlSetState($mEdit, $GUI_ENABLE) If not $bEdit Then GUICtrlSetState($mEdit, $GUI_DISABLE) If $bAdd Then GUICtrlSetState($mAdd, $GUI_ENABLE) If not $bAdd Then GUICtrlSetState($mAdd, $GUI_DISABLE) If $bON Then GUICtrlSetState($mON, $GUI_ENABLE) If not $bON Then GUICtrlSetState($mON, $GUI_DISABLE) If $bOFF Then GUICtrlSetState($mOFF, $GUI_ENABLE) If not $bOFF Then GUICtrlSetState($mOFF, $GUI_DISABLE) EndFunc Func ReadStatus ($hdlListView,$aSel) Local $sText = "", $sTmp For $i = 1 to $aSel[0] $sTmp = _GUICtrlListView_GetItemText ($hdlListView,$aSel[$i],2) If $sText <> $sTmp Then $sText &= $sTmp Next Return $sText EndFunc
    1 point
  10. I've tested the header color example as 64 bit code on both Windows 7 and Windows 10. In both cases, it fails. There are no colors in the header. Then I've made a much smaller example that only contains header colors: #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #AutoIt3Wrapper_UseX64=y Opt( "MustDeclareVars", 1 ) #include <GUIConstants.au3> #include <GuiListView.au3> Global $hHeader, $aHdrTexts[8] Example() Func Example() ; Create GUI GUICreate( "ListView Header Colors - GUIRegisterMsg", 840, 420 ) ; Create ListView Local $idListView = GUICtrlCreateListView( "", 10, 10, 820, 400 ) _GUICtrlListView_SetExtendedListViewStyle ( $idListView, $LVS_EX_FULLROWSELECT ) ; Add columns to ListView For $i = 0 To 7 _GUICtrlListView_AddColumn( $idListView, "Column " & $i, 99 ) $aHdrTexts[$i] = "Column " & $i Next ; Fill ListView For $i = 0 To 99 GUICtrlCreateListViewItem( $i & "/0|" & $i & "/1|" & $i & "/2|" & $i & "/3|" & _ $i & "/4|" & $i & "/5|" & $i & "/6|" & $i & "/7|", $idListView ) Next ; Header control $hHeader = _GUICtrlListView_GetHeader( $idListView ) ; Register WM_NOTIFY message handler GUIRegisterMsg( 0x004E, "WM_NOTIFY" ) ; 0x004E = $WM_NOTIFY ; Show GUI GUISetState( @SW_SHOW ) ; Message loop While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd ; Cleanup GUIDelete() EndFunc ; WM_NOTIFY message handler Func WM_NOTIFY( $hWnd, $iMsg, $wParam, $lParam ) Local Static $hHdrBrush = _WinAPI_CreateSolidBrush( 0xCCFFFF ) ; Yellow, BGR Local $tNMHDR = DllStructCreate( $tagNMHDR, $lParam ), $hWndFrom = HWnd( DllStructGetData( $tNMHDR, "hWndFrom" ) ), $iCode = DllStructGetData( $tNMHDR, "Code" ) Switch $hWndFrom Case $hHeader Switch $iCode Case $NM_CUSTOMDRAW Local $tNMCustomDraw = DllStructCreate( $tagNMLVCUSTOMDRAW, $lParam ) Local $dwDrawStage = DllStructGetData( $tNMCustomDraw, "dwDrawStage" ) Switch $dwDrawStage ; Holds a value that specifies the drawing stage Case $CDDS_PREPAINT ; Before the paint cycle begins ConsoleWrite( "CDDS_PREPAINT" & @CRLF ) Return $CDRF_NOTIFYITEMDRAW ; Notify parent window of any item related drawing operations Case $CDDS_ITEMPREPAINT ; Before an item is drawn: Default painting (frames and background) ConsoleWrite( "CDDS_ITEMPREPAINT" & @CRLF ) Return $CDRF_NOTIFYPOSTPAINT ; Notify parent window of any post item related drawing operations Case $CDDS_ITEMPOSTPAINT ; After an item is drawn: Custom painting (item texts) ConsoleWrite( "CDDS_ITEMPOSTPAINT" & @CRLF ) Local $iIndex = DllStructGetData( $tNMCustomDraw, "dwItemSpec" ) ; Item index Local $hDC = DllStructGetData( $tNMCustomDraw, "hdc" ) ; Device context _WinAPI_SetBkMode( $hDC, $TRANSPARENT ) ; Transparent background Local $tRECT = DllStructCreate( $tagRECT ) DllStructSetData( $tRECT, 1, DllStructGetData( $tNMCustomDraw, 6 ) + 1 ) DllStructSetData( $tRECT, 2, DllStructGetData( $tNMCustomDraw, 7 ) + 1 ) DllStructSetData( $tRECT, 3, DllStructGetData( $tNMCustomDraw, 8 ) - 2 ) DllStructSetData( $tRECT, 4, DllStructGetData( $tNMCustomDraw, 9 ) - 2 ) _WinAPI_FillRect( $hDC, $tRECT, $hHdrBrush ) ; Background color DllStructSetData( $tNMCustomDraw, "Left", DllStructGetData( $tNMCustomDraw, "Left" ) + 4 ) ; Left margin DllStructSetData( $tNMCustomDraw, "Right", DllStructGetData( $tNMCustomDraw, "Right" ) - 4 ) ; Right margin DllCall( "user32.dll", "int", "DrawTextW", "handle", $hDC, "wstr", $aHdrTexts[$iIndex], "int", StringLen( $aHdrTexts[$iIndex] ), "struct*", DllStructGetPtr( $tNMCustomDraw, "Left" ), "uint", $DT_LEFT+$DT_SINGLELINE+$DT_VCENTER ) ; _WinAPI_DrawText Return $CDRF_NEWFONT ; $CDRF_NEWFONT must be returned after changing font or colors EndSwitch EndSwitch EndSwitch Return $GUI_RUNDEFMSG #forceref $hWnd, $iMsg, $wParam EndFunc It fails the same way. Then I've replaced the GUIRegisterMsg technique with the Subclassing technique: #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #AutoIt3Wrapper_UseX64=y Opt( "MustDeclareVars", 1 ) #include <GUIConstants.au3> #include <GuiListView.au3> Global $hHeader, $aHdrTexts[8] Example() Func Example() ; Create GUI GUICreate( "ListView Header Colors - Subclassing", 840, 420 ) ; Create ListView Local $idListView = GUICtrlCreateListView( "", 10, 10, 820, 400 ) _GUICtrlListView_SetExtendedListViewStyle ( $idListView, $LVS_EX_FULLROWSELECT ) Local $hListView = GUICtrlGetHandle( $idListView ) ; Add columns to ListView For $i = 0 To 7 _GUICtrlListView_AddColumn( $idListView, "Column " & $i, 99 ) $aHdrTexts[$i] = "Column " & $i Next ; Fill ListView For $i = 0 To 99 GUICtrlCreateListViewItem( $i & "/0|" & $i & "/1|" & $i & "/2|" & $i & "/3|" & _ $i & "/4|" & $i & "/5|" & $i & "/6|" & $i & "/7|", $idListView ) Next ; Header control $hHeader = _GUICtrlListView_GetHeader( $idListView ) ; Register ListView WM_NOTIFY message handler Local $pLV_WM_NOTIFY = DllCallbackGetPtr( DllCallbackRegister( "LV_WM_NOTIFY", "lresult", "hwnd;uint;wparam;lparam;uint_ptr;dword_ptr" ) ) DllCall( "comctl32.dll", "bool", "SetWindowSubclass", "hwnd", $hListView, "ptr", $pLV_WM_NOTIFY, "uint_ptr", 0, "dword_ptr", 0 ) ; $iSubclassId = 0, $pData = 0 ;_WinAPI_SetWindowSubclass( $hListView, $pLV_WM_NOTIFY, 0, 0 ) ; $iSubclassId = 0, $pData = 0 ; Show GUI GUISetState( @SW_SHOW ) ; Message loop While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd ; Cleanup DllCall( "comctl32.dll", "bool", "RemoveWindowSubclass", "hwnd", $hListView, "ptr", $pLV_WM_NOTIFY, "uint_ptr", 0 ) ; $iSubclassId = 0 ;_WinAPI_RemoveWindowSubclass( $hListView, $pLV_WM_NOTIFY, 0 ) ; $iSubclassId = 0 GUIDelete() EndFunc ; ListView WM_NOTIFY message handler Func LV_WM_NOTIFY( $hWnd, $iMsg, $wParam, $lParam, $iSubclassId, $pData ) If $iMsg <> 0x004E Then Return DllCall( "comctl32.dll", "lresult", "DefSubclassProc", "hwnd", $hWnd, "uint", $iMsg, "wparam", $wParam, "lparam", $lParam )[0] ; 0x004E = $WM_NOTIFY Local Static $hHdrBrush = _WinAPI_CreateSolidBrush( 0xCCFFFF ) ; Yellow, BGR Local $tNMHDR = DllStructCreate( $tagNMHDR, $lParam ), $hWndFrom = HWnd( DllStructGetData( $tNMHDR, "hWndFrom" ) ), $iCode = DllStructGetData( $tNMHDR, "Code" ) Switch $hWndFrom Case $hHeader Switch $iCode Case $NM_CUSTOMDRAW Local $tNMCustomDraw = DllStructCreate( $tagNMLVCUSTOMDRAW, $lParam ) Local $dwDrawStage = DllStructGetData( $tNMCustomDraw, "dwDrawStage" ) Switch $dwDrawStage ; Holds a value that specifies the drawing stage Case $CDDS_PREPAINT ; Before the paint cycle begins ConsoleWrite( "CDDS_PREPAINT" & @CRLF ) Return $CDRF_NOTIFYITEMDRAW ; Notify parent window of any item related drawing operations Case $CDDS_ITEMPREPAINT ; Before an item is drawn: Default painting (frames and background) ConsoleWrite( "CDDS_ITEMPREPAINT" & @CRLF ) Return $CDRF_NOTIFYPOSTPAINT ; Notify parent window of any post item related drawing operations Case $CDDS_ITEMPOSTPAINT ; After an item is drawn: Custom painting (item texts) ConsoleWrite( "CDDS_ITEMPOSTPAINT" & @CRLF ) Local $iIndex = DllStructGetData( $tNMCustomDraw, "dwItemSpec" ) ; Item index Local $hDC = DllStructGetData( $tNMCustomDraw, "hdc" ) ; Device context _WinAPI_SetBkMode( $hDC, $TRANSPARENT ) ; Transparent background Local $tRECT = DllStructCreate( $tagRECT ) DllStructSetData( $tRECT, 1, DllStructGetData( $tNMCustomDraw, 6 ) + 1 ) DllStructSetData( $tRECT, 2, DllStructGetData( $tNMCustomDraw, 7 ) + 1 ) DllStructSetData( $tRECT, 3, DllStructGetData( $tNMCustomDraw, 8 ) - 2 ) DllStructSetData( $tRECT, 4, DllStructGetData( $tNMCustomDraw, 9 ) - 2 ) _WinAPI_FillRect( $hDC, $tRECT, $hHdrBrush ) ; Background color DllStructSetData( $tNMCustomDraw, "Left", DllStructGetData( $tNMCustomDraw, "Left" ) + 4 ) ; Left margin DllStructSetData( $tNMCustomDraw, "Right", DllStructGetData( $tNMCustomDraw, "Right" ) - 4 ) ; Right margin DllCall( "user32.dll", "int", "DrawTextW", "handle", $hDC, "wstr", $aHdrTexts[$iIndex], "int", StringLen( $aHdrTexts[$iIndex] ), "struct*", DllStructGetPtr( $tNMCustomDraw, "Left" ), "uint", $DT_LEFT+$DT_SINGLELINE+$DT_VCENTER ) ; _WinAPI_DrawText Return $CDRF_NEWFONT ; $CDRF_NEWFONT must be returned after changing font or colors EndSwitch EndSwitch EndSwitch ; Call next function in subclass chain Return DllCall( "comctl32.dll", "lresult", "DefSubclassProc", "hwnd", $hWnd, "uint", $iMsg, "wparam", $wParam, "lparam", $lParam )[0] #forceref $iSubclassId, $pData EndFunc Here the code works in all 4 situations: Windows 7/10, 32/64 bit. In the GUIRegisterMsg example, only CDDS_PREPAINT notifications are displayed in SciTE console. The problem seems to be that the CDRF_NOTIFYITEMDRAW return values are not received by the operating system. Therefore, the operating system does not generate CDDS_ITEMPREPAINT or CDDS_ITEMPOSTPAINT notifications and the header items are not colored. Because the Subclassing example works, it excludes errors in the $tagNMLVCUSTOMDRAW structure. It seems like there is an error in the internal AutoIt code associated with the GUIRegisterMsg function when the code is run as 64 bit code. The return values from the WM_NOTIFY message handler are not properly forwarded to the operating system. The error seems also to be related to the fact that the header control is a second level child in relation to the GUI. Colors does work for a listview control which is a first level child. Solution: Implement the WM_NOTIFY message handler in GUIListViewEx.au3 using the Subclassing technique. This is not necessarily completely trivial. In my example above, it looks easy. But this is also a very small example. Lars.
    1 point
  11. Where can i get this dll? It would be nice if i could test it here and try troubleshoot.
    1 point
  12. No, the commands I posted deal with only shutting down the PC remotely, which is what you asked for in the original post. You're now asking for something totally unrelated and not so easy to do.
    1 point
  13. Try RunWait('"' & @ComSpec & '" /k ' & $CMD, '', @SW_SHOW) You've got too many parameters
    1 point
  14. Perhaps using _SingleScript() function? You may wait until predecessor ends or kill predecessor or kill own script. _SingleScript.au3 may be found here
    1 point
  15. I think the best approach would be doing something like this : Opt ("MustDeclareVars", 1) HotKeySet ("{ESC}","_Exit") Global $latestname = "/Loaderv2.51.exe" While True While Not IsAppleConnected () Sleep (100) Wend Launcher () While IsAppleConnected () Sleep (100) Wend Wend Func _Exit () Exit EndFunc Func IsAppleConnected () Local $vObjWMI = ObjGet("winmgmts:\\" & @ComputerName & "\root\cimv2") Local $vObjItems = $vObjWMI.ExecQuery('SELECT * FROM Win32_USBHub') If not IsObj($vObjItems) Then Exit MsgBox (0,"Error","Not an object") For $vObjItem In $vObjItems If StringInStr($vObjItem.Description, "Apple") Then return True Next Return False EndFunc Func Launcher() If not WinExists("CydiaLoader") Then Local $c = Run(@ScriptDir & $latestname) If $c = 0 Then Exit MsgBox(0, 0, "failed to open cydia impactor, did you rename it?") EndIf EndFunc ;==>Launcher
    1 point
  16. Version 1.0.0.0

    1,675 downloads

    ADAT is a tool to simplify common AD administration tasks. Every administration task has its own tab. It is easy to add new functions (tabs) to the tool. Some often used functions are already available: list users, computers, OUs. File ADAT.ini can be customized to hold the AD logon information if necessary. Known Bugs: 2018-03-07: If the Script started from SciTE works but the "Process" button in the compiled exe does not do anything then please add the following line at the top of your script: #Au3Stripper_Ignore_Funcs=Process_Tab* BTW: If you like this tool please click the "I like this" button. This tells me where to next put my development effort
    1 point
  17. Iczer

    FreeImage Library

    Here FreeImage_GetMemorySize() function (its only for 3.17+ versions - 3.15. dont have it - see FreeImage3170.pdf) to update dll-version info on-the-fly some corrections to UDF are needed (also updated version of UDF uploaded): Global $FREEIMAGE_MAJOR_VERSION = 0 Global $FREEIMAGE_MINOR_VERSION = 0 Global $FREEIMAGE_RELEASE_SERIAL = 0 ;------------------------------------------------------------------------------------------ Func _FreeImage_GetVersion() ;Author: Prog@ndy Local $result = DllCall($__g_hFREEIMAGEDLL, "str", (($b___FeeImageIsx64)?("FreeImage_GetVersion"):("_FreeImage_GetVersion@0"))) If @error Then Return SetError(1, @error, "") Local $aVersion = StringRegExp($result[0],"(\d+)",3) If @error Then Return SetError(1, @error, "") $FREEIMAGE_MAJOR_VERSION = $aVersion[0] $FREEIMAGE_MINOR_VERSION = $aVersion[1] $FREEIMAGE_RELEASE_SERIAL = $aVersion[2] Return $result[0] EndFunc ;==>_FreeImage_GetVersion ;------------------------------------------------------------------------------------------ ;~ DLL_API unsigned DLL_CALLCONV FreeImage_GetMemorySize(FIBITMAP *dib); Func _FreeImage_GetMemorySize($pDIB) ;Author: Prog@ndy Local $result = DllCall($__g_hFREEIMAGEDLL, "uint", (($b___FeeImageIsx64)?("FreeImage_GetMemorySize"):("_FreeImage_GetMemorySize@4")), $lpFIBITMAP, $pDIB) If @error Then Return SetError(1, @error, 0) Return $result[0] EndFunc ;==>_FreeImage_GetMemorySize ;------------------------------------------------------------------------------------------ FreeImage_x86x64.au3
    1 point
  18. #include <FileConstants.au3> If Number(FileGetTime("file1.txt", $FT_CREATED, 1)) > Number(FileGetTime("file2.txt", $FT_CREATED, 1)) Then _ Msgbox(0, "", "file2 is older than file1")
    1 point
  19. rodent1

    copy append etc tool

    If you need to generate text data, this tool is for you. If you are gathering data from multiple sources and filtering it, or sorting it, this tool is for you. Generating text data manually can be time-consuming and mind-numbing. To ease my pain in this endeavour, I created this tool. I allows you to: - Gather data from multiple sources without having to paste it again and again in some editor before anything can be done to it. A user-defined string separator is used to separate the appended clipboard entries into records. - Or take a single line of formatted data and multiplying it by hundreds, then incrementing its lead field. Typical use: copy a line such as 2015/03/23 data 1 This is a test And this is a value where tabs separate data fields, for example. Then after generating a clipboard buffer where the line is repeated 10 times, and then incrementing it, the date at the start is detected and the day/month/year date value is correctly incremented This value is the output, and it is then placed into the clipboard: 2015/03/23 data 1 This is a test And this is a value 2015/03/24 data 1 This is a test And this is a value 2015/03/25 data 1 This is a test And this is a value 2015/03/26 data 1 This is a test And this is a value 2015/03/27 data 1 This is a test And this is a value 2015/03/28 data 1 This is a test And this is a value 2015/03/29 data 1 This is a test And this is a value 2015/03/30 data 1 This is a test And this is a value 2015/03/31 data 1 This is a test And this is a value 2015/04/01 data 1 This is a test And this is a value - Or if you are tring to filter records, enter a list of strings to find in the clipboard buffer and only keep the records that contain one of the find strings, or only keep the records that don't have one of the find strings This tool runs in the background and allows copying information that is scattered in documents or web pages etc to the clipboard by appending to what is already in the clipboard. To make the updated clipboard buffer more usable and separate records, a separator is used. The default separator is CRLF, but it can be changed to any user text string including CR or LF. Using the clipboard separator, records can be sorted as text up and down before pasting them, or you can copy a list and sort it in the clipboard before pasting it back sorted. Use hotkeys ctrl-alt-c to copy-append, ctrl-alt-x to cut-append, ctrl-alt-f to parse the clipboard text contents, and only keep the records that contain a find string ctrl alt d, prompt for find string, then find records in clipboard that contain the string and remove them only keeping other records in clipboard ctrl alt h, prompt for a find and a replace string, replace and update the clipboard ctrl-alt-r to run the current text selection as a command, ctrl-alt-F1 to display the list of commands, ctrl-alt-arrow up or down to sort up or down the entries, ctrl-alt-s to bring up the setup dialog, to set the separator, and other values. ctrl-alt-q to quit. There are a few more commands that I use to easily generate large amounts of testing data. ctrl-alt-g copies what is selected and prompts the user for the number of times the selection should be repeated. Then if each record starts with a number, or a date with format yyyy/mm/dd, or time, ctrl-alt-i increments the numeric or date or time value for each record. If these ctrl-alt keys are not convenient, you can change them in the first 8 HotKeySet statements of the code to fit what you need. This works fine for me on my windows 7 64 bit machines. If you find that you have problems on a different platform, please share your fixes. Enjoy, and please share your improvements. #include <GUIConstantsEx.au3> #include <EditConstants.au3> #include <Array.au3> #include <Date.au3> Local $sClipSeparator = @CRLF ; some apps at times misbehave and hog the clipboard for a while, they are supposed to release it and may take their time before they release it, if ever... Local $dNumberOfRetries = 3 ; number of times to try again in case it's needed Local $dWaitTimeMilliSec = 200 ; how long to wait between tries, in milliseconds Local $IncrementValue = 1 Local $Version = "1.01" ; if you change the key assignments below, you may want to also modify the Help() function accordingly HotKeySet("^!c", "CopyAppend") ; ctrl alt c, copy append HotKeySet("^!f", "FilterInClpRecords") ; ctrl alt f, prompt for find string, then find records in clipboard that contain the string and remove other records from clipboard HotKeySet("^!d", "FilterOutClpRecords") ; ctrl alt d, prompt for find string, then find records in clipboard that contain the string and remove them only keeping other records in clipboard HotKeySet("^!h", "ReplaceInClpRecords") ; ctrl alt h, prompt for a find and a replace string, replace and update the clipboard HotKeySet("^!x", "CutAppend") ; ctrl alt x, cut append HotKeySet("^!r", "RunSelection") ; ctrl alt r, run selection as command line HotKeySet("^!s", "ClipAppendSetup") ; ctrl alt s HotKeySet("^!q", "QuitClipAppend") ; ctrl alt q HotKeySet("!^{UP}", "SortAscending") ; ctrl alt up HotKeySet("!^{DOWN}", "SortDescending") ; ctrl alt down HotKeySet("!^{F1}", "Help") ; ctrl alt F1 ; This reads the current text selection, then prompts for number of needed lines in output buffer. HotKeySet("^!g", "GenerateListFromSelection") ; If the ctrl alt g list is numeric or date time or starts with a number or date time, ctrl alt i uses the setup increment or decrement value to increment or decrement each buffer entry HotKeySet("^!i", "InOrDecrementSelection") ; ctrl alt i, looks at record starts, if it is date or numeric and of consistent length, updates that prefix to increase or decrease with each record ReadSettings() ; The loop that will go on and on while the app is running, between sleeps autoit checks to see if a hotkey from statements above was called from the keyboard while 1 Sleep(100) WEnd ;=========Functions called by hot keys=============== Func ClipAppendSetup() ; Run the clipAppend setup GUI Local $listValue Local $LocalSep Local $boolSepIsLitt = False Local $frmSetup = GUICreate("Append to Clipboard, setup", 530, 220, 50, 5) GUISetBkColor(0x005555, $frmSetup) WinSetTrans($frmSetup, "", 230) ;set transparency level to 200 (0=invisible, 255=opaque) GUICtrlCreateGroup("Clipboard Separator", 5, 5, 520, 110) Local $rbLiteral = GUICtrlCreateRadio("Enter a custom separator string:",20, 20) Local $rbNonLiteral = GUICtrlCreateRadio("Select a non-literal separator string:",20, 40) Local $lbSeps = GUICtrlCreateList("", 210, 50,300, 60) Local $edit = GUICtrlCreateEdit("", 210, 20, 300, 25, $ES_AUTOHSCROLL) Local $CurrentListSelection Local $bSelectionIsCustom = False Switch($sClipSeparator) case @CR $CurrentListSelection = "CR" GUICtrlSetState($rbNonLiteral, $GUI_CHECKED) case @LF $CurrentListSelection = "LF" GUICtrlSetState($rbNonLiteral, $GUI_CHECKED) case @CRLF $CurrentListSelection = "CRLF" GUICtrlSetState($rbNonLiteral, $GUI_CHECKED) case Else $bSelectionIsCustom = True GUICtrlSetState($rbLiteral, $GUI_CHECKED) EndSwitch if $bSelectionIsCustom Then GUICtrlSetState($lbSeps, $GUI_DISABLE) Else GUICtrlSetState($edit, $GUI_DISABLE) GUICtrlSetData($lbSeps, "CR|LF|CRLF", $CurrentListSelection) EndIf Local $lblTries = GUICtrlCreateLabel("Number of tries:", 20, 125) Local $cboTries = GUICtrlCreateCombo($dNumberOfRetries, 110, 125, 50) GUICtrlSetData(-1,"1|2|3|4|5|6|7") Local $lblWait = GUICtrlCreateLabel("Delay between tries (ms):",260, 125) Local $cboDelay = GUICtrlCreateCombo($dWaitTimeMilliSec, 390, 125, 50) GUICtrlSetData(-1,"100|200|300|400|500|600|700|800|900|1000") Local $incVal = GUICtrlCreateLabel("Increment value:",20, 150) Local $cboInc = GUICtrlCreateCombo($IncrementValue, 110, 150, 50) Local $Data = "-20" for $i = -19 to 20 $Data &= "|" & $i Next GUICtrlSetData(-1, $Data) Local $btnSave = GUICtrlCreateButton("Save Settings", 20, 180, 120, 25) Local $btnCancel = GUICtrlCreateButton("Cancel", 390, 180, 120, 25) GUICtrlSetState($btnSave, $GUI_DISABLE) GUISetState(@SW_SHOW) Local $idMsg while 1 $idMsg = GUIGetMsg() Switch($idMsg) case $GUI_EVENT_CLOSE, $btnCancel GUIDelete($frmSetup) ;Exit ;debug Return case $rbLiteral $boolSepIsLitt = True GUICtrlSetState($lbSeps, $GUI_DISABLE) GUICtrlSetState($edit, $GUI_ENABLE) case $rbNonLiteral $boolSepIsLitt = False GUICtrlSetState($lbSeps, $GUI_ENABLE) GUICtrlSetState($edit, $GUI_DISABLE) case $lbSeps $listValue = "@" & GUICtrlRead($lbSeps) GUICtrlSetState($btnSave, $GUI_ENABLE) case $cboInc GUICtrlSetState($btnSave, $GUI_ENABLE) case $btnSave if $boolSepIsLitt Then $sClipSeparator = GUICtrlRead($edit) Else $sClipSeparator = GetStringValue($listValue) EndIf $dNumberOfRetries = GUICtrlRead($cboTries) $dWaitTimeMilliSec = GUICtrlRead($cboDelay) $IncrementValue = GUICtrlRead($cboInc) GUIDelete($frmSetup) SaveSettings() ; save the clipboard separator to the registry value HKCU\software\clipappend\$sClipSeparator Return case $edit, $cboTries, $cboDelay GUICtrlSetState($btnSave, $GUI_ENABLE) EndSwitch WEnd EndFunc Func CopyAppend() SetError(0) Local $CurrentClipString = GetTextClipboard() Switch(@error) case 0 send ("^c") Local $NewClp = ClipGet() PutToClp($CurrentClipString & $sClipSeparator & $NewClp) case 1 ; The data in the clipboard is NOT text Send ("^c") ; the clipboard is empty, no separator case 2 MsgBox(0, "Error!", "Unable to append to non-string clipboard contents") case 3, 4 MsgBox(0, "Error!", "Unable to access the clipboard") EndSwitch EndFunc func CutAppend() SetError(0) Local $CurrentClipString = GetTextClipboard() Switch(@error) case 0 send ("^x") Local $NewClp = GetTextClipboard() PutToClp($CurrentClipString & $sClipSeparator & $NewClp) case 1 Send ("^x") ; the clipboard is empty, no separator case 2 MsgBox(0, "Error!", "Unable to append to non-string clipboard contents") case 3, 4 MsgBox(0, "Error!", "Unable to access the clipboard") EndSwitch EndFunc Func FilterInClpRecords() FilterClpRecords(True) EndFunc Func FilterOutClpRecords() FilterClpRecords(False) EndFunc Func GenerateListFromSelection() send("^c") ; get the selection Sleep(100) Local $CurrentClipString = GetTextClipboard() Local $RepeatNumber = int(InputBox("Repeat Number", "Please enter a number between 0 and 36767:")) if $RepeatNumber > 0 Then Local $OutBuf = $CurrentClipString for $i = 1 to $RepeatNumber-1 $OutBuf = $OutBuf & $sClipSeparator & $CurrentClipString Next PutToClp($OutBuf) EndIf EndFunc Func Help() Local $sHelpBuffer = "ClipAppend list of commands" & @LF & "====================" & @LF $sHelpBuffer &= "Ctl-alt-S to set up the clipboard delimitor" & @LF $sHelpBuffer &= "Ctrl-alt-c to copy and append the current selection (if it can be copied)" & @LF $sHelpBuffer &= "Ctrl-alt-x to cut and append the current selection (if it can be cut)" & @LF $sHelpBuffer &= "Ctrl-alt-r to run the current selection as a command line" & @LF $sHelpBuffer &= "Ctrl-alt-f to only keep clipboard records that contain user find strings" & @LF $sHelpBuffer &= "Ctrl-alt-d to only keep clipboard records that DO NOT contain user find strings" & @LF $sHelpBuffer &= "Ctrl-alt-up/down to sort the clipboard contents up or down" & @LF $sHelpBuffer &= "Ctrl-alt-g to repeat a selected line in current document n times, where the user is prompted for n" & @LF $sHelpBuffer &= "Ctrl-alt-i to autoincrement numerically or date wise the clipboard buffer from command above" & @LF $sHelpBuffer &= "Ctrl-alt-q to quit" & @LF $sHelpBuffer &= "Ctrl-alt-F1 to bring up this message" MsgBox(32,"ClipAppend " & $Version & " Help",$sHelpBuffer) EndFunc Func InOrDecrementSelection() ; check if the buffer starts with a number on each item after splitting around the separator Local $CurrentClipString = GetTextClipboard() if StringInStr($CurrentClipString, $sClipSeparator)>0 Then Local $NumericStringStart = GetNumericStringStart($CurrentClipString) if stringlen($NumericStringStart)>0 Then ; since this starts with a number, it could be the start of a time, date, or date time substring Local $DateTimeStringStart = GetDateTimeStringStart($CurrentClipString) if $DateTimeStringStart <> -1 Then Local $IncValue = $DateTimeStringStart if StringInStr($IncValue, ":")>0 Then ; includes time Local $arTimeInfo = StringSplit($IncValue, ":") Switch($arTimeInfo[0]) case 1 ;we increment minutes Local $OutBuf = IncDate($CurrentClipString, "n", $IncValue) $IncValue = _DateAdd("n", $IncValue, $IncrementValue) case 2 ; we increment seconds Local $OutBuf = IncDate($CurrentClipString, "s", $IncValue) $IncValue = _DateAdd("s", $IncValue, $IncrementValue) EndSwitch Else ; does not include time, we increment days Local $OutBuf = IncDate($CurrentClipString, "D", $IncValue) $IncValue = _DateAdd("D", $IncValue, $IncrementValue) EndIf PutToClp($OutBuf) Else Local $IncValue = $NumericStringStart Local $iLen = stringlen($NumericStringStart) Local $arClip = StringSplit($CurrentClipString, $sClipSeparator, 1) for $i = 1 to $arClip[0] $arClip[$i] = $IncValue & StringRight($arClip[$i], stringlen($arClip[$i]) - stringlen($NumericStringStart)) $IncValue = IncStringNumber($IncValue, $iLen) Next Local $OutBuf = _ArrayToString($arClip, $sClipSeparator, 1, $arClip[0], $sClipSeparator) PutToClp($OutBuf) EndIf EndIf EndIf EndFunc Func QuitClipAppend() Exit EndFunc Func ReplaceInClpRecords() Local $CurrentClipString = GetTextClipboard() if StringLen($CurrentClipString)>0 Then Local $FindString = InputBox("ClipAppend", "Please enter the find string:") if StringLen($FindString)>0 Then Local $ReplaceString = InputBox("ClipAppend", "Please enter the replace string:") if StringInStr($CurrentClipString, $sClipSeparator)>0 Then Local $arClip = StringSplit($CurrentClipString, $sClipSeparator) for $i = 1 to $arClip[0] if StringInStr($arClip[$i], $FindString)>0 Then $arClip[$i] = StringReplace($arClip[$i], $FindString, $ReplaceString) EndIf Next Local $sOut = _ArrayToString($arClip, $sClipSeparator, 1, 0, $sClipSeparator) PutToClp($sOut) Else if StringInStr($CurrentClipString, $FindString)>0 Then PutToClp(StringReplace($CurrentClipString, $FindString, $ReplaceString)) EndIf EndIf EndIf Else MsgBox(0, "Warning!", "No clipboard text!") EndIf EndFunc func RunSelection() SetError(0) Local $CurrentClipString = GetTextClipboard() Switch(@error) case 0 ; PutToClp("") commented because it often causes the next command to fail send ("^c") SetError(0) Local $RunSelection = ClipGet() if StringLen($RunSelection)=0 Then Switch(@error) case 1 MsgBox(0,"Error!", "Failed to copy the selection to the clipboard") case 2 MsgBox(0,"Error!", "The selection is not text") case Else MsgBox(0,"Error!", "Failed to access the clipboard, @error = " & @error) EndSwitch Return Else ; PutToClp("") commented because it often causes the next command to fail PutToClp($CurrentClipString) Local $Result = ShellExecute($RunSelection) ; better than using the run cmd, since it can also interpret a link, an exe, a txt if $Result = 0 Then MsgBox(0,"Error!", "Failed to run the command '" & $RunSelection & "'") EndIf EndIf case 1 Send ("^x") ; the clipboard is empty, no separator case 2 MsgBox(0, "Error!", "Unable to append to non-string clipboard contents") case 3, 4 MsgBox(0, "Error!", "Unable to access the clipboard") EndSwitch EndFunc Func SortAscending() SetError(0) Local $clp = ClipGet() Switch(@error) case 0 Local $arClip = StringSplit($clp, $sClipSeparator, 1) _ArraySort($arClip,0, 1) PutToClp(_ArrayToString($arClip, $sClipSeparator, 1, 0, $sClipSeparator)) case 1 MsgBox(0,"Warning!", "There is nothing to sort, the clipboard is empty") case 2 MsgBox(0,"Warning!", "There is nothing to sort, the clipboard contents are not alphanumeric") case 3, 4 MsgBox(0, "Error!", "Unable to access the clipboard") EndSwitch EndFunc Func SortDescending() SetError(0) Local $clp = ClipGet() Switch(@error) case 0 Local $arClip = StringSplit($clp, $sClipSeparator, 1) _ArraySort($arClip,1, 1) PutToClp(_ArrayToString($arClip, $sClipSeparator, 1, 0, $sClipSeparator)) case 1 MsgBox(0,"Warning!", "There is nothing to sort, the clipboard is empty") case 2 MsgBox(0,"Warning!", "There is nothing to sort, the clipboard contents are not alphanumeric") case 3, 4 MsgBox(0, "Error!", "Unable to access the clipboard") EndSwitch EndFunc ;==============End of Functions called by hot keys=============== ;====================Support Functions ========================== Func FilterClpRecords($boolInclude) Local $CurrentClipString = GetTextClipboard() if StringLen($CurrentClipString)>0 Then ; There is a clipboard text to search and filter Local $arFindStrings = InputBoxWCheckBox("ClipAppend", "Please enter the find string:", "Please uncheck to stop entering data") if $arFindStrings <> -1 Then ; The user entered at least one find string Local $sOutClip ; output string that will be written to the clipboard when populated below if StringInStr($CurrentClipString, $sClipSeparator)>0 Then ; the clipboard text has multiple records Local $arClip[0], $arFound[0] _ArrayAdd($arClip, $CurrentClipString, 0, $sClipSeparator) ;populate the array of current clipboard records $arClip ; for each user find string, for $i = 0 to UBound($arFindStrings) - 1 Local $arNewFound[0] ; populate an array of indexes where the current find string was found, $arNewFound $arNewFound = _ArrayFindAll($arClip, $arFindStrings[$i], 0, 0, 0, 1) ; append the contents of array $arNewFound to already found array $arFound _ArrayConcatenate($arFound, $arNewFound) Next _ArrayUnique($arFound) ; remove duplicates (different user find strings may be found in the same record) _ArraySort($arFound) ; sort so looping through array items points to increasing indexes of array $arClip if $boolInclude Then ; $boolInclude is the instruction to filter in strings where find strings are found Local $arOutClip[UBound($arFound)] ; declare output clipboard record array with same size as array of found records ; populate output clipboard array for $i = 0 to UBound($arOutClip) - 1 $arOutClip[$i] = $arClip[$arFound[$i]] Next if UBound($arOutClip)>0 then $sOutClip = _ArrayToString($arOutClip,$sClipSeparator) ; serialize the array into a string for output EndIf ElseIf Ubound($arClip) > UBound($arFound) Then ; if not all clipboard records contain one of the find strings, if UBound($arFound) = 0 Then Return ; nothing was found, keep the clipboard as is Else Local $arOutClip[UBound($arClip) - UBound($arFound)] Local $iFound = 0 Local $FoundIndex = $arFound[$iFound] Local $OutClipIndex = 0 for $i = 0 to UBound($arClip) - 1 if $FoundIndex < $i Then ; the current clipboard record does not contain any of the find strings, $arOutClip[$OutClipIndex] = $arClip[$i] $OutClipIndex += 1 ; increment output clipboard array index for (possible) use in later loop Else $iFound += 1 $FoundIndex = $arFound[$iFound] EndIf Next $sOutClip = _ArrayToString($arOutClip,$sClipSeparator) EndIf ;Else ; all records have found strings, the clipboard contents should be emptied, leave $sOutClip as is, which is empty EndIf PutToClp($sOutClip) Else ; clipboard contents has only one record, msgbox(0,@ScriptLineNumber, "clipboard contents has only one record") for $i = 0 to UBound($arFindStrings) - 1 MsgBox(0,@ScriptLineNumber, "checking out " & $arFindStrings[$i]) if StringInStr($CurrentClipString, $arFindStrings[$i])>0 Then If $boolInclude Then Return Else PutToClp("") EndIf EndIf Next EndIf EndIf Else MsgBox(0, "Warning!", "No clipboard text!") EndIf EndFunc Func GetDateTimeStringStart($Buf) local $arClip = StringSplit($Buf, $sClipSeparator, 1) ; don't want to check all entries if there are thousands, limit it to 30 Local $scope = $arClip[0] if $scope > 30 then $scope = 30 Local $SubString = "" for $i = 1 to $scope if $SubString = "" Then $SubString = GetNumSubstring($arClip[$i], "/:") Else if stringlen($arClip[$i])>0 Then Local $NewSubString = GetNumSubstring($arClip[$i], "/:") if $NewSubString <> $SubString Then MsgBox(0, "Error!", "Buffer line " & $i & " is different from buffer line " & $i - 1 & "!") Return -1 EndIf EndIf EndIf Next Return $SubString EndFunc Func GetNumericStringStart($Buf) local $arClip = StringSplit($Buf, $sClipSeparator, 1) ; don't want to check all entries if there are thousands, limit it to 30 Local $scope = $arClip[0] if $scope > 30 then $scope = 30 Local $LeftNumeric, $boolDifferent = False for $i = 1 to $scope if $i = 1 Then $LeftNumeric = GetNumSubstring($arClip[$i]) Else Local $NewLeftNumeric = GetNumSubstring($arClip[$i]) if $NewLeftNumeric <> $LeftNumeric Then MsgBox(0, "Error!", "Buffer line " & $i & " is different from buffer line " & $i - 1 & "!") Return -1 EndIf EndIf if StringLen($LeftNumeric) = 0 then MsgBox(0, "Error!", "Buffer line 1 does not start with a number") Return -1 EndIf Next Return $LeftNumeric EndFunc Func GetNumSubstring($sIn, $NonNumAcceptableChars = "") Local $Char, $Ret for $i = 1 to stringlen($sIn) $Char = StringMid($sIn, $i, 1) if Asc($Char)>47 and Asc($Char)<58 Then $Ret &= $Char ElseIf StringInStr($NonNumAcceptableChars, $Char)>0 Then $Ret &= $Char Else ExitLoop EndIf Next if StringLen($NonNumAcceptableChars)>0 Then ; check if it's a date, time, or date time if _DateIsValid($Ret)=0 Then $Ret = "" ; date time is not valid EndIf EndIf Return $Ret EndFunc func GetStringValue($Value) if StringLeft($Value, 1) = "@" Then Switch($Value) case "@CR" Return @CR case "@LF" Return @LF case "@CRLF" return @CRLF case Else Return $Value EndSwitch Else Return $Value EndIf EndFunc Func GetTextClipboard($dFailedNum = 0) Local $ClipText = ClipGet() ; first try to get the text clipboard value Switch(@error) case 0 Return $ClipText case 1 SetError(0) Return "" case 2 Return "" case 3,4 if $dFailedNum = -1 then ; -1 flags that if it fails, we return an empty string and the error set in the ClipGet() call Return "" EndIf ; it failed once, try again till the set number of tries is reached While ++$dFailedNum < $dNumberOfRetries Sleep($dWaitTimeMilliSec) SetError(0) $ClipText = GetTextClipboard(-1) ; use -1 to flag not to keep going recursively forever if @error = 0 Then ; no error, this means that the call succeeded, the function job is complete Return $ClipText EndIf WEnd MsgBox(0, "Error!", "The clipboard seems to be locked, it failed to respond after " & $dNumberOfRetries & " attempts, with " & $dWaitTimeMilliSec & " between tries.") EndSwitch EndFunc Func IncDate($Buf, $Type, $IncValue) Local $arClip = StringSplit($Buf, $sClipSeparator, 1) Local $iLen = stringlen($IncValue) for $i = 1 to $arClip[0] $arClip[$i] = $IncValue & StringRight($arClip[$i], stringlen($arClip[$i]) - $iLen) $IncValue = _DateAdd($Type, $IncrementValue, $IncValue) Next Return _ArrayToString($arClip,$sClipSeparator, 1, $arClip[0], $sClipSeparator) EndFunc Func IncStringNumber($sIn, $iLen) Local $sFormat = "%0" & $iLen & "d" ; build the format string, see PrintFormat in help for the syntax $sIn = $sIn*1 + $IncrementValue ; multyplying by one internally converts the string that contains characters between 0 and 9 to a numeric value Return StringFormat($sFormat, $sIn) EndFunc ; returns an array of user strings, user enters till the checkbox is unchecked Func InputBoxWCheckBox($Title, $Prompt, $CheckBoxLabel) Local $boolChecked = True Local $boolClearEdit = True Local $arUE[1] Local $GuiID = GUICreate($Title, 415, 120) Local $PromptID = GUICtrlCreateLabel($Prompt, 5, 10, 200) Local $UserInputID = GUICtrlCreateInput("",210, 10, 200) Local $cbDoneID = GUICtrlCreateCheckbox($CheckBoxLabel, 5, 35) GUICtrlSetState(-1, $GUI_CHECKED) Local $cbEmptyEditOnOK = GUICtrlCreateCheckbox("Delete Find string on OK press", 200, 35) GUICtrlSetState(-1, $GUI_CHECKED) Local $btnCancel = GUICtrlCreateButton("Cancel", 5, 60, 70) Local $btnOK = GUICtrlCreateButton("OK", 340, 60, 70) GUICtrlSetState(-1, $GUI_DEFBUTTON) GUISetState(@SW_SHOW, $GuiID) While 1 local $msg = GUIGetMsg() Switch($msg) Case $GUI_EVENT_CLOSE GUIDelete($GuiID) ExitLoop case $cbDoneID $boolChecked = BitAND(GUICtrlRead($cbDoneID), $GUI_CHECKED) = $GUI_CHECKED case $cbEmptyEditOnOK $boolClearEdit = BitAND(GUICtrlRead($cbEmptyEditOnOK), $GUI_CHECKED) = $GUI_CHECKED case $btnCancel GUIDelete($GuiID) Return -1 case $btnOK Local $UserEntry = GUICtrlRead($UserInputID) if stringlen($UserEntry)>0 Then if StringLen($arUE[0]) = 0 Then $arUE[0] = $UserEntry Else _ArrayAdd($arUE, $UserEntry) EndIf if $boolClearEdit Then GUICtrlSetData($UserInputID, "") EndIf EndIf if $arUE = 0 And Not $boolChecked Then GUIDelete($GuiID) return -1 ElseIf $arUE <> 0 And Not $boolChecked Then GUIDelete($GuiID) Return $arUE EndIf EndSwitch WEnd EndFunc Func PutToClp($sClp) Local $Res = ClipPut($sClp) Local $Attempts = 1 while $res = 0 and $Attempts < $dNumberOfRetries ; while failure Sleep($dWaitTimeMilliSec) $Res = ClipPut($sClp) $Attempts += 1 WEnd if $Res = 0 Then ; failed MsgBox(0,"Error!", "Failed to write to the clipboard!") EndIf EndFunc Func ReadRegSetting($Setting, $Type) Local $RetVal SetError(0) $RetVal = RegRead("HKCU\software\ClipAppend", $Setting) Switch(@error) case 0 if StringLen($RetVal)>0 Then Return $RetVal Else Return -1 EndIf case -1 ; in case the ClipAppend key is there, but not the $Setting value Return -1 case 1 ; expected on first use, there is no ClipAppend key, create it RegWrite("HKCU\software\ClipAppend") Return -1 case 2 Return -1 case else ; should never get here MsgBox(0,"Error!", "Failed to write to the registry, @error = " & @error) Return -1 EndSwitch EndFunc Func ReadSettings() Local $RetVal $RetVal = ReadRegSetting("ClipSeparator", "REG_MULTI_SZ") if $RetVal <> -1 Then $sClipSeparator = $RetVal EndIf $RetVal = ReadRegSetting("CopyCutRetries", "REG_SZ") if $RetVal <> -1 Then $dNumberOfRetries = $RetVal EndIf $RetVal = ReadRegSetting("RetryDelay", "REG_SZ") if $RetVal <> -1 Then $dWaitTimeMilliSec = $RetVal EndIf $RetVal = ReadRegSetting("IncrementValue", "REG_SZ") if $RetVal <> -1 Then $IncrementValue = $RetVal EndIf EndFunc Func SaveSettings() SetError(0) Local $Result = RegWrite("HKCU\SOFTWARE\ClipAppend", "ClipSeparator", "REG_MULTI_SZ", $sClipSeparator) if $Result = 0 Then MsgBox(0,"Error!", "Failed to write the separator value to the registry, error = " & @error) EndIf SetError(0) Local $Result = RegWrite("HKCU\SOFTWARE\ClipAppend", "CopyCutRetries", "REG_SZ", $dNumberOfRetries) if $Result = 0 Then MsgBox(0,"Error!", "Failed to write the number of copy retries to the registry, error = " & @error) EndIf SetError(0) Local $Result = RegWrite("HKCU\SOFTWARE\ClipAppend", "RetryDelay", "REG_SZ", $dWaitTimeMilliSec) if $Result = 0 Then MsgBox(0,"Error!", "Failed to write the retry delay to the registry, error = " & @error) EndIf SetError(0) Local $Result = RegWrite("HKCU\SOFTWARE\ClipAppend", "IncrementValue", "REG_SZ", $IncrementValue) if $Result = 0 Then MsgBox(0,"Error!", "Failed to write the increment value to the registry, error = " & @error) EndIf EndFunc ;====================End Support Functions ==========================
    1 point
  20. TIFF2JPGS.au3This is not a request for such a script, but a "proof of concept", for the ones interested. Ok, ok. It's just a bunch of DLL calls. I admit lol! Since I was not able to find a *simple* program to split the TIFF files into individual JPG images (that I can then use easily with AutoIT), I did some research for a DLL able to do that... I came across "The FreeImage Project", which gave me what I was looking for. So here it is - a simple script to convert multi-page TIFF files into separate JPGs I might have some issues / obvious errors in my DLLCalls that may cause memory leaks... I'm no expert in the subject unfortunately. But it works for me!
    1 point
  21. After I saw this example I´ve decided to change a litle here and add a litle more there and make a MultiTiff To PDF creator script. I´ve changed a litle the Comment ... I hope you don´t mind Who knows ... maybe we shall make a PDFCreator clone in AutoIt Just kiding ... Keep the good work #cs TIFF2PDF --------- Multi-Page TIFF to PDF file converter THIS SCRIPT NEEDS THE FREEIMAGE LIBRARY DLL FILE (FreeImage.dll) IN THE SCRIPT DIRECTORY AND ALSO THE PDFFORGE LYBRARY DLL FILE (pdfforge.dll) AND iText LIBRARY DLL (itextsharp.dll) FreeImage library is at http://freeimage.sourceforge.net/download.html PdfForge libraries are at http://pdfcreator.svn.sourceforge.net/viewvc/pdfcreator/tags/Version%201.2.1/PlugIns/pdfforge/ #ce ;Input file to split $input = FileOpenDialog("Choose a TIFF file", @ScriptDir, "TIFF files (*.TIF)") ;Output file convention is simple: I remove the extension, append an underscore '_'. ;The loop (below) will further append the page number and add the ".jpg" extension. ;If I picked a file named "IMAGE.TIF", the output will be "IMAGE_1.JPG", "IMAGE_2.JPG" and so on. $output = StringTrimRight($input,4) & "_" ;Filename of the FreeImage Dll. $FI_DLL = @ScriptDir & "\FreeImage.dll" ;Create PDFForge.dll instance $PdfForge = ObjCreate("pdfforge.pdf.pdf") ;Theses are constants used by FreeImage. ;I got the values from the header file (FreeImage.h) included with the FreeImage dll download. ;Global const $FIF_JPEG = 2 Global const $FIF_TIFF = 18 ;Some basic check... does the TIFF file exists? if FileExists($input) then ;Yet another check - does the FreeImage DLL is there? if FileExists($FI_DLL) then ;At this point, I start the process! ;Opens the FreeImage DLL $FI = DllOpen($FI_DLL) ;Initialize the library (mandatory according to the documentation0 DllCall($FI,"none","_FreeImage_Initialise@4","dword",1) ;Opens the input TIFF file. $TIFF_IMAGE = DllCall($FI,"long_ptr","_FreeImage_OpenMultiBitmap@24","dword", $FIF_TIFF, "str", $input, "dword", 0, "dword", 1, "dword", 0, "dword", 0) ;Gets the number of pages from the TIFF image $PAGE_COUNT = DllCall($FI, "int", "_FreeImage_GetPageCount@4", "long_ptr", $TIFF_IMAGE[0]) ;Page index are 0-based. For a loop, I'll need to go from 0 to (PAGE_COUNT -1) $PAGE_COUNT = $PAGE_COUNT[0] -1 ;Declare Image2PDF array Dim $imageFilenames[$PAGE_COUNT+1] ;The way FreeImage lib works, you need to "lock" a single page at a time to work with it. ;I understands that this will actually copy the page into a separate bitmap, so I can play with it ;In my case, I just want to save each page into an individual JPG file for $i = 0 to $PAGE_COUNT ;Get a page from the multi-page TIFF file $BITMAP = DllCall($FI, "long_ptr", "_FreeImage_LockPage@8", "long_ptr", $TIFF_IMAGE[0], "dword", $i) ;Save it as a JPG file $ret = DllCall($FI, "dword", "_FreeImage_Save@16","dword", $FIF_TIFF, "long_ptr", $BITMAP[0], "str", $i &".tiff", "dword", 0) ;Save the file´s names into array $imageFilenames[$i] = @ScriptDir &"\" &$i &".tiff" ;Unlock the page. $ret = DllCall($FI, "none", "_FreeImage_UnlockPage@12", "long_ptr", $TIFF_IMAGE[0], "long_ptr", $BITMAP[0], "dword", 0) ;Free the RAM? AutoIT tends to crash at the end if I do not do this (Can't tell - I'm no developper) $BITMAP = 0 next ;Output the PDF file $PdfForge.Images2PDF_2($imageFilenames, StringTrimRight($input, 4) &".pdf", 1) ;MsgBox(64,"Info","Process is done." & @crlf & $input & " were splitted into " & $PAGE_COUNT+1 & " individual TIF files") MsgBox(64,"Info","Process is done." &StringTrimRight($input, 4) &".pdf has been created with " &$PAGE_COUNT+1 &" pages from " &StringTrimRight($input, 4) &" file") ;Close the TIFF file $ret = DllCall($FI,"long","_FreeImage_CloseMultiBitmap@8","long_ptr", $TIFF_IMAGE[0], "dword", 0) ;Again, if I do not reassign some variables like this, I usually have a crash when the program ends. $TIFF_IMAGE = 0 ;This will "DeInitialize" the FreeImage lib ;I *think* this does more or less the same as DllClose(), but I can be wrong. DllCall($FI,"none","_FreeImage_DeInitialise@0") Else MsgBox(16,"FreeImage DLL not found","The FreeImage DLL was not found in the script directory." & @crlf & "(" & $FI_DLL & ")" & @crlf & @crlf & "You can get if from this website:" & @crlf & "http://freeimage.sourceforge.net/download.html") EndIf Else MsgBox(16,"File not found","You should have a TIFF file named " & $input & " in this script directory. Check this and try again") EndIf
    1 point
  22. nf67, Or you can use these SREs from Malkey to get various parts of the path directly: Local $sFile = "C:\Program Files\Another Dir\AutoIt3\AutoIt3.chm" ; Drive letter - Example returns "C" Local $sDrive = StringRegExpReplace($sFile, ":.*$", "") ; Full Path with backslash - Example returns "C:\Program Files\Another Dir\AutoIt3\" Local $sPath = StringRegExpReplace($sFile, "(^.*\\)(.*)", "\1") ; Full Path without backslash - Example returns "C:\Program Files\Another Dir\AutoIt3" Local $sPathExDr = StringRegExpReplace($sFile, "(^.:)(\\.*\\)(.*$)", "\2") ; Full Path w/0 backslashes, nor drive letter - Example returns "\Program Files\Another Dir\AutoIt3\" Local $sPathExDrBSs = StringRegExpReplace($sFile, "(^.:\\)(.*)(\\.*$)", "\2") ; Path w/o backslash, not drive letter: - Example returns "Program Files\Another Dir\AutoIt3" Local $sPathExBS = StringRegExpReplace($sFile, "(^.*)\\(.*)", "\1") ; File name with ext - Example returns "AutoIt3.chm" Local $sFilName = StringRegExpReplace($sFile, "^.*\\", "") ; File name w/0 ext - Example returns "AutoIt3" Local $sFilenameExExt = StringRegExpReplace($sFile, "^.*\\|\..*$", "") ; Dot Extenstion - Example returns ".chm" Local $sDotExt = StringRegExpReplace($sFile, "^.*\.", ".$1") ; Extenstion - Example returns "chm" Local $sExt = StringRegExpReplace($sFile, "^.*\.", "") MsgBox(0, "Path File Name Parts", _ "Drive " & @TAB & $sDrive & @CRLF & _ "Path " & @TAB & $sPath & @CRLF & _ "Path w/o backslash" & @TAB & $sPathExBS & @CRLF & _ "Path w/o Drv: " & @TAB & $sPathExDr & @CRLF & _ "Path w/o Drv or \'s" & @TAB & $sPathExDrBSs & @CRLF & _ "File Name " & @TAB & $sFilName & @CRLF & _ "File Name w/o Ext " & @TAB & $sFilenameExExt & @CRLF & _ "Dot Extension " & @TAB & $sDotExt & @CRLF & _ "Extension " & @TAB & $sExt & @CRLF) M23
    1 point
×
×
  • Create New...