Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Hotkeys hot off the forms


Exvayate
 Share

Recommended Posts

Damn I ask a bunch of questions. But it's okay because this can help the community as well!

So here I have created a command which toggles the window on picInventory:

```
Private Sub picInvButton_Click()
            If picInventory.Visible = False Then
                ' show the window
                picInventory.Visible = True
                BltInventory
                ' play sound
                PlaySound Sound_ButtonClick
                Else
                picInventory.Visible = False
                ' play sound
                PlaySound Sound_ButtonClick
            End If
End Sub
```
Here I have set the hotkey in which executes the previous window toggling command:

```
Private Sub picInvButton_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = vbKeyI Then
        picInvButton_Click
    End If
End Sub

```
But when I login to my game and immediately press the hotkey, I, it does NOT open picInventory like I told the program to.

However when I click on the button to open picInventory AND THEN press the hotkey, I, only then will the hotkey toggle the Inventory window.

I have also created hotkeys for the other buttons for the other windows (Spells/Options/Character/Equipment)

But the same situation occurs, where those windows cannot be toggled unless they've been previously clicked.

ALSO! After clicking all of the windows to be able to "set" the hotkeys, will NOT allow you to press hotkey I and then S to toggle both windows. So the ONLY way the window can be toggle is clicking it first, then press the key. Then if you wanted to toggle another window, you HAVE to do the same process.

I could use some help on how I can be able to press the keys and have all of them toggle as SOON as I enter the game.
Link to comment
Share on other sites

Edited: Sorry man, I was about to edit this and then my internet dropped, I misread your question..
You need to call for the hotkeys inside the picscreen (Which picscreen is already is calling hotkeys inside modInput - CheckInputKeys … Which you can place your code inside.)

But as well, you have to make the Private declarations Public of all of your buttons.
Such as Private Sub picInvButton_Click()
Would be Public Sub picInvButton_Click()

And repeat that for all of the private subs you're trying to call from the module.
Link to comment
Share on other sites

I placed my code, under ModInput > CheckInputKeys
As well as changing all private subs to public

```
KeyPreview = True
    If KeyCode = vbKeyI Then
        picInvButton_Click
    End If
```
And it gave me error: variable undefined

I even tried mimiciing robin's stick code like this:
```
    If GetKeyState(vbKeyI) < 0 Then
        picInvButton_Click = True
    End If
```
Whyyyyy am I not doing this right? -_-
Link to comment
Share on other sites

I think you can only call a click event by clicking it, just make a new sub with :
```
If picInventory.Visible = False Then
                ' show the window
                picInventory.Visible = True
                BltInventory
                ' play sound
                PlaySound Sound_ButtonClick
                Else
                picInventory.Visible = False
                ' play sound
                PlaySound Sound_ButtonClick
            End If
```in it and make it call that sub, that must work.
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...