Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > .NET Languages
You last visited: Today at 06:54

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



pressing a hotkey while the program is not focused(minimized)

Discussion on pressing a hotkey while the program is not focused(minimized) within the .NET Languages forum part of the Coders Den category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Feb 2013
Posts: 865
Received Thanks: 139
pressing a hotkey while the program is not focused(minimized)

Hello guys i want to do a simple program it could be usefull to me i want to make a textbox and insert a text in it then copy it via button and paste via hotkey
i have written the code and done it but the problem in the hotkey is working only inside the Form not outside as i intend to do can someone help me since i am a begginer in coding ?

Quote:
Public Class Form1
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vkey As Long) As Integer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Copy.Click
If TextBox1.SelectedText <> "" Then
Clipboard.SetText(TextBox1.SelectedText)
End If
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim iData As IDataObject = Clipboard.GetDataObject()
If iData.GetDataPresent(DataFormats.Text) Then
TextBox1.SelectedText = CType(iData.GetData(DataFormats.Text), String)
Else
MsgBox(")
End If
End Sub

Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
If e.KeyCode = Keys.F8 Then
Button2.PerformClick()
End If
End Sub


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
KeyPreview = True
End Sub

End Class
iontzel222 is offline  
Old 12/13/2015, 14:00   #2
 
elite*gold: 0
Join Date: Aug 2011
Posts: 159
Received Thanks: 57
You need to register the hotkey(s) you want to use. Here is an example

PHP Code:

Imports System
.Runtime.InteropServices

Public Class Form1
    
Public Const WM_HOTKEY As Integer = &H312

    
<DllImport("User32.dll")> _
    
Public Shared Function RegisterHotKey(ByVal hwnd As IntPtr_
                        ByVal id 
As IntegerByVal fsModifiers As Integer_
                        ByVal vk 
As Integer) As Integer
    End 
Function

    <
DllImport("User32.dll")> _
    
Public Shared Function UnregisterHotKey(ByVal hwnd As IntPtr_
                        ByVal id 
As Integer) As Integer
    End 
Function

    Private 
Sub Form1_Load(sender As System.ObjectAs System.EventArgsHandles MyBase.Load
        RegisterHotKey
(Me.Handle1000Keys.F8)
    
End Sub

    
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
        If 
m.Msg WM_HOTKEY Then
            Dim id 
As IntPtr m.WParam
            Select 
Case (id.ToString)
                Case 
"100"
                    
MsgBox("lol")
            
End Select
        End 
If
        
MyBase.WndProc(m)
    
End Sub
End 
Class 
BeginnerDO is offline  
Old 12/13/2015, 14:53   #3
 
elite*gold: 0
Join Date: Feb 2013
Posts: 865
Received Thanks: 139
great thank you very much instead the code in button 2 i used this
If iData.GetDataPresent(DataFormats.Text) Then
SendKeys.Send("^v")
guess that works too thank you again
iontzel222 is offline  
Old 12/14/2015, 21:13   #4
 
iBanq's Avatar
 
elite*gold: 21
Join Date: Aug 2014
Posts: 245
Received Thanks: 38
There's a very simple method.
Just use the GetAsyncKeyState-API:

PHP Code:
Declare Function GetAsyncKeyState Lib "user32.dll" (ByVal nVirtKey As Keys) As Short 
to use it just put this into a button or timer:

PHP Code:
If GetAsyncKeyState(ASCII Code of the Key) = -32767 Then 
a link of ASCII keys F1-F12.
iBanq is offline  
Old 12/20/2015, 16:13   #5
 
elite*gold: 0
The Black Market: 229/0/0
Join Date: Mar 2014
Posts: 2,790
Received Thanks: 6,655
Code:
'Under Public Class Form1
Declare Function GetAsyncKeyState Lib "user32.dll" (ByVal nVirtKey As Keys) As Short

'Put this in a timer or in a Loop
If GetAsyncKeyState(Keys.F8) = -32767 Then
'Do the stuff what you want to do
End If
anonymous-29742 is offline  
Reply


Similar Threads Similar Threads
★Hotkey Creator★ Create your own hotkey executing your preferred action
05/01/2015 - Coding Releases - 2 Replies
Deutsch Ich möchte dir meinen Hotkey Creator v 1.0 vorstellen, mit welchem es möglich ist, eigene hotkeys zu definieren, die eine von dir ausgewählte Aktion ausführen. Mögliche Aktionen: - Webseite öffnen - Programm oder Dokument ausführen - Aktives Fenster verstecken - Pfad öffnen - Bildschirm sperren
WTS 40 mil SP PVP focused
06/04/2012 - Eve Online Trading - 0 Replies
sold
[MACRO/AHK source] Minimized hotkey stig/treamheal/shield (1024x768)
06/12/2008 - CO2 Bots & Macros - 3 Replies
Added as attachment the RAR of the precompiled exe, for you lazy bums :P If you want the water tao to follow you around instead of sitting somewhere, then just install and use FollowMe by evan found here: http://www.elitepvpers.com/forum/co2-bots-macros/1 25307-followme-minimized-background.html This source is freely adapted from evan's minimized autostig, and is, in my intentions (you may use it how you prefer tho) a leveling aid for archers with a water companion. Basic settings (that...
How to Fix SRO Closing after Pressing F6
11/20/2007 - SRO Guides & Templates - 4 Replies
Like you have all heard about disabling loopback their is a bit of a trick that has worked for me on multiple length named account Load your bot when the Gameguard screen comes up disable the loopback adapter log in with your name and password like normal when you get to the char select screen press F6 and let it patch select your player and let it load to the game screen minimize the screen and re enable your loopback adapter open the game and start training it should then work +Rep...



All times are GMT +1. The time now is 06:54.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.