Jump to content

Search the Community

Showing results for tags 'guisetonevent'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • Forum FAQ
  • AutoIt

Calendars

  • Community Calendar

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 3 results

  1. Hi, I have a problem with GUICtrlCreatePic(). In topic WMPlayer.ocx how to change the shuttle picture? I wanted to replace the shuttle picture with a custom one (which I sent below the code) but got some weird results. #include <GuiConstants.au3> #include <Misc.au3> Global $Paused = False, $SliderButton = @ScriptDir & "\SliderButton.jpg" $hGui = GUICreate("Music Player", 400, 75, -1, -1) $Label1 = GUICtrlCreateButton("", 0, 0, 400, 20) ;music name GUICtrlSetState(-1, $GUI_DISABLE) $Shuttle = GUICtrlCreatePic($SliderButton, 0, 6, 30, 13) $PauseButton = GUICtrlCreateButton("Pause", 208, 40, 80, 20) GUISetOnEvent($PauseButton, "PauseButton") $PlayButton = GUICtrlCreateButton("Play", 112, 40, 80, 20) $Progress = GUICtrlCreateLabel("0:00", 4, 25, 45, 20, $SS_LEFT) ; current media position $Length = GUICtrlCreateLabel("0:00", 350, 25, 45, 20, $SS_RIGHT) ; media length GUISetState(@SW_SHOW) $FilePath = "" ;your music path & .mp3 $oPlayer = ObjCreate("WMPlayer.OCX") If Not IsObj($oPlayer) Then MsgBox(0, "WMPlayer.OCX", "Cannot create a WMP object.", 5) GUIDelete($hGui) Exit EndIf $iPos = 0 ; x coordinate of $Shuttle control in progress bar $hDLL = DllOpen("user32.dll") ; to dectect mouse down on the $Shuttle control $sliderLength = 380 ; in pixels $adlibInterval = 250 ; in milliseconds $oPlayer.Settings.Volume = 100 While 1 $oPlayer.URL = $FilePath $hTimer = TimerInit() While $oPlayer.playState <> 3 ; 1 - stopped, 2 - paused, 3 - playing If TimerDiff($hTimer) > 3000 Then MsgBox(0, "WMPlayer.OCX", $FilePath & @CRLF & @CRLF & "Cannot play this file.", 5) ExitLoop EndIf Sleep(5) WEnd If $oPlayer.playState <> 3 Then ContinueLoop EndIf $sFile = StringMid($FilePath, StringInStr($FilePath, "\", 0, -1) + 1) GUICtrlSetData($Label1, $sFile) $mediaLength = Int($oPlayer.currentMedia.Duration) ; in seconds GUICtrlSetData($Length, Int($mediaLength / 60) & ":" & StringFormat("%02i", Mod($mediaLength, 60))) AdlibRegister("Slider", $adlibInterval) $oPlayer.Controls.Pause While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE $oPlayer.Close Exit Case $PlayButton If GUICtrlRead($PlayButton) = "Play" Then $oPlayer.Controls.Play AdlibRegister("Slider") GUICtrlSetData($PlayButton, "Stop") Else $oPlayer.Controls.currentPosition = 0 $oPlayer.Controls.Pause GUICtrlSetData($PlayButton, "Play") EndIf If $Paused Then While $Paused Sleep(100) WEnd EndIf Case $Shuttle AdlibUnRegister() $x = MouseGetPos(0) $xOffset = $x - $iPos While _IsPressed("01", $hDLL) = 1 $x = MouseGetPos(0) If $x > 380 + $xOffset Then $x = 380 + $xOffset ElseIf $x < $xOffset Then $x = $xOffset EndIf $iPos = $x - $xOffset GUICtrlSetPos($Shuttle, $iPos) Sleep(1) WEnd $mediaPos = $iPos / $sliderLength * $mediaLength $oPlayer.Controls.currentPosition = $mediaPos AdlibRegister("Slider", $adlibInterval) GUICtrlSetData($PauseButton, "Pause") EndSwitch If $oPlayer.playState = 1 Then ExitLoop EndIf WEnd WEnd Func PauseButton() If $Paused = False Then $oPlayer.Controls.Pause AdlibUnRegister() $Paused = True GUICtrlSetData($PauseButton, "Resume") Else $oPlayer.Controls.Play AdlibRegister("Slider") $Paused = False GUICtrlSetData($PauseButton, "Pause") EndIf EndFunc ;==>PauseButton Func Slider() $mediaPos = $oPlayer.Controls.currentPosition $iPos = $mediaPos * $sliderLength / $mediaLength GUICtrlSetPos($Shuttle, $iPos) GUICtrlSetData($Progress, Int($mediaPos / 60) & ":" & StringFormat("%02i", Mod($mediaPos, 60))) EndFunc ;==>Slider Also how can I set buttons to act like OnEvent button? I tried for $PauseButton but didn't make it. So I didn't do it for $PlayButton and $Shuttle. I want to add some lines from my main source to $PlayButton and since I used while loop in those lines (while the song is not over), I should control song (Pause/Resume, adjust position) anytime I want.
  2. Hello everybody I need help with Opt("GUIOnEventMode",1) I Normally use GUIGetMsg() but I want to learn how GUIOnEventMode works so I created a little test GUI the start button works fine and everything but the problem is that the stop button won't work down below is the code I made and I'm wondering if someone with experience can explain me and the rest o newbies how it works and also if can post the code already fixed #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <ProgressConstants.au3> #include <WindowsConstants.au3> $Stop = False $X=1 $i = 0 Opt("GUIOnEventMode",1) #Region ### START Koda GUI section ### Form= Global $Form1 = GUICreate("Form1", 579, 212, 192, 124) Global $Button1 = GUICtrlCreateButton("Stop", 432, 136, 75, 25) Global $Button2 = GUICtrlCreateButton("Start", 96, 136, 75, 25) Global $Progress1 = GUICtrlCreateProgress(24, 40, 526, 49) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### GUISetOnEvent ($GUI_EVENT_CLOSE, "_exit",$Form1 ) GUICtrlSetOnEvent($Button1,"_Stop") GUICtrlSetOnEvent($Button2,"DecreaseAndIncrement") While 1 sleep(500) WEnd Func _Stop () $Stop = True EndFunc Func _exit () Exit EndFunc Func DecreaseAndIncrement () $Stop = False While $Stop = False $i+=$X ;ConsoleWrite($i & @CRLF) GUICtrlSetData($Progress1,$i) Sleep(80) if $i = 105 Then $X = -1 if $i = 0 Then $X = 1 WEnd EndFunc here is the version that works with GUIGetMsg() #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <ProgressConstants.au3> #include <WindowsConstants.au3> $Stop = False $X=1 $i = 0 #Region ### START Koda GUI section ### Form= Global $Form1 = GUICreate("Form1", 579, 212, 192, 124) Global $Button1 = GUICtrlCreateButton("Stop", 432, 136, 75, 25) Global $Button2 = GUICtrlCreateButton("Start", 96, 136, 75, 25) Global $Progress1 = GUICtrlCreateProgress(24, 40, 526, 49) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button2 DecreaseAndIncrement () case $Button1 $Stop = True EndSwitch WEnd Func DecreaseAndIncrement () $Stop = False While $Stop = False $i+=$X ;ConsoleWrite($i & @CRLF) GUICtrlSetData($Progress1,$i) Sleep(80) if $i = 105 Then $X = -1 if $i = 0 Then $X = 1 $nMsg2 = GUIGetMsg() Switch $nMsg2 Case $GUI_EVENT_CLOSE Exit case $Button1 $Stop = True EndSwitch WEnd EndFunc
  3. here I am writing simple gui with text processing capabilities. i have main gui, background picture, all buttons with labels over them 2 static buttons (1 present here) Opt("GUIOnEventMode", 1) and includes $main = GUICreate("Title", 961, 721); Main Window $bgpic = GUICtrlCreatePic(@WorkingDir & "\960x720.jpg", 0, 0, 960, 720); use background picture $quitBtn = GUICtrlCreateButton("Quit", 885, 685, 95, 40) GUICtrlSetOnEvent($quitBtn, "_exit"); assign quit button to function "exit" _GuiCtrlMakeTrans(-1, 1) $quitLabel = GUICtrlCreateLabel("Quit", 885, 685, 95, 40, BitOR($SS_CENTER, $BS_BOTTOM)) GUICtrlSetFont(-1, 14, 400, 0, "Tahoma") GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) GUICtrlSetColor(-1, 0x962129) GUISetState(@SW_SHOW) then i have the code for creating buttons dynamically from information in file Dim $Button[$NumberFromText] $startX = 48 $startY = 24 $fromLeft = 240 $bHeigh = 160 $bWidth = 50 Dim $1to4btn[0] For $x = 0 To _Min(UBound($Button) - 1, 3) ; creates maximum 4 button, label $Button = GUICtrlCreateButton($x, $startX, $startY, $bHeigh, $bWidth); create buttons _GuiCtrlMakeTrans(-1, 1) ; transparency 255 Solid, 0 Transparent $serverLabel = GUICtrlCreateLabel(FileReadLine($configF, $SN), _ ; read 1st line and 5 below on each iteration $startX, $startY, $bHeigh, $bWidth, BitOR($SS_CENTER, $SS_CENTERIMAGE, $WS_EX_TRANSPARENT)); GUICtrlSetFont(-1, 14, 400, 0, "Tahoma"); set font and size GUICtrlSetColor($serverLabel, 0x04A111); set color of font GUICtrlSetBkColor($serverLabel, $GUI_BKCOLOR_TRANSPARENT); make label Background transparent $SN += 5; read 5 lines below $startX = $startX + $fromLeft $btnArray=_ArrayAdd($1to4btn, GUICtrlGetHandle($Button)) Next since buttons are created under the label $Button and I couldn't conacenate $Button[$i] , I created array and place handles into it and connected static buttons with GUICtrlSetOnEvent($cancelBtn,"cancelFunc") and it worked now i tried using handles to assign functions to buttons but it fails with GUICtrlSetOnEvent() also tried GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "funcForFirstButton", $1to4btn[0]) if I assign without handle it works by clicking anywhere on MainGUI While loop includes only sleep(10) Window starts as inactive and return code 7 If i click dynamically created buttons, window loses focus . clicking anywhere else focuses window this is _GuiCtrlMakeTrans function (found here on forums some time ago) also created simple button on the same mainGUI and tried but didn't work $try=GUICtrlCreateButton("TRY",250,150,100,35) GUICtrlSetOnEvent(-1,"FunctionOne") ; shows messagebox and write console
×
×
  • Create New...