VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Manipulating Applications


Category: Custom Controls/Forms/Menus
Compatability: Visual Basic 3.0
Difficulty: Intermediate
Date Added: Wed 3rd February 2021
Rating: (4 Votes)

This code will minimize, maximize and send keystrokes from within your program to any application.

Rate Manipulating Applications

'There are three programs which:
'send any keystroke to any application.
'minimize any window(of any application).
'maximise any window(of any application).
'Send Keystroke'
'~~~~~~~~~~~~~~'
Dim ReturnValue, I
ReturnValue = Shell("App. Name", 1)  ' e.g. Shell ("Calc.exe",1)
AppActivate ReturnValue  ' Activate the Calculator.
For I = 1 To 100  ' Set up counting loop.
  SendKeys I & "{+}", True  ' Send keystrokes to Calculator
Next I  ' to add each value of I.
SendKeys "=", True  ' Get grand total.
SendKeys "%{F4}", True  ' Send ALT+F4 to close Calculator.
'Minimize'
'~~~~~~~~'
Private Declare Function CloseWindow Lib "user32" Alias "CloseWindow" _
(ByVal hwnd As Long) As Long
Shell "Calc.exe",1  'This will start calc. Any appl. can be opened 
   'like this
a = screen.activeform.hwnd 'will return the window handle of calc.
  'to get handle of own app. don't use shell 
  'command and write the code as it is.
closewindow(a) 'will minimize calc
'Maximize'
'~~~~~~~~'
'this code assumes that the application is opened but minimized
'If application is not opened you may use /Shell "App Nm"/ to open it

Appactivate "Title",True 'Here Title is the one which is shown in the 
 'title bar of the application
 'Shell command automatically gives title so 
 'in above example to send keystroke we did 
 'not mention title.
SendKeys "%( x)" '% stands for alt and then a blank and x is sent 
 'to maximize.

Download this snippet    Add to My Saved Code

Manipulating Applications Comments

No comments have been posted about Manipulating Applications. Why not be the first to post a comment about Manipulating Applications.

Post your comment

Subject:
Message:
0/1000 characters