myspacee Posted March 3, 2008 Share Posted March 3, 2008 Hello to all, first post for me here. Want to post a very simple script that save us a lot of work. We must cut hundred pdf into small ones, so this script wait for a clipboard, and when a new one comes, it ask for filename, and save in bmp format. Easy one, maybe already posted, but i want to join ... Thank you again for Autoit and all examples Bye. [sorry for bad english] CODE#include <Clipboard.au3> #include <ScreenCapture.au3> ;//////////////////////////////////////////////////////////////////// ;// declare var ;//////////////////////////////////////////////////////////////////// dim $f_go dim $sizeA dim $sizeB dim $conta $f_go = 0 $conta = 0 ;//////////////////////////////////////////////////////////////////// ;// create 2 temp file A and B. ;//////////////////////////////////////////////////////////////////// Sleep(500) ;//////////////////////////////////////////////////////////////////// ;// read clipboard and create file A ;//////////////////////////////////////////////////////////////////// _ClipBoard_Open(0) ; open clipboard is associated with the current task $hBitmap = _ClipBoard_GetData(2) ; $CF_BITMAP ;_ScreenCapture_SetJPGQuality(100) ; set the value between 0-100 _ScreenCapture_SaveImage(@WorkingDir & '\TempA.bmp', $hBitmap) _ClipBoard_Close() ;//////////////////////////////////////////////////////////////////// ;// read clipboard and create file B ;//////////////////////////////////////////////////////////////////// _ClipBoard_Open(0) ; open clipboard is associated with the current task $hBitmap = _ClipBoard_GetData(2) ; $CF_BITMAP ;_ScreenCapture_SetJPGQuality(100) ; set the value between 0-100 _ScreenCapture_SaveImage(@WorkingDir & '\TempB.bmp', $hBitmap) _ClipBoard_Close() While $f_go = 0 Sleep(500) ;aspetto mezzo secondo ;//////////////////////////////////////////////////////////////////// ;// read clipboard and create file A ;//////////////////////////////////////////////////////////////////// _ClipBoard_Open(0) ; open clipboard is associated with the current task $hBitmap = _ClipBoard_GetData(2) ; $CF_BITMAP ;_ScreenCapture_SetJPGQuality(100) ; set the value between 0-100 _ScreenCapture_SaveImage(@WorkingDir & '\TempA.bmp', $hBitmap) _ClipBoard_Close() ;//////////////////////////////////////////////////////////////////// ;// take files dimension for confrontation ;//////////////////////////////////////////////////////////////////// $sizeA = FileGetSize(@WorkingDir & "\TempA.bmp") $sizeB = FileGetSize(@WorkingDir & "\TempB.bmp") if $sizeB <> $sizeA then ;se il file nuovo è diverso da quello preedente - qualcosa è cambiato... ;//////////////////////////////////////////////////////////////////// ;// ask for filename ;//////////////////////////////////////////////////////////////////// Beep(500, 100) $answer = InputBox("Save as", "Filename", "Insert file name", "", -1, -1, 0, 0) if $answer = "" then $answer = @HOUR & @MIN & @SEC EndIf ;//////////////////////////////////////////////////////////////////// ;// copy new file into user give filename ;//////////////////////////////////////////////////////////////////// FileCopy(@WorkingDir & '\TempA.bmp', @WorkingDir & "\" & $answer & ".bmp", 1) ; copio il nuovo sul vecchio Sleep(500) ;aspetto mezzo secondo ;//////////////////////////////////////////////////////////////////// ;// delete temp and restart ;//////////////////////////////////////////////////////////////////// FileDelete(@WorkingDir & "\TempA.bmp") FileDelete(@WorkingDir & "\TempB.bmp") _ClipBoard_Open(0) ; open clipboard is associated with the current task $hBitmap = _ClipBoard_GetData(2) ; $CF_BITMAP ;_ScreenCapture_SetJPGQuality(100) ; set the value between 0-100 _ScreenCapture_SaveImage(@WorkingDir & '\TempB.bmp', $hBitmap) _ClipBoard_Close() $f_go = 0 $conta = 0 EndIf $conta = $conta + 1 if $conta = 3600 Then msgbox(0, "ClipME", "Time pass away... I quit myself !", 30) FileDelete(@WorkingDir & "\TempA.bmp") FileDelete(@WorkingDir & "\TempB.bmp") Exit EndIf WEnd Link to comment Share on other sites More sharing options...
yoness Posted March 4, 2008 Share Posted March 4, 2008 hey, you are italian purtroppo quelli italiani che usano autoit sono pochi, quindi ho sempre dovuto leggere roba in inglese... beh complimenti per lo script, ora lo vado a provare -i can use the computer, but i'm not a computer- Link to comment Share on other sites More sharing options...
myspacee Posted March 5, 2008 Author Share Posted March 5, 2008 ciao yoness ! update code with some nice exercises (for me) and new feature : - save as .... (ask for output filename) - progressive (automatic number for filename) to switch, right mouse over icon and select. Sorry for italian comment (i'm so lazy) CODE#include <Clipboard.au3> #include <ScreenCapture.au3> #Include <Constants.au3> ;#NoTrayIcon ;FileInstall(@WorkingDir & "\Clipme.au3", @WorkingDir & "\source.au3") ;//////////////////////////////////////////////////////////////////// ;// dichiaro variabile e primi settaggi ;//////////////////////////////////////////////////////////////////// dim $f_go dim $sizeA dim $sizeB dim $conta dim $conta_progressivo dim $conta_progressivo_zeroed dim $modalita_A dim $modalita_B Dim $f_modalita $f_go = 0 $conta = 0 $conta_progressivo = 0 $modalita_A = "Modalità : Salva con nome ..." $modalita_B = "Modalità : Numero progressivo" $f_modalita = 1 ;//////////////////////////////////////////////////////////////////// ;// informazioni nella trayicon ;//////////////////////////////////////////////////////////////////// TrayTip("ClipME", "Trasformo gli snapshot in file !", 3, 1) ;//////////////////////////////////////////////////////////////////// ;// poi ne disabilito funzioni classiche e creo menù ;//////////////////////////////////////////////////////////////////// Opt("TrayMenuMode",1) ; Default tray menu items (Script Paused/Exit) will not be shown. $switchitem = TrayCreateItem($modalita_A) TrayCreateItem("") $exititem = TrayCreateItem("Exit") TraySetState() TraySetClick(16) ;//////////////////////////////////////////////////////////////////// ;// controllo esistenza di una sola sessione - chiudo le altre ! ;//////////////////////////////////////////////////////////////////// $list = ProcessList("Clipme.exe") for $i = 1 to $list[0][0] if $i > 1 Then msgbox(0, "ClipME", "Puoi lanciare una sola sessione di ClipME !", 1) ProcessClose($list[$i][1]) EndIf next ;//////////////////////////////////////////////////////////////////// ;// creo i 2 file per confronto, poi è il ciclo while li gestisce ;//////////////////////////////////////////////////////////////////// Sleep(500) ;//////////////////////////////////////////////////////////////////// ;// leggo snapshot in canna ( creo file A) ;//////////////////////////////////////////////////////////////////// _ClipBoard_Open(0) ; open clipboard is associated with the current task $hBitmap = _ClipBoard_GetData(2) ; $CF_BITMAP ;_ScreenCapture_SetJPGQuality(100) ; set the value between 0-100 _ScreenCapture_SaveImage(@WorkingDir & '\TempA.bmp', $hBitmap) _ClipBoard_Close() ;//////////////////////////////////////////////////////////////////// ;// leggo snapshot in canna ( creo file ;//////////////////////////////////////////////////////////////////// _ClipBoard_Open(0) ; open clipboard is associated with the current task $hBitmap = _ClipBoard_GetData(2) ; $CF_BITMAP ;_ScreenCapture_SetJPGQuality(100) ; set the value between 0-100 _ScreenCapture_SaveImage(@WorkingDir & '\TempB.bmp', $hBitmap) _ClipBoard_Close() While 1 $msg = TrayGetMsg() ;MsgBox(0, "", $msg) Select Case $msg = 0 Sleep(500) ;aspetto mezzo secondo ;//////////////////////////////////////////////////////////////////// ;// leggo snapshot in canna ( creo file A) ;//////////////////////////////////////////////////////////////////// _ClipBoard_Open(0) ; open clipboard is associated with the current task $hBitmap = _ClipBoard_GetData(2) ; $CF_BITMAP ;_ScreenCapture_SetJPGQuality(100) ; set the value between 0-100 _ScreenCapture_SaveImage(@WorkingDir & '\TempA.bmp', $hBitmap) _ClipBoard_Close() ;//////////////////////////////////////////////////////////////////// ;// prendo le dimensioni file per eseguire confronto ;//////////////////////////////////////////////////////////////////// $sizeA = FileGetSize(@WorkingDir & "\TempA.bmp") $sizeB = FileGetSize(@WorkingDir & "\TempB.bmp") if $sizeB <> $sizeA then ;se il file nuovo è diverso da quello preedente - qualcosa è cambiato... if $f_modalita = 1 Then ;//////////////////////////////////////////////////////////////////// ;// modalità Save as... ;//////////////////////////////////////////////////////////////////// Beep(500, 100) $answer = InputBox("Salva con nome", "Inserisci il nome file", "Inserisci il nome file", "", -1, -1, 0, 0) Elseif $f_modalita = 0 Then ;//////////////////////////////////////////////////////////////////// ;// modalità numero progressivo ;//////////////////////////////////////////////////////////////////// Beep(500, 100) $conta_progressivo = $conta_progressivo + 1 $conta_progressivo_zeroed = "000000" & $conta_progressivo $conta_progressivo_zeroed = Stringright($conta_progressivo_zeroed, 5) $answer = $conta_progressivo_zeroed TrayItemSetText($switchitem, $modalita_B & " - " & $conta_progressivo_zeroed) EndIf ;//////////////////////////////////////////////////////////////////////////// ;// pulizia e controllo nomefile e copia clipboard modificata in mio file ;//////////////////////////////////////////////////////////////////////////// $answer = StringReplace($answer, "\", "") $answer = StringReplace($answer, "/", "") $answer = StringReplace($answer, "|", "") $answer = StringReplace($answer, ":", "") $answer = StringReplace($answer, "*", "") $answer = StringReplace($answer, "<", "") $answer = StringReplace($answer, ">", "") if $answer = "" then $answer = @HOUR & @MIN & @SEC EndIf FileCopy(@WorkingDir & '\TempA.bmp', @WorkingDir & "\" & $answer & ".bmp", 1) ; copio il nuovo sul vecchio Sleep(500) ;aspetto mezzo secondo ;//////////////////////////////////////////////////////////////////// ;// RI-leggo snapshot in canna ( RI-creo file ;//////////////////////////////////////////////////////////////////// _ClipBoard_Open(0) ; open clipboard is associated with the current task $hBitmap = _ClipBoard_GetData(2) ; $CF_BITMAP ;_ScreenCapture_SetJPGQuality(100) ; set the value between 0-100 _ScreenCapture_SaveImage(@WorkingDir & '\TempB.bmp', $hBitmap) _ClipBoard_Close() $f_go = 0 $conta = 0 EndIf $conta = $conta + 1 if $conta = 3600 Then msgbox(0, "ClipME", "Sono passati 30 minuti senza eseguire snapshot - ESCO !", 30) FileDelete(@WorkingDir & "\TempA.bmp") FileDelete(@WorkingDir & "\TempB.bmp") Exit EndIf Case $msg = $switchitem ;Msgbox(64,"Info: ", "è " & $f_modalita) ;//////////////////////////////////////////////////////////////////// ;// cambio di modalita 1 = salva con nome | 0 = num progressivo ;//////////////////////////////////////////////////////////////////// if $f_modalita = 1 Then ;se sono in salva con nome switcho in modalità numero progressivo TrayItemSetText($switchitem, $modalita_B & " - " & $conta_progressivo_zeroed) Msgbox(64,"CAMBIO MODALITA' !", "Ora sei in " & $modalita_ $f_modalita = 0 elseif $f_modalita = 0 then ;se sono in numero progressivo switcho in modalità salva con nome TrayItemSetText($switchitem, $modalita_A) Msgbox(64,"CAMBIO MODALITA' !", "Ora sei in " & $modalita_A) $f_modalita = 1 EndIf ;Msgbox(64,"Info: ", "diventa: " & $f_modalita) $msg = 0 Case $msg = $exititem FileDelete(@WorkingDir & "\TempA.bmp") FileDelete(@WorkingDir & "\TempB.bmp") ExitLoop Exit EndSelect WEnd Exit bye to all ! Link to comment Share on other sites More sharing options...
myspacee Posted April 3, 2008 Author Share Posted April 3, 2008 Hello again,a lots of improvments for my little tool. (thank you Autoit you open a world)I want to add 'Selection capture' feature from wonderfull MsCreatoR CaptureitOur tool are pretty similar (obviously MsCreatoR is better) but mine do a different job.(start action when differences between clipboard are found)'Selection capture' can complete my tools for my office users and our daily activity.Anyone can help me maybe with function or old post ?Thank you and sorry for bad english.M. Link to comment Share on other sites More sharing options...
myspacee Posted April 29, 2008 Author Share Posted April 29, 2008 Update code. adjust for our office needs. Sorry for spaghetti code, but now works so i can pass my time to optimize it. - snapshot an area of your screen - snapshot alt+prt area - 2 save mode (silent and prompted) - add cutter - add thumb creation (set them with .ini) to snapshot and resize/crop them to defined meseurements. (we use to upload them to out job www) - add 'cross' on desktop to suggest user where point mouse, to fight resize/crop effect. - add a lot of bugs to correct thank you for your time m Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now