Greenseed Posted October 10, 2004 Share Posted October 10, 2004 (edited) Hello Guys! i searching a method to know when a button was press on a digital camera for taking a photo from it with a autoit script. in my script the people need to press enter to take the photo. but on the digital camera we got a button. i know that, windows know the existance of this button and he know when i press it. this is my code expandcollapse popup; Cree le 26/01/2004 Mod: 28/01/2004 ;Autoit Script Pour Une Photo Pour Carte De Membre ;Ordinateur: Terminal Server ;Module: Click.exe ;Debut ;************Variable And Setting*********** AutoItSetOption ( "WinDetectHiddenText", 1 ) AutoItSetOption ( "WinWaitDelay", 500 ) AutoItSetOption ( "RunErrorsFatal", 0 ) AutoItSetOption ( "TrayIconDebug", 1 ) AutoItSetOption ( "TrayIconHide", 1 ) AutoItSetOption ( 'SendKeyDownDelay', 1 ) AutoItSetOption ( 'SendKeyDelay', 1 ) AdlibEnable ( "myAdLib" ) MouseMove ( 0, 0, 0 ) BlockIn ( 1 ) Global $_x = @Desktopwidth - 306 Global $_y = @DesktopHeight - @DesktopHeight Global $_windir = @WindowsDir Global $_pf = @ProgramFilesDir dim $i = 0 Global $_computername = @ComputerName Global $_savebox Global $_notfound ;**************Files Installs ;----Progress--------- _progress($i, 10, 1, 'Vérification Fichiers') FileInstall ( 'c:\au3\pskill.exe', $_windir & '\system32\pskill.exe' ) ;**************Début*************************** ;**************Check Files and delete******************* if FileExists ( 'C:\Quickcam\scrach.bmp' ) then Filedelete ( 'c:\quickcam\scrach.bmp' ) if FileExists ( 'C:\Quickcam\photo.bmp' ) then Filedelete ( 'c:\quickcam\photo.bmp' ) ;***************Function Call***************************** debut() func debut() langue() runie() photo() iview() ;----Progress--------- _progress($i, 100, 1,'Fermeture...') _exit() endfunc ;*********Langue************************ Func langue() if $_computername = 'rgauche' or $_computername = 'rcentre' or $_computername = 'rdroite' then $_savebox = 'Enregistrer l''image' $_notfound = 'Impossible de trouver le serveur' else $_savebox = 'Save Picture' $_notfound = 'Cannot find server' endif endfunc ;*********Block Input********************************* Func blockin( $x ) dim $x2 = @Desktopwidth - 387 Blockinput ( $x ) If $x = 1 then SplashTextOn ( 'InputLocked', '', 75, 0, $x2, 0 ) else SplashOff() endif endfunc ;****************Run Explorer at http://rgauche:8080********** Func runie() ;----Progress--------- _progress($i, 20, 1, 'Connection À La WebCam...') Run ( $_pf & '\Internet Explorer\iexplore.exe -k http://rgauche:8080' ) $_winwait = WinWait ( 'RGauche WebCam', '', 10 ) if $_winwait = 0 then ;----Progress--------- _progress( $i, 0, -1, 'Erreur') Run ( 'pskill.exe iexplore.exe' ) blockin ( 0 ) Msgbox (0, 'Finding Cam', 'La Caméra n''a pu être rejoin.', 15 ) myadlib() _exit() else WinActivate ( 'RGauche WebCam', ',' ) endif EndFunc ;**************Prise de la photo******************* Func photo() ;----Progress--------- _progress($i, 30, 1, 'Initialisation De La Prise De Photo...') Blockin (0) $_msgbox = MsgBox ( 262145, 'Photo', 'Appuyez Sur ''Enter'' Pour Prendre La Photo!', 300 ) Blockin (1) if $_msgbox = -1 or $_msgbox = 2 then ;----Progress--------- _progress($i, 10, -1, 'Réinisialisation...') retry() else blockin ( 1 ) ;----Progress--------- _progress($i, 35, 1, 'Fermeture De La WebCam...') Winclose ( 'RGauche WebCam' ) endif ;----Progress--------- _progress($i, 40, 1,'Capture Photo...') Run ( $_pf & '\Internet Explorer\iexplore.exe -k http://rgauche:8080/cam_1.jpg' ) $_winwait = WinWait ( 'http://rgauche:8080/cam_1.jpg','', 10 ) if $_winwait = 0 then ;----Progress--------- _progress($i, 0, -1, 'Erreur') blockin ( 0 ) Msgbox (262144, 'Photo', 'Impossible de trouver la photo.', 15 ) _exit() endif Blockin( 0 ) ;----Progress--------- _progress($i, 45, 1, 'Confirmation...') $_msgbox = MsgBox( 262404, 'Photo', 'Voulez-Vous Cette Photo?', 60 ) if $_msgbox = 6 then Blockin (1) ;----Progress--------- _progress($i, 55, 1, 'Sauvegarde De La Photo...') Blockin ( 1 ) MouseClick ('left', 33, 37, 1, 0 ) Sleep (2500) MouseClick ('left', 33, 37, 1, 0 ) $_winwait = WinWait ( $_savebox,'',10 ) if $_winwait = 0 then ;----Progress--------- _progress($i, 0, -1, 'Erreur') blockin ( 0 ) Msgbox (0, 'Photo', 'Impossible de sauvegarder la photo.', 15 ) myadlib() _exit() endif WinActivate ( $_savebox ) Clipput ( 'c:\quickcam\scrach.bmp' ) Send ( '^v{ENTER}' ) WinWaitClose ( $_savebox ) ;----Progress--------- _progress($i, 60, 1,'Saving...') else retry() endif endfunc ;********************I_view32********************* Func iview() ;----Progress--------- _progress($i, 70, 1,'Démarrage De Ir_View32...') Blockin (1) Run ( 'i_view32.exe scrach.bmp', 'c:\quickcam' ) $_winwait = WinWait ( 'IrfanView - scrach.bmp', '', 15 ) if $_winwait = 0 then ;----Progress--------- _progress($i, 0, -1, 'Erreur') Run ( 'pskill.exe i_view32.exe' ) blockin ( 0 ) Msgbox (0, 'i_view32', 'Impossible de charger la photo.', 15 ) myadlib() _exit() endif WinActivate ( 'IrfanView - scrach.bmp' ) ;----Progress--------- _progress($i, 75, 1,'Sending Keys...') Send ( '^r' ) WinActivate ( 'Resize/Resemple' ) Send ( '!n{TAB}150{TAB}130{ENTER}' ) sleep ( 100 ) Send ( '!fs' ) ;----Progress--------- _progress($i, 80, 1,'Saving...') WinWait ( 'Save Picture As ...', '', 7 ) WinActivate ( 'Save Picture As ...' ) ;----Progress--------- _progress($i, 85, 1,'Sending Keys...') Clipput ( 'c:\quickcam\photo.bmp' ) send ( '^v{TAB}b{ENTER}' ) WinWaitClose ( 'Save Picture As ...', 15 ) ;----Progress--------- _progress($i, 90, 1,'Fermeture De IR_View32...') Run ( 'pskill.exe i_view32.exe' ) endfunc ;********************Progress Bar**************************** Func _progress( $de, $a, $step, $_text ) ProgressOn ( 'Photo Carte De Membre', $_text, '', $_x, $_y ) If $i = 100 then ProgressSet(100 , "Terminé", "Complété") else For $i = $de to $a step $step sleep(10) ProgressSet( $i, $i & " % De Terminé") If $i = 100 then ProgressSet(100 , "Terminé", "Complété") endif Next endif endfunc ;************************Retry******************************* Func retry() while winexists( 'RGauche WebCam' ) winclose( 'RGauche WebCam' ) wend While WinExists( 'http://rgauche:8080/cam_1.jpg' ) WinClose ( 'http://rgauche:8080/cam_1.jpg' ) wend Blockin ( 0 ) $_msgbox = Msgbox ( 262404, 'Recommencer', 'Voulez-Vous Recommencer?', 30) if $_msgbox = 7 then ;----Progress--------- _progress($i, 0, -1, 'Exiting') _exit() else ;----Progress--------- $i = 10 debut() endif endfunc ;**********************ADLIB********************************** Func myAdLib() if WinExists ( $_notfound ) then WinClose ( $_notfound ) endif EndFunc ;*****************Exit****************** func _exit() while winexists( 'RGauche WebCam' ) winclose( 'RGauche WebCam' ) wend While WinExists( 'http://rgauche:8080/cam_1.jpg' ) WinClose ( 'http://rgauche:8080/cam_1.jpg' ) wend If winexists ('IrfanView') then Winkill ('IrfanView') exit endfunc Greenseed MCSE+I Edited August 27, 2008 by Greenseed GreenseedMCSE+I, CCNA, A+Canada, QuebecMake Love Around You. Link to comment Share on other sites More sharing options...
t0ddie Posted October 10, 2004 Share Posted October 10, 2004 (edited) instead of hitting enter, could you maybe use a workaround? like click it with the mouse instead. maybe use a getmouseposition, if its on the tab "take snapshot" for a specific amount of time then alert you. just a thought. i dont think you can detect or capture keystrokes with autoit that would be keylogging... but im not sure. that might be just for ascii characters. that is a good question. :EDIT oh, reading further.. you want it to react to another device button push... you might need third party software. or, what does the screen do when you take a picture? does it open a new window? anything? save a pic? if you can get autoit to detect an event in the GUI then it will work autoit will work on the windows gui and thats it. can you make the pic have a set name each time? or do you have to enter it. can you make the first pic.. "1" the second pic "2" then you just check to see if the file exists. it will be a little slower than detecting the actual realtime press of the camera button, but it will work to let you know that it WAS pressed if you use this method hope that helps Edited October 10, 2004 by t0ddie Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you. Link to comment Share on other sites More sharing options...
Greenseed Posted October 10, 2004 Author Share Posted October 10, 2004 we take only one picture at time beacause we must put this picture in a database with the client name.... the question about "detect button press on a device" maybe we can get it by calling a dll or something like this... maybe when the button is press a key is modifying in the reg and modifi it again when realese. i don't know im a newbi... i will try some reg and process monitor when i press the button ... GreenseedMCSE+I, CCNA, A+Canada, QuebecMake Love Around You. Link to comment Share on other sites More sharing options...
nobby Posted October 11, 2004 Share Posted October 11, 2004 Just a thought... I know that is not what you want, but... Instead of checking for a button pressed on the camera, you could check for the existance of the file "cam_1.jpg". CheersNobby Link to comment Share on other sites More sharing options...
t0ddie Posted October 11, 2004 Share Posted October 11, 2004 thats exactly what i already suggested nobby Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you. 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