Press ALT Key In Any Application Whenever LEFT Mouse Button Is HOLD.
If anyone would have a ready code for this please reply with the code, i will gladly appreciate it, many many tanks in advance.
I wanna Run a VB app in the background. Then it will capture the LEFT MOUSE BUTTON HOLD.
SO whenever the LEFT MOUSE button is hold the "ALT KEY" should be hold too.
The purpose is that i am doing drafting in an application Called Unigraphics. And whenever i place a dimension i have to drag it with the mouse left button and press "ALT KEY" so it doesn't SNAP.
If i can run the VB app and capture the left mouse button and trigger ALT, then i don't have to press the ALT key anymore.
Any help would be really really appreciated, big big thanks!
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Press And Hold Command Button Repeats
Hello Forum,
I have a simple (I hope) question. When I press a command button, I would like the function it is programmed to do to repeat as long as the button is click and held. I can't seem to find a function to do this.
Thanks for the help.
Move The Mouse Courser And Press Left Mousebutton?
If I wanna move the mousecourser on my screen to the position 507, 294 (my resolution is 1024x768) and then press left mousebutton. How do i write the code?
Or, if it's possible, go to a button (in a externial program) and then press enter.
Hold Mouse Button Down
soz for not being more efficent with the search function
but im trying to figure out how to hold the left mose botton down for a period of time and all i can manage to do it make it press then sleep , then press etc.
could some1 send me some useful code or a working example pllzzz
ty
edit: btw i wish to hold the right mouse button down not the left ^^ ty
Code:
For i = 0 To 30
mouse_event MOUSEEVENTF_LEFTDOWN Or MOUSEEVENTF_LEFTUP, 0&, 0&, cButt, dwEI
Sleep 200
Next i
Hold Down & Move Mouse Button, Form A Rectangle (like On Desktop)
All in the topic title. I have a form, and I want to be able to hold my mouse button and form a 'rectangle'.. then I want to be able to get the .Top/.Left of all 4 corners.
Like on your desktop, how you can drag your mouse to form a rectangle, and all the icons within this rectangle gets selected..
Mouse Button Press
Hey guys im making a game. Anyway Im at the point now where I need to know how to tell how long the left mouse button has been pressed down for on my form. Can anyone point me in a general direction. Thanks
How To Detect Mouse Left/right Button?
I have created an app to display a balloon from a system tray application, and need to detect when someone left or right clicks upon the app. My code is pasted below, and the problem is in the line "If MouseButtons = MouseButtons.Left Then ...", the compiler barfs with:
Warning1: Access of shared member, constant member, enum member or
nested type through an instance; qualifying expression will not be evaluated.
Could someone advise, even just tell me where to locate the documentation that tells me how to do this... thanks.
BTW, I am using Visual Studio 2005, and am not a VB expert at all!!
Private Sub nIcon_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles nIcon.Click
'Handle a single-click on the system tray icon
Dim strComputer
Dim strUser
Dim strIP
Dim strMachineInfo
MessageBox.Show("Called Single Click Handler", "Debug", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
If MouseButtons = MouseButtons.Left Then
' Leftlick: Check for new files, and process them accordingly
MessageBox.Show("LEFT", "DEBUG", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End If
If MouseButtons = MouseButtons.Right Then
' RightClick: Display Machine Information
strComputer = System.Environment.MachineName
strUser = System.Environment.UserName
strIP = System.Net.Dns.GetHostEntry(strComputer).AddressList(0).ToString()
strMachineInfo = "Computer Name: " & strComputer & vbCrLf & "User Name: " & strUser & vbCrLf & "IP Address: " & strIP
nIcon.ShowBalloonTip(3000, "ControlCentre", strMachineInfo, 1)
End If
End Sub
What Is The Inkey For Mouse Button Left?
Could anyone please tell me the variable that stands for the left mouse button click..heres alittle more info on what im doing
for school i am just making a simple shooting game and i have the mouse pointer set to a cross
under form1_mousemove i have:
if Button = vb________ then
blah blah
end if
in the blank...what would i put to say LEFT MOUSE BUTTON CLICK???
thanks in advnaced
How To Determine Which Mouse Button Is Left Or Right?
Hello,
I have a program in which I am display the current button status of the mouse similar to the way it is in the control panel of Windows. What code do I need to determine the current status of the mouse (i.e. - left button for left click).
Thanks!
Emulate Left Mouse Button
This is for a school project. I'm building a program that receives a number from the serial port. If that number is number 4, for example, it simulates the left mouse button. So, if the mouse is over a command button, and the serial port receives the number 4, the command button will be selected (activated), as if it was clicked with the mouse. So far, all I can do is receiving that number from the serial port, through a microcontroller. The number is well sent to the PC, I've tested it. So far so good. What I can't do is simulating the mouse click, the left button. I've searched through Visual Basic 6.0 help, but can't figure out what to do! Should I use an API?? Can someone help me?? Thank you.
P.S.: Here is my program. The toggle button is to open/close the serial port. I'm reading the buffer from the serial port in a text box (more simple). Then I compare it to number 4. If it's true, how do I simulate the mouse click?? It will help if someone knows how to simulate if number 4 is pressed from keyboard, for example. The objective is to simulate the left mouse button...without using the mouse!!
Is There A Command For Left Mouse Button
Hi
Could anyone tell me if there is a command which will recongnise a simple
mouse click anywhere on the screen, I can do it ok for a command box etc etc
but would like to be able to simply click a mouse button from anywhere on
the screen.
Thanking You In Advanced
Pete
Counting Mouse Left Button Clicks
In VB6 is there a way to count mouse left clicks? For example I would like to just have a form that resides in the systray that would be able to count the mouse clicks anywhere in Windows. I assume there is an API for this but allapi.net is down. Background info: I'm trying to count the number of mouse clicks so that I know how many pictures I have viewed in a certain program.
Press And Hold F8
I need a simple script that would press f8 and just hold it until i hit the stop button.
Mouse Click.. And Hold
I understand how to emulate a mouse click anywhere on the screen using the Mouse_Event API.
However, is there a way i could simulate a 'Click And Hold' type action outside of my application?
Mouse Hold Move Form
Hey i have created a webcam viewer and it has no border but i want that when people hold there mousebutten on the form the can move it is this posseble?
Hold Button
How can I distinguish between when a user clicks a button vs. holds a button...
Hold Down Cmd Button
How do you make an event repeat while a command button is held down? I need it to scroll focus through text boxes. I've tried various combinations of Mousedown, Mouseup and Click events, but someone out there must do this all of the time. I need it to scroll focus through text boxes.
Command Button Hold Down
How can I keep the appearance of a button in the "down" position until the user clicks on it again? For example, the app has a bunch of buttons grouped together and I want the user to select more than one, and show the selected buttons all as being in the down position until the user releases them back to the up position by clicking on them.
Simulating A Button Press On A Command Button
OK, here we go...
I have a command button that starts a database search. I have set an animation control to show a searchlight while the search is being performed, but want this to appear on the button.
The animation control has been placed over the button, but of course this stops the button being pressed. I have added in the 'click' procedure for the animation, a call to the 'click' procedure for the button, so it functions, but I want the button to look pressed for the duration of the mouse button press on the animation control.
Is there anybody who knows how?
Thanks in advance...
Mouse Press
how can u tell when the mouse has been pressed out side of the form? as in its u can use mosue down for in the form but what about when u press it outside the form?
Mouse.left? (mouse Location)
I am making (trying to make) a real time strategy game with visual basic, and I need help writing code that, when you click, the left and top of the mouse's location where you clicked are displayed in two seperate labels/text boxes/ variables. I tried many things like "label1.caption = mouse.left" + "cursor.left" + "pointer.left". I can't make a label or object in every square because that is too many objects (I think the limit is 200 or something). I also looked it up in the help menu, but it wasn't there. Thanks for your help!
Does VB6 Limit The Number Of COM Reference's An Application Can Hold ?
Hi all,
Ok, first off all I need to clarify that this has been working fine for a few years, the problem appears to be with the work load and not with the code...
I have a standard .exe application that utilises an ActiveX EXE server. The application is used to ping various resources and display on screen the status of the resource dependant upon the result of the ping. The actual pinging of the resource is handled by the ActiveX server.
The ActiveX server provides a single thread-per-object multiuse class interface. Each instance of the class utilises a timer to run in a pseudo-async nature.
The application creates an instance of the ActiveX server's iface per resource ping that is required. The application then passes the target IP, frequency to ping and a timeout to the ActiveX server.
Once all of the needed instances have been created and configured the application calls a "start" procedure on the object that enables the class' internal timer.
When the timer fires in each object, the object pings the resource and then returns a response to the application via a message queue.
Right onto the problem...
I have just added a lot of new resources to monitor, taking the work load from 85 individual pings to around 200.
The problem I have is that when the application attempts to create the 161st instance of the multiuse class, VB spits out an "Out of Memory" error.
I have stepped through the code and the error is thrown when the parent application's thread accesses the 161st instance of the ActiveX's multiuse class. i.e.
CODE'This works fine 161 times...
Set loObject = new MyServer.Pinger
'On the 161st call the Configure routine returns false
'lsErrorMsg contains the "Out of Memory" Error
lbReturn = loObject.Configure(lsConfXML, lsErrorMsg)
Key Press And Mouse Movement
I'm writing program that will automatically 'do something' if the pc has been idle for a certain about of time, sort of like and screen saver.. But this is where I get stuck, how can I make my program know when a key is pressed or the mouse has been moved, so that the idle timer can be restarted.
note: The program will be hidden since its going to be like an screen saver.
Detecting Mouse Movement And Key Press
Ok, can anyone help me with this? I want some code which can detect if the mouse has been moved or a key has been pressed on the keyboard, basically like how a screen saver works if you press a key on the keyboard of move the mouse the screen saver goes off ??
Automated Key Press/mouse Movement
is there a way to simulate the press of a key? (eg: windows key, shift, A, etc..)
if that's not possible, how about this: is there a way to change the coordinates of the mouse and then simulating a click or double click?
Sending Mouse Click And Key Press
Hey, I've got an application where I need to be able to run a program that does a right mouse click then presses number 1 on the numpad where I position the mouse, or alternatively right mouse click then move the mouse to another location and left click on it.
Thanks in advance.
Press 'ESC' To Stop Mouse Playback
I actually need to press a key 'esc' so that the mouse will stop playing back. My code is such that i am opening a file which playing back mouse movement.Is there a api which can help me stop the mouse from playing back ? My mouse playbck code is shown below :
Private Type EVENTMSG
message As Long
paramL As Long
paramH As Long
time As Long
hwnd As Long
End Type
Private Type POINTAPI
x As Long
y As Long
End Type
Private Type MSG
hwnd As Long
message As Long
wParam As Long
lParam As Long
time As Long
pt As POINTAPI
End Type
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Private Declare Function SetWindowsHookEx Lib "user32" Alias "SetWindowsHookExA" (ByVal idHook As Long, ByVal lpfn As Long, ByVal hmod As Long, ByVal dwThreadId As Long) As Long
Private Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As Long) As Long
Private Declare Function CallNextHookEx Lib "user32" (ByVal hHook As Long, ByVal nCode As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Const WH_JOURNALRECORD = 0
Private Const WH_JOURNALPLAYBACK = 1
Private Const HC_GETNEXT = 1
Private Const HC_SKIP = 2
Private Const WH_GETMESSAGE = 3
Private Const WH_CALLWNDPROC = 4
Private Const WM_CANCELJOURNAL = &H4B
Private Const WM_MOUSEMOVE = &H200
Private lHookID As Long
Private lAppHookID As Long
Private tEventList() As EVENTMSG
Private tEVENTMSG As EVENTMSG
Private lMsgCount As Long
Private lMsgCountMax As Long
Public sDat As String
Public Sub RecordMouse()
'Record the Mouse Events
If lHookID <> 0 Then Exit Sub
lMsgCountMax = 0
lMsgCount = 0
ReDim tEventList(0)
'Set an application hook to monitor for messages sent to this app
lAppHookID = SetWindowsHookEx(WH_GETMESSAGE, AddressOf GetMessageProc, App.hInstance, App.ThreadID)
'Set the Journal Hook to allow us to record all Mouse Movements
lHookID = SetWindowsHookEx(WH_JOURNALRECORD, AddressOf JournalRecordProc, 0&, 0&)
Debug.Print "Recording..."
End Sub
Public Sub RecordMouseStop()
'Stop Recording the Mouse Events
If lHookID <> 0 Or lAppHookID <> 0 Then
Call UnhookWindowsHookEx(lAppHookID)
Call UnhookWindowsHookEx(lHookID)
lHookID = 0
lAppHookID = 0
Debug.Print "Recording Stopped - " & lMsgCountMax & " messages recorded."
End If
End Sub
Public Sub PlayBackMouse()
'Playback the Journal Recorded with JournalRecord
If lHookID <> 0 Then Exit Sub
lMsgCount = 1
tEVENTMSG = tEventList(1)
'Set an application hook to monitor for messages sent to this app
lAppHookID = SetWindowsHookEx(WH_GETMESSAGE, AddressOf GetMessageProc, App.hInstance, App.ThreadID)
lHookID = SetWindowsHookEx(WH_JOURNALPLAYBACK, AddressOf JournalPlaybackProc, 0&, 0&)
Debug.Print "Playing..."
End Sub
Public Sub PlayBackMouseStop()
'Stop Journal Playback
If lHookID <> 0 Or lAppHookID <> 0 Then
Call UnhookWindowsHookEx(lAppHookID)
Call UnhookWindowsHookEx(lHookID)
lHookID = 0
lAppHookID = 0
Debug.Print "Playback Stopped."
End If
End Sub
Private Function GetMessageProc(ByVal Code As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Dim tMSG As MSG
If Code < 0 Then
'Pass the message along...
GetMessageProc = CallNextHookEx(lAppHookID, Code, wParam, ByVal lParam)
Else
'Grab the MSG structure
CopyMemory tMSG, ByVal lParam, Len(tMSG)
Select Case tMSG.message
Case WM_CANCELJOURNAL
'An external process has requested us to stop this operation
Call UnhookWindowsHookEx(lHookID)
lHookID = 0
End Select
End If
End Function
Private Function JournalRecordProc(ByVal Code As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
On Error GoTo LogError
If Code < 0 Then
'Pass this message along...
JournalRecordProc = CallNextHookEx(lHookID, Code, wParam, ByVal lParam)
Else
'Grab the Event Message Structure
CopyMemory tEVENTMSG, ByVal lParam, Len(tEVENTMSG)
'Only record MOUSE_MOVE events
If tEVENTMSG.message = WM_MOUSEMOVE Then
lMsgCountMax = lMsgCountMax + 1
ReDim Preserve tEventList(lMsgCountMax)
tEventList(lMsgCountMax) = tEVENTMSG
End If
JournalRecordProc = 0
End If
Exit Function
LogError:
Debug.Print "Error in JournalRecordProc()"
End Function
Private Function JournalPlaybackProc(ByVal Code As Long, ByVal wParam As Long, ByRef lParam As Long) As Long
Dim iX As Integer, iY As Integer, lTime As Long
On Error GoTo LogError
Select Case Code
Case HC_SKIP
'Select the Next Event Message
lMsgCount = lMsgCount + 1
If lMsgCount >= lMsgCountMax Then
'Last Message processed, so remove the Journal Hook
PlayBackMouseStop
Else
tEVENTMSG = tEventList(lMsgCount)
End If
JournalPlaybackProc = 0
Case HC_GETNEXT
'Grab the Event Message Structure and Process the Message
lParam = VarPtr(tEVENTMSG)
With tEVENTMSG
If .message = WM_MOUSEMOVE Then
iX = .paramL
iY = .paramH
'Pause time for processing lag (calculated as time between this and prev. message)
lTime = (.time - tEventList(lMsgCount - 1).time) - 7
'Pause can't be less than 0
If lTime < 0 Then lTime = 0
'Move the Cursor accordingly
SetCursorPos iX, iY
'If this isn't the 1st message pause before processing the next message
If lMsgCount > 1 Then
Sleep lTime
End If
End If
End With
Case Else
'Pass this message along...
JournalPlaybackProc = CallNextHookEx(lHookID, Code, wParam, ByVal lParam)
Exit Function
End Select
Exit Function
LogError:
Debug.Print "Error in JournalPlaybackProc():" & Err.Description, lMsgCount, lMsgCountMax
End Function
Public Sub SaveEvents(ByVal sFilename As String, ByRef tEventArray() As EVENTMSG)
Dim iFile As Integer
Dim lIndex As Long
If Len(Dir(sFilename)) Then Kill sFilename
iFile = FreeFile
Open sFilename For Random Access Write As iFile
For lIndex = LBound(tEventArray) To UBound(tEventArray)
Put #iFile, , tEventArray(lIndex)
Next
Close iFile
End Sub
Public Sub LoadEvents(ByVal sFilename As String, ByRef tEventArray() As EVENTMSG)
Dim iFile As Integer
Dim lIndex As Long
If FileLen(sFilename) = 0 Then Exit Sub
iFile = FreeFile
Open sFilename For Random Access Read As iFile
While Not EOF(iFile)
ReDim Preserve tEventArray(lIndex)
Get #iFile, , tEventArray(lIndex)
lIndex = lIndex + 1
Wend
Close iFile
End Sub
Public Sub SaveTheEvents()
Call SaveEvents("C:Events.dat", tEventList)
End Sub
Public Sub LoadTheEvents()
Call LoadEvents(sDat, tEventList)
lMsgCountMax = UBound(tEventList)
End Sub
Button Press
Hi,
I want to do an action when you press the Enter key on the keyboard - How can I do this?
-Neo
Using A Button To Press A Key..
I have a "Delete" Button on my form. When I press this button i want it to act as if i pressed the Delete key on my keyboard. How would i go about doing this. I tried this but i didnt work.
Code:
sendKeys vbkeydelete
What do I need to do?
Button Press
I was wondering if somebody could tell me how to activate an object (a command button) in my form by simply pressing the downkey. Can somebody help me out, I am pretty new at this.
Button Press
Is there a way to get a webbrowser to press a button using the webbrowser control?
Button Press
Hi,
I've got two command buttons that I use to control the volume of my app.
At the moment the user presses the applicable button and the volume is adjusted either up or down.
I want to allow the user to keep the button pressed down and adjust the volume accordingly rather than having to repeatedly press the button.
Is there a way to do this?
Regards
Button Press
Im making a program to see how often buttons and keys are used in a day...So I need to know code that will add "1" to label1 when "A" is pressed. So if "A" is pressed label1.caption will add 1...so if it was o it would then by 1...ANy ideas thx guys I appreciate it
When I Press A Button It Will Get.. Help Needed
when i press a button it will get the text from the textbox and check how many symbols it is in the text and is it more then 7 it will display error
and if u have 6 it will get the text from the textbox and save it to a txt file
InputBox Button Press
I want to return a result from an InputBox based on the button pressed.
For instance if cancel was pressed I could place an exit sub in an selection structure.
Pseudo Code Example:
Code:
If button input box = "Cancel" Then
Exit Sub
End If
Button Press To Variable
I want to have it to where I press a button say cmdA and have it placed into a string variable such as LETTERS. I also want to put more stuff into the string so that I can place all of that information into a random generator and in a label.
Example if ya don't understand:
cmdA gets clicked and the letter A is added to a string. a few more letters such as B and C are added from cmdB and cmdC being clicked. Another button, cmdDisplay, is pressed and the letters appear in a label called lblDisplay. cmdRandomGeneration is pressed and a random letter from the group is placed into a lbl.
I can create the generator and such, that's easy. I was just wondering if you guys had any ideas on how to do what I said. Thanks for any help in advance!
How To Press A Button Automatically???
hi there,
I've a button, also have its HWND, I just want to press it using code and then repress it after 4 seconds. Its like Pause-Resume case.I cant find how to press a button using code..pls help..
Wait For A Button Press VB6
Hello,
I would like to apologize in advance if this turns out to be a stupid question, but after searching to no avail, I haven't the faintest Idea on how to accomplish this.
Basically, I'm trying to make a helper function, called Wait, that will not let any code proceed until the boolean variable "Ready" is true. This variable is changed by certain buttons being pressed with "Ready = True".
I tried a Do While loop that should have looped until Ready was true, but when I went to run the program, it locked up. I assume because it ended up being a never ending loop.
Next I looked on the internet and found some code that would sleep a program. I tried it, and added that to the loop in hopes of slowing it down, so it would check on the variable and then sleep for 1 second, and repeat. This also locked up, and seems like a bad way to handle this.
I hope that this description was clear, if not don't hesitate to ask for me to elaborate, and thanks in advance to anyone willing to spend a little time helping me out here, No Rush though.
Press Command Button
Hey,all i have program what is using webbrowser control,and im using sendkeys to excute the submit form example:
WebBrowser1.Document.All.profile.submit.focus
SendKeys "{ENTER}"
thing is i want my window hidden so if i have it hidden u can imanage what happens it presses enter everything im near etc,so im wonderin,if any one has solution maybe abit to focus the button get the window of it and submit it o somthing thanks
|