dcsimg
Results 1 to 9 of 9

Thread: Increment number and graphical effects by push on USB big red button

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2018
    Posts
    5

    Lightbulb Increment number and graphical effects by push on USB big red button

    Hello,

    We are organizing a running contest by night.
    We are spending 1 per person per round for charity.

    I want to set up a big screen at the finish line with a big USB panic button connected to it.

    Name:  TTM_017-large.jpg
Views: 253
Size:  15.6 KB

    Every time a runner finishes one round he pushes the button and the number on the screen has to increment with some animation effects ;-) and sound !

    Can anyone point me in the right direction how to accomplish this with Powerpoint and macros/VB ? Should be possible I suppose ?

    thank you !

    Olivier

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    23,819

    Re: Increment number and graphical effects by push on USB big red button

    is a button push effectively a mouse click or what does event does it do?
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3

    Thread Starter
    New Member
    Join Date
    Oct 2018
    Posts
    5

    Re: Increment number and graphical effects by push on USB big red button

    Yes can be a click or keypress event

  4. #4
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    4,636

    Re: Increment number and graphical effects by push on USB big red button

    So, your question is probably about how to increment a value, do an animation and make sound within Powerpoint, not how to process the event?
    Or, perhaps it seems more likely now, you want an example of how to do all four things {1: handle an event, 2: increment a value, 3: do an animation and 4roduce a sound}.
    (and perhaps a fifth thing, how to run it).

  5. #5

    Thread Starter
    New Member
    Join Date
    Oct 2018
    Posts
    5

    Re: Increment number and graphical effects by push on USB big red button

    Well, yeah that's pretty much it ;-)

    The button gives a mouse click so I have to handle the OnClick Event. A mouse click also let's the presentation jump to the next slide so I have to catch this one and disable it.
    I thought maybe someone knows that this has already been done and knows of an example...
    Or someone can easily point out how to accomplish this.

    Thank you anyhow for your help,

    Olivier

  6. #6

    Thread Starter
    New Member
    Join Date
    Oct 2018
    Posts
    5

    Re: Increment number and graphical effects by push on USB big red button

    bump

  7. #7
    PowerPoster
    Join Date
    Dec 2004
    Posts
    23,819

    Re: Increment number and graphical effects by push on USB big red button

    my guess is a keypress would be easier, but found an example for working with a mouseclick

    as office applications have not onkeypress or onmouseclick events, you would have to use APIs as in the link below

    if you want to test the code make sure to read the disclaimer and take note of the warnings

    you might be better to build an application in .net, or VB6 that can automate powerpoint, rather than using VBA

    https://stackoverflow.com/questions/...s-in-excel-vba
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  8. #8

    Thread Starter
    New Member
    Join Date
    Oct 2018
    Posts
    5

    Re: Increment number and graphical effects by push on USB big red button

    I found this:

    http://www.vbforums.com/showthread.p...PI(Window-API)

    This should be possible for powerpoint?

  9. #9
    PowerPoster
    Join Date
    Dec 2004
    Posts
    23,819

    Re: Increment number and graphical effects by push on USB big red button

    yes that should be possible, but you would have to use an API timer as there is no timer control in VBA, i have posted examples of using API timer in this forum before, it is fairly easy to use,

    here is an example
    in a module
    Code:
    Public Declare Function SetTimer Lib "user32" ( _
    ByVal HWnd As Long, ByVal nIDEvent As Long, _
    ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
    
    Public Declare Function KillTimer Lib "user32" ( _
    ByVal HWnd As Long, ByVal nIDEvent As Long) As Long
    Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
    
    
    Public TimerID As Long, TimerSeconds As Single, tim As Boolean
    Dim Counter As Long
    Dim countdown As Double
    
    
    '~~> Start Timer
    Sub StartTimer()
        '~~ Set the timer for 1 second
        
        TimerSeconds = 1
        TimerID = SetTimer(0&, 0&, TimerSeconds * 1000&, AddressOf TimerProc)
    End Sub
    
    '~~> End Timer
    Sub EndTimer()
        On Error Resume Next
        KillTimer 0&, TimerID
    End Sub
    
    Sub TimerProc(ByVal HWnd As Long, ByVal uMsg As Long, _
    ByVal nIDEvent As Long, ByVal dwTimer As Long)
        Dim iKey As Integer
        For iKey = 3 To 255
            If GetAsyncKeyState(iKey) Then Caption = "KeyCode: " & iKey & " was pressed."
        Next
    End Sub
    you would need to call starttimer from somewhere and endtimer when finished, also change the value of timerseconds to suit if 1 second intervals is too great
    there may be some surplus variables and code, in the above, from previous examples
    Last edited by westconn1; Oct 22nd, 2018 at 03:23 PM.
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width