Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

how can i add a screenshot function to a function?

$
0
0
Func IMR12()      while 1           sleep(1000)          $IMR12= _ImageSearch('5star.bmp', 0, $X, $Y, 0)          if $IMR12 = 1 Then             MouseClick("left")             sleep(600)             IMR21()          else             sleep(100)             start()          EndIf       WEnd    EndFunc

i want know if its possible for this function to have a screenshot when the 5star.bmp is there? so maybe like right before IMR21()?

and also the screenshot shouldnt replace an exist screenshot?

i did find a this script from some1 else and was wondering if it possible to add the screenshot function to mine script? or im not sure how to go about it. 

thanks for the help!

AutoIt         
#cs AU3 Screen Shot Utility 1.0 Author : Solixious Klein #ce #include<WindowsConstants.au3> #include<GUIConstants.au3> #include<ScreenCapture.au3> init() Func init()    Global $frame=GUICreate("AU3 Screen Shot Utility 1.0",300,100,200,200)    GUISetIcon("icon.ico")    TraySetIcon("icon.ico")    Global $file=GUICtrlCreateMenu("File")    Global $name=GUICtrlCreateMenuItem("Change Name",$file)    Global $loc=GUICtrlCreateMenuItem("Storage Location",$file)    Global $form=GUICtrlCreateMenuItem("Screenshot Format",$file)    Global $exit=GUICtrlCreateMenuItem("Exit",$file)    Global $help=GUICtrlCreateMenu("Help")    Global $about=GUICtrlCreateMenuItem("About",$help)    Global $lab=GUICtrlCreateLabel("Shift + F8 -------> Take Screen Shot" & @CRLF & @CRLF & "Shift + F3 -------> Show or Hide this Window Frame",10,15)    Opt("TrayOnEventMode", 1)    Opt("TrayMenuMode", 1)    Global $shw=TrayCreateItem("Show Frame")    Global $capt=TrayCreateItem("Capture Screen Shot")    Global $ex=TrayCreateItem("Exit")    TrayItemSetOnEvent($shw,"show")    TrayItemSetOnEvent($ex,"ex")    TrayItemSetOnEvent($capt,"Cap")    If FileExists("name.dat") Then       Global $prename=FileRead("name.dat")       If $prename="" Then          $prename="Screen"       EndIf    Else       Global $prename="Screen"    EndIf    If FileExists("loc.dat") Then       Global $path=FileRead("loc.dat")       If $path="" Then          $path=@WorkingDir       EndIf    Else       Global $path=@WorkingDir    EndIf    If FileExists("form.dat") Then       Global $format=FileRead("form.dat")       If $format="" Then          $format="jpg"       EndIf    Else       Global $format="jpg"    EndIf    HotKeySet("+{F3}","show")    HotKeySet("+{F8}","Cap")    While 1       $event=GUIGetMsg()       If $event=$GUI_EVENT_CLOSE Or $event=$exit Then          Exit       ElseIf $event=$GUI_EVENT_MINIMIZE Then          GUISetState(@SW_HIDE,$frame)          HotKeySet("+{F3}","hide")          TrayItemSetState($shw,64)       ElseIf $event=$loc Then          $p=FileSelectFolder("Open Location","",1+2+4,FileRead("loc.dat"))          If $p<>"" Then             $f=FileOpen("loc.dat",2+8)             FileWrite($f,$p)             $path=$p          EndIf       ElseIf $event=$name Then          $x=InputBox("New Name","Enter the file name",FileRead("name.dat"))          If $x<>"" Then             $f=FileOpen("name.dat",2+8)             FileWrite($f,$x)             $prename=$x          EndIf       ElseIf $event=$form Then          $o=InputBox("Format","jpg / bmp / gif / tif / png",FileRead("form.dat"))          $o=StringLower($o)          If $o="jpg" Or $o="bmp" Or $o="gif" Or $o="tif" Or $o="png" Then             $f=FileOpen("form.dat",2+8)             FileWrite($f,$o)             $format=$o          EndIf       ElseIf $event=$about Then          MsgBox(0,"About","Screen Shot Utility 1.0" & @CRLF & "Author : Solixious" & @CRLF & "Date of Creation : 10th October, 2012")       EndIf    WEnd EndFunc Func show()    GUISetState(@SW_SHOW,$frame)    HotKeySet("+{F3}","hide")    TrayItemSetState($shw,128) EndFunc Func hide()    GUISetState(@SW_HIDE,$frame)    HotKeySet("+{F3}","show")    TrayItemSetState($shw,64) EndFunc Func Cap()    $fname=getname()    $c=_ScreenCapture_Capture()    _ScreenCapture_SaveImage($fname,$c,True) EndFunc Func ex()    Exit EndFunc Func getname()    $i=1    While FileExists($path & "\" & $prename & " " & $i & "." & $format)       $i=$i+1    WEnd    Return $path & "\" & $prename & " " & $i & "." & $format EndFunc

Viewing all articles
Browse latest Browse all 12506

Trending Articles