ChrisL Posted June 22, 2006 Share Posted June 22, 2006 (edited) In the below script I have a slider, when you change the position of the slider it updates a label to show you a text representation of the slider value but only once you release the mouse.Is there a way to update the text value live as you slide the slider?Thanks(uses LazyCats captdll.dll http://www.autoitscript.com/forum/index.php?showtopic=8377 )Edit* Who broke the Autoit code tags then??expandcollapse popup#include <GuiConstants.au3> ;only allow 1 running copy if _Singleton("MultiScreenDump3",1) = 0 Then MsgBox(262144, "Error", "Screen Capture is already running") Exit EndIf ;install Dll FileInstall("captdll.dll", @TempDir & "\captdll.dll", 1) ;set initial global settings Global $count = 1, $dest = @ScriptDir, $quality = "100", $ext = "JPG" , $useButtonGui = 1 ;instructions for user MsgBox(262144, "Screen Capture", "Press ""F1"" to change settings at any time" & @CRLF & _ "Press ""PrintScreen"" to capture whole screen" & @CRLF & _ "Press ""Alt"" + ""Printscreen"" to capture active window" & @CRLF & _ "Press ""escape"" to quit") ;build the button Gui $buttonGui = GuiCreate("ScreenButtons", 120, 120,@DesktopWidth -170, @desktopheight -210 , $WS_POPUP, $WS_EX_TOPMOST) $button1 = GuiCtrlCreateButton ("Screen",0,0,60,60) $button2 = GuiCtrlCreateButton ("Active",61,0,60,60) $button3 = GuiCtrlCreateButton ("Setup",0,61,60,60) $button4 = GuiCtrlCreateButton ("Quit",61,61,60,60) GuiSetState(@SW_Hide,$buttonGui) ;bring up settings dialogue and activate hotkeys Settings() While 1 If $usebuttonGui = 1 then ButtonGui() Sleep(100) WEnd Func Settings() HotKeySet("{PRINTSCREEN}", "Capture") HotKeySet("!{PRINTSCREEN}", "AreaCapture") HotKeySet("{ESC}", "Quit") HotKeySet("{F1}", "Settings") $main = GUICreate("Screen capture settings", 392, 178, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS), $WS_EX_TOPMOST) $outputLabel = GUICtrlCreateLabel("Output Directory", 10, 15, 180, 20) $OutputDir = GUICtrlCreateInput("", 10, 40, 290, 25) GUICtrlSetData(-1, $dest) $Browse = GUICtrlCreateButton("Browse", 320, 40, 60, 25) $Combo = GUICtrlCreateCombo("JPG", 20, 75, 80, 61) GUICtrlSetData(-1, "BMP", $ext) $QualitySlide = GUICtrlCreateSlider(10, 100, 365, 30) GUICtrlSetLimit($QualitySlide, 100, 1) GUICtrlSetData($QualitySlide, $quality) If $ext = "BMP" then GuiCtrlSetState ($QualitySlide, $GUI_Disable) $SliderLabel = GUICtrlCreateLabel("Quality " & $quality, 300, 80, 120, 20) $OSButtons = GUICtrlCreateCheckbox ("Use on screen capture buttons", 20,140) If $useButtonGui = 1 then GuiCtrlSetState ($OSButtons, $GUI_CHECKED) $done = GUICtrlCreateButton ("Continue",260,140,120,25) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE $dest = GUICtrlRead($OutputDir) If StringRight($dest, 1) = "\" Then $dest = StringTrimRight($dest, 1) If Not FileExists ($dest) then DirCreate ($dest) $quality = GUICtrlRead($QualitySlide) $ext = GUICtrlRead($Combo) If Bitand (GUICtrlRead ($OSButtons), $GUI_Checked) Then $useButtonGui = 1 Else $useButtonGui = 0 Endif GUIDelete($main) Exitloop Case $msg = $done $dest = GUICtrlRead($OutputDir) If StringRight($dest, 1) = "\" Then $dest = StringTrimRight($dest, 1) If Not FileExists ($dest) then DirCreate ($dest) $quality = GUICtrlRead($QualitySlide) $ext = GUICtrlRead($Combo) If Bitand (GUICtrlRead ($OSButtons), $GUI_Checked) Then $useButtonGui = 1 Else $useButtonGui = 0 Endif GUIDelete($main) Exitloop Case $msg = $Browse WinSetOnTop($main,"",0) GuiSetState (@SW_Disable, $main) $dest = FileSelectFolder("Select a destination", "", 1) If $dest = "" then $dest = @scriptDir GUICtrlSetData($OutputDir, $dest) GuiSetState (@SW_Enable, $main) WinSetOnTop($main,"",1) Case $msg = $Combo If GUICtrlRead($Combo) = "BMP" Then GUICtrlSetState($QualitySlide, $GUI_Disable) GUICtrlSetData($SliderLabel, "Quality N/A") $quality = "-1" $ext = "BMP" Else GUICtrlSetState($QualitySlide, $GUI_Enable) $quality = GUICtrlRead($QualitySlide) GUICtrlSetData($SliderLabel, "Quality " & $quality) EndIf Case $msg = $QualitySlide $quality = GUICtrlRead($QualitySlide) GUICtrlSetData($SliderLabel, "Quality " & $quality) $ext = "JPG" Case Else ;;; EndSelect WEnd ;Exit EndFunc ;==>Settings Func ButtonGui() GuiSetState(@SW_Show,$buttonGui) While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button1 Capture() Case $msg = $Button2 AreaCapture() Sleep (100) Case $msg = $Button3 GuiSetState(@SW_Hide,$buttonGui) Send ("{F1}") ExitLoop Case $msg = $Button4 Send ("{ESC}") Case Else If not BitAnd (WinGetState ($buttonGui),8) then WinSetOnTop ($buttonGui,"",1) ;;; EndSelect WEnd EndFunc Func Capture() If $useButtonGui = 1 then WinSetState ($buttonGui,"",@SW_MINIMIZE) GuiSetState (@SW_HIDE, $buttonGui) Endif If FileExists($dest & "\image_" & $count & "." & $ext) <> 0 Then Do $count += 1 Until FileExists($dest & "\image_" & $count & "." & $ext) = 0 EndIf DllCall(@TempDir & "\captdll.dll", "int", "CaptureScreen", "str", $dest & "\image_" & $count & "." & $ext, "int", $quality) $count += 1 If $useButtonGui = 1 then Sleep (100) GuiSetState (@SW_SHOW, $buttonGui) WinSetState ($buttonGui,"",@SW_Restore) Endif EndFunc ;==>Capture Func AreaCapture() If $useButtonGui = 1 then WinSetState ($buttonGui,"",@SW_MINIMIZE) GuiSetState (@SW_HIDE, $buttonGui) Endif If FileExists($dest & "\image_" & $count & "." & $ext) <> 0 Then Do $count += 1 Until FileExists($dest & "\image_" & $count & "." & $ext) = 0 EndIf $active = WinGetHandle ("") $cords = WinGetPos($active) If IsArray($cords) Then DllCall(@TempDir & "\captdll.dll", "int", "CaptureRegion", "str", $dest & "\image_" & $count & "." & $ext, "int", $cords[0], "int", $cords[1], "int", $cords[2], "int", $cords[3], "int", $quality) $count += 1 EndIf If $useButtonGui = 1 then Sleep (100) GuiSetState (@SW_SHOW, $buttonGui) WinSetState ($buttonGui,"",@SW_Restore) Endif EndFunc ;==>AreaCapture Func _Singleton($occurenceName, $flag=0) Local $ERROR_ALREADY_EXISTS = 183 $occurenceName=StringReplace($occurenceName,"\", ""); to avoid error ; Local $handle = DllCall("kernel32.dll", "int", "CreateSemaphore", "int", 0, "long", 1, "long", 1, "str", $occurenceName) Local $handle = DllCall("kernel32.dll", "int", "CreateMutex", "int", 0, "long", 1, "str", $occurenceName) Local $lastError = DllCall("kernel32.dll", "int", "GetLastError") If $lastError[0] = $ERROR_ALREADY_EXISTS Then If $flag = 0 Then Exit -1 Else SetError($lastError[0]) Return 0 EndIf EndIf Return $handle[0] EndFunc; _Singleton() Func Quit() $ans = MsgBox(262145, "Screen Capture", "Files are saved in " & $dest & @CRLF & "Do you really want to quit?") If $ans = 1 Then Exit EndFunc ;==>Quit Func OnAutoITExit() FileDelete(@TempDir & "\captdll.dll") EndFunc ;==>OnAutoITExit Edited June 22, 2006 by ChrisL [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
Helge Posted June 22, 2006 Share Posted June 22, 2006 The label now updates when slider changes value, storing that value in $quality_last, which will be used to check if the slider has changed next time. expandcollapse popup#include <GuiConstants.au3> ;only allow 1 running copy if _Singleton("MultiScreenDump3",1) = 0 Then MsgBox(262144, "Error", "Screen Capture is already running") Exit EndIf ;install Dll FileInstall("captdll.dll", @TempDir & "\captdll.dll", 1) ;set initial global settings Global $count = 1, $dest = @ScriptDir, $quality = "100", $ext = "JPG" , $useButtonGui = 1 Dim $quality_last = $quality ;instructions for user MsgBox(262144, "Screen Capture", "Press ""F1"" to change settings at any time" & @CRLF & _ "Press ""PrintScreen"" to capture whole screen" & @CRLF & _ "Press ""Alt"" + ""Printscreen"" to capture active window" & @CRLF & _ "Press ""escape"" to quit") ;build the button Gui $buttonGui = GuiCreate("ScreenButtons", 120, 120,@DesktopWidth -170, @desktopheight -210 , $WS_POPUP, $WS_EX_TOPMOST) $button1 = GuiCtrlCreateButton ("Screen",0,0,60,60) $button2 = GuiCtrlCreateButton ("Active",61,0,60,60) $button3 = GuiCtrlCreateButton ("Setup",0,61,60,60) $button4 = GuiCtrlCreateButton ("Quit",61,61,60,60) GuiSetState(@SW_Hide,$buttonGui) ;bring up settings dialogue and activate hotkeys Settings() While 1 If $usebuttonGui = 1 then ButtonGui() Sleep(100) WEnd Func Settings() HotKeySet("{PRINTSCREEN}", "Capture") HotKeySet("!{PRINTSCREEN}", "AreaCapture") HotKeySet("{ESC}", "Quit") HotKeySet("{F1}", "Settings") $main = GUICreate("Screen capture settings", 392, 178, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS), $WS_EX_TOPMOST) $outputLabel = GUICtrlCreateLabel("Output Directory", 10, 15, 180, 20) $OutputDir = GUICtrlCreateInput("", 10, 40, 290, 25) GUICtrlSetData(-1, $dest) $Browse = GUICtrlCreateButton("Browse", 320, 40, 60, 25) $Combo = GUICtrlCreateCombo("JPG", 20, 75, 80, 61) GUICtrlSetData(-1, "BMP", $ext) $QualitySlide = GUICtrlCreateSlider(10, 100, 365, 30) GUICtrlSetLimit($QualitySlide, 100, 1) GUICtrlSetData($QualitySlide, $quality) If $ext = "BMP" then GuiCtrlSetState ($QualitySlide, $GUI_Disable) $SliderLabel = GUICtrlCreateLabel("Quality " & $quality, 300, 80, 120, 20) $OSButtons = GUICtrlCreateCheckbox ("Use on screen capture buttons", 20,140) If $useButtonGui = 1 then GuiCtrlSetState ($OSButtons, $GUI_CHECKED) $done = GUICtrlCreateButton ("Continue",260,140,120,25) GUISetState() While 1 $msg = GUIGetMsg() $curinfo = GUIGetCursorInfo() Select Case $msg = $GUI_EVENT_CLOSE $dest = GUICtrlRead($OutputDir) If StringRight($dest, 1) = "\" Then $dest = StringTrimRight($dest, 1) If Not FileExists ($dest) then DirCreate ($dest) $quality = GUICtrlRead($QualitySlide) $ext = GUICtrlRead($Combo) If Bitand (GUICtrlRead ($OSButtons), $GUI_Checked) Then $useButtonGui = 1 Else $useButtonGui = 0 Endif GUIDelete($main) Exitloop Case $msg = $done $dest = GUICtrlRead($OutputDir) If StringRight($dest, 1) = "\" Then $dest = StringTrimRight($dest, 1) If Not FileExists ($dest) then DirCreate ($dest) $quality = GUICtrlRead($QualitySlide) $ext = GUICtrlRead($Combo) If Bitand (GUICtrlRead ($OSButtons), $GUI_Checked) Then $useButtonGui = 1 Else $useButtonGui = 0 Endif GUIDelete($main) Exitloop Case $msg = $Browse WinSetOnTop($main,"",0) GuiSetState (@SW_Disable, $main) $dest = FileSelectFolder("Select a destination", "", 1) If $dest = "" then $dest = @scriptDir GUICtrlSetData($OutputDir, $dest) GuiSetState (@SW_Enable, $main) WinSetOnTop($main,"",1) Case $msg = $Combo If GUICtrlRead($Combo) = "BMP" Then GUICtrlSetState($QualitySlide, $GUI_Disable) GUICtrlSetData($SliderLabel, "Quality N/A") $quality = "-1" $ext = "BMP" Else GUICtrlSetState($QualitySlide, $GUI_Enable) $quality = GUICtrlRead($QualitySlide) GUICtrlSetData($SliderLabel, "Quality " & $quality) EndIf Case GUICtrlRead($QualitySlide) <> $quality_last $quality = GUICtrlRead($QualitySlide) $quality_last = $quality GUICtrlSetData($SliderLabel, "Quality " & $quality) $ext = "JPG" Case Else ;;; EndSelect WEnd ;Exit EndFunc;==>Settings Func ButtonGui() GuiSetState(@SW_Show,$buttonGui) While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button1 Capture() Case $msg = $Button2 AreaCapture() Sleep (100) Case $msg = $Button3 GuiSetState(@SW_Hide,$buttonGui) Send ("{F1}") ExitLoop Case $msg = $Button4 Send ("{ESC}") Case Else If not BitAnd (WinGetState ($buttonGui),8) then WinSetOnTop ($buttonGui,"",1) ;;; EndSelect WEnd EndFunc Func Capture() If $useButtonGui = 1 then WinSetState ($buttonGui,"",@SW_MINIMIZE) GuiSetState (@SW_HIDE, $buttonGui) Endif If FileExists($dest & "\image_" & $count & "." & $ext) <> 0 Then Do $count += 1 Until FileExists($dest & "\image_" & $count & "." & $ext) = 0 EndIf DllCall(@TempDir & "\captdll.dll", "int", "CaptureScreen", "str", $dest & "\image_" & $count & "." & $ext, "int", $quality) $count += 1 If $useButtonGui = 1 then Sleep (100) GuiSetState (@SW_SHOW, $buttonGui) WinSetState ($buttonGui,"",@SW_Restore) Endif EndFunc;==>Capture Func AreaCapture() If $useButtonGui = 1 then WinSetState ($buttonGui,"",@SW_MINIMIZE) GuiSetState (@SW_HIDE, $buttonGui) Endif If FileExists($dest & "\image_" & $count & "." & $ext) <> 0 Then Do $count += 1 Until FileExists($dest & "\image_" & $count & "." & $ext) = 0 EndIf $active = WinGetHandle ("") $cords = WinGetPos($active) If IsArray($cords) Then DllCall(@TempDir & "\captdll.dll", "int", "CaptureRegion", "str", $dest & "\image_" & $count & "." & $ext, "int", $cords[0], "int", $cords[1], "int", $cords[2], "int", $cords[3], "int", $quality) $count += 1 EndIf If $useButtonGui = 1 then Sleep (100) GuiSetState (@SW_SHOW, $buttonGui) WinSetState ($buttonGui,"",@SW_Restore) Endif EndFunc;==>AreaCapture Func _Singleton($occurenceName, $flag=0) Local $ERROR_ALREADY_EXISTS = 183 $occurenceName=StringReplace($occurenceName,"\", ""); to avoid error ; Local $handle = DllCall("kernel32.dll", "int", "CreateSemaphore", "int", 0, "long", 1, "long", 1, "str", $occurenceName) Local $handle = DllCall("kernel32.dll", "int", "CreateMutex", "int", 0, "long", 1, "str", $occurenceName) Local $lastError = DllCall("kernel32.dll", "int", "GetLastError") If $lastError[0] = $ERROR_ALREADY_EXISTS Then If $flag = 0 Then Exit -1 Else SetError($lastError[0]) Return 0 EndIf EndIf Return $handle[0] EndFunc; _Singleton() Func Quit() $ans = MsgBox(262145, "Screen Capture", "Files are saved in " & $dest & @CRLF & "Do you really want to quit?") If $ans = 1 Then Exit EndFunc;==>Quit Func OnAutoITExit() FileDelete(@TempDir & "\captdll.dll") EndFunc;==>OnAutoITExit Link to comment Share on other sites More sharing options...
ChrisL Posted June 22, 2006 Author Share Posted June 22, 2006 Wow Thank you Helge, so simple when you know how hey [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
Helge Posted June 22, 2006 Share Posted June 22, 2006 No problem ! About those AutoIt-tags, it's most likely just Jon who's updating the forums... 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