Sie sind vermutlich noch nicht im Forum angemeldet - Klicken Sie hier um sich kostenlos anzumelden Impressum 
Sie können sich hier anmelden
Dieses Thema hat 20 Antworten
und wurde 404 mal aufgerufen
 Skripte und Zusatzprogramme
Seiten 1 | 2
monkey8 Offline



Beiträge: 315

06.06.2010 12:23
RE: Mouse positioning scripts Zitat · Antworten

Dear all

one of the most commonly used type of advanced script with DNS is mouse positioning scripts e.g. the following script clicks the mouse at a certain position in your application.

SetMousePosition 1,234,494
Wait 0.1
ButtonClick 1,1

To create such a script it is necessary to work out the coordinates of the particular point where you want to click the mouse and then call up the command editor and insert the necessary code. Thus it can take a few minutes to create such a script and it can be awkward to work out the mouse position coordinates. However the script below will do all the hard work for you, all you do is position the mouse on the application window where you would like the mouse click to occur and call the advanced script containing the following code e.g.

"add mouse position script"

Option Explicit
Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Type POINTAPI
x As Long
y As Long
End Type
Declare Function GetCursorPos Lib "user32" _
Alias "GetCursorPos" (lpPoint As POINTAPI) As Long
Declare Function GetWindowRect Lib "user32" _
Alias "GetWindowRect" (ByVal hwnd As Long, _
lpRect As RECT) As Long
Declare Function GetForegroundWindow& Lib "user32" ()
Function GetWinCurPos(hwnd As Long) As POINTAPI
Dim pt As POINTAPI
Dim wRect As RECT
Dim result As POINTAPI
Dim EngineControl As DgnEngineControl
GetCursorPos pt
GetWindowRect hwnd, wRect
result.x = pt.x - wRect.Left
result.y = pt.y - wRect.Top
GetWinCurPos = result
End Function
Sub Main
Dim hwnd As Long
Dim result As POINTAPI
Dim clip As String
hwnd = GetForegroundWindow
result = GetWinCurPos(hwnd)
clip = "SetMousePosition 1," & result.x & _
"," & result.y
EngineControl.DlgShow(dgndlgNewCommandWizard, 0, , 0)
Wait 0.4
SendKeys"%y"
Wait 0.2
SendKeys"{Down 3}{Tab 2}"
Wait 0.2
SendKeys clip
Wait 0.1
SendKeys"~Wait 0.2~ButtonClick 1, 1"
Wait 0.1
'SendKeys"%a"
'The previous line will work in the English version, the one below in German

SendKeys "%z"
Wait 0.1
'SendKeys"%c"
'See above

SendKeys "%n"
End Sub


After calling the above script your new script will be created automatically and all you need to do is give it a name, after that you can call it any time you like while using the relevant application.

Lindsay

monkey8 Offline



Beiträge: 315

06.06.2010 23:40
#2 RE: Mouse positioning scripts Zitat · Antworten

Rüdiger

thanks for pointing out the difference accelerator keys that are used with German, I guess I should check these out as I am posting on a German forum, apologies to anyone wasting time with the script with the wrong accelerator keys.

Lindsay

JoeBu Offline




Beiträge: 213

18.06.2010 20:35
#3 RE: Mouse positioning scripts Zitat · Antworten

Hello together,

Lindsay, thanks for this useful mouse position script.

I am looking for a simular script for the right mouse click. (like ButtonClick 2, 1)

I would like to start a programm from the taskbar with a right mouse click on a specific icon.
The second step is to click on a different position above the first one.
But the position inside the taskbar of the icon is not always the same.

I would like to use a script for starting this programm.

If anyone have an idea how to find the postion or how to start a programm from the taskbar with a rightclick please let me know.

Kind regards

Jörg


Hallo zusammen,

vielen Dank an Lindsay für dieses hilfreiche Skript.

Ich suche ein ähnliches Skript für die rechte Maustaste (wie ButtonClick 2, 1).

Ich möchte ein Programm aus der Taskleiste mit einem Rechtsklick auf ein bestimmtes Icon starten. Im zweiten Schritt muss ich auf dem erscheinenden Menü mit der linken Maustaste auf "Umschalten zu Messbetrieb" klicken.
Leider befindet sich das Icon nicht immer an der selben Stelle.

Dies würde ich gerne per Skript machen.

Wenn jemand mir hierbei helfen könnte wäre ich sehr dankbar.

Gruß

Jörg



Uploaded with ImageShack.us

Angefügte Bilder:
Aufgrund eingeschränkter Benutzerrechte werden nur die Namen der Dateianhänge angezeigt Jetzt anmelden!
 f12t182p1013n37.jpg 
monkey8 Offline



Beiträge: 315

19.06.2010 13:34
#4 RE: Mouse positioning scripts Zitat · Antworten

Jörg

Try this, obviously you can shorten the name of the command if you wish, currently you would say e.g.

"right click system tray 1"
"right click system tray 4"
etc

the list just contains the numerals 1 to 20

Lindsay

I have additionally attached the code below to copy and paste.

EDIT: Unfortunately the Google translation into German will mess up the actual code for copying, so if in doubt you will just have to copy the code from the screenshot.



Declare Function SetForegroundWindow Lib "user32" _
Alias "SetForegroundWindow" (ByVal Hwnd As Long)As Long
Declare Function FindWindow Lib "user32" Alias _
"FindWindowA" (ByVal lpClassName As String, ByVal _
lpWindowName As String) As Long
Declare Function FindWindowEx Lib "user32" Alias _
"FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, _
ByVal lpsz1 As String, ByVal lpsz2 As String) As Long

Sub main
Dim h1, h2, h3 As Long
'Get the taskbar window
h1 = FindWindow("Shell_TrayWnd","")
h2 = FindWindowEx(h1,0,"TrayNotifyWnd","")
SetForegroundWindow(h2)
Wait 0.2
SendKeys"{Left "+ListVar1+"}{Left}+{F10}",True
' to then choose an item on the menu just moved down
' the relevant amount of times, e.g. for the top item
SendKeys"{Down}"
' optionally add the enter key to select the menu item
End Sub

JoeBu Offline




Beiträge: 213

19.06.2010 15:20
#5 RE: Mouse positioning scripts Zitat · Antworten

Hello Lindsay,

thanks a lot. The scripts works very well for starting a program from the taskbar with a rightclick.

It is possible to extend this makro in a way that the macro will save the name (not the position) of the program with was choosen from the taskbar like your first mouse position script? This would be usefull for using the result for a different macro.
The position changes from time to time, depending what programs are running.

I would like to start a program (in this specific case an IP-changer) from the taskbar with a command like "switch IP" without knowing the position of the Icon all the time.

Kind regards

Jörg

monkey8 Offline



Beiträge: 315

19.06.2010 16:46
#6 RE: Mouse positioning scripts Zitat · Antworten

Jörg

it would require a script to manually check the names of all the system tray icons and log the position of the relevant one (IP Switcher), it's not so easy to do that unfortunately with advanced scripting and like you say the previous script I gave you will do this but you need to know which position in the system tray that the IP Switcher icon is. Before even considering an advanced script I would look at another way (e.g. commandline function) for getting IP Switcher to do what you want to do without going via the system today. Can you point me to download of the particular IP Switcher software that you are using as there may be a simpler way to do this.

Edit: I meant to say that I realised that you want to use this principle and script for doing similar things with other applications as well. However one of the difficulties of that is that different application developers use different parameters within the application code to store the relevant application name. I looked at this problem quite a few years ago as I wanted to do this with Skype (and other applications) but the compromise I ended up with was using the script above.

Lindsay

JoeBu Offline




Beiträge: 213

19.06.2010 18:00
#7 RE: Mouse positioning scripts Zitat · Antworten

Zitat von monkey8
Jörg

Before even considering an advanced script I would look at another way (e.g. commandline function) for getting IP Switcher to do what you want to do without going via the system today. Can you point me to download of the particular IP Switcher software that you are using as there may be a simpler way to do this.

Lindsay



Hello Lindsay,

I tried already the way with commandline function, but the program does not support this feature (feedback from my company IT). Unfortunately I have no possibility to give you any information about this program. This program is developed for my company and it works closely with the firewall.

I guess I have to use the script above. Thanks for your support.

Kind regards

Jörg

monkey8 Offline



Beiträge: 315

19.06.2010 19:15
#8 RE: Mouse positioning scripts Zitat · Antworten

Hello Jörg

If your program was created in-house can you not get the developers to make the particular function you want to access more accessible (e.g. with a hot key assignment)?

The only other option I can see of finding it directly on the system tray is if you download a program such as WinID (which is free and very small), start it up, and then position your mouse over the different system tray icons. If the system tray icon that you need to access the context menu for has a title then we might be able to do it. If you try this you will notice that the class name for all the system tray icons is "SysPager". However most developers usually leave the title field blank and thus I can't distinguish between them using an advanced script. If your particular system tray icon does have a title then we might possibly be able to do something.

if you Google "download WinID" you will find various places to download it.

Best wishes

Lindsay

JoeBu Offline




Beiträge: 213

24.06.2010 22:35
#9 RE: Mouse positioning scripts Zitat · Antworten

Hello Lindsay,

thanks for the advise to download WinID.

Unfortunately it is not allowed to use this programm in order of IT regulations. I am working in a huge company with high security rules.
I have checked this on my privat computer with other applications. But the title fields are always blank.

The ip-switcher-program was developed ouside the company. There is no easy way to ask for additional features.

Kind regards

Jörg

BruceTjosvold Offline



Beiträge: 1

15.07.2010 01:01
#10 RE: Mouse positioning scripts Zitat · Antworten

Hello Jörg,

If your company allows, Vista Switcher is a very nice replacement for the Windows Alt+Tab function. Check out the following URL for an explanation. It is also freeware.

http://www.ntwind.com/software/vistaswitcher.html

review of the tool:

http://download.cnet.com/Switcher/3000-12565_4-10665605.html

I am not affiliated with the company that created this tool. I recently stumbled upon a review, and have been happily using the tool ever since. I have created a couple of scripts to launch this software a couple of different ways.

I like the way the software shows a smaller screen print of the application, allowing you to visually see what you can then select. See the attachment.

Bruce

Stecknadel Offline



Beiträge: 78

14.06.2011 20:56
#11 RE: Mouse positioning scripts Zitat · Antworten

Hello forum, hello Lindsay!
This script is really great! I’ve tried that today at work and it worked fine! Thanks a lot for sharing this!

Stecknadel Offline



Beiträge: 78

15.06.2011 18:10
#12 RE: Mouse positioning scripts Zitat · Antworten

Hello forum, hello Lindsay!
Today I had some problems with the mouse positioning script. It only worked in 50% of the time. I regularly got the error message:”Die Koordinaten befinden sich außerhalb des Bereichs“ which I think means in English something like “the coordinates are outside of the area”. This error occurred regularly when I tried to access the taskbar with a mouse positioning script. It didn’t appear when I tried to access other areas on the screen. Unfortunately this error message can’t be closed by voice, neither by the keyboard. I have to use the mouse for closing this error message, and that’s really bad for my RSI?
Do you have any idea, why this error message appears? Did I do anything wrong? Or does the mouse positioning script just not work for the taskbar?
Thank you very much in advance!
Susanne

monkey8 Offline



Beiträge: 315

15.06.2011 23:32
#13 RE: Mouse positioning scripts Zitat · Antworten

Hi Susanne

Glad you liked the script, it's very popular and saves a lot of time. The script was really written to produce application-specific scripts to position the mouse on a particular application window. If you want to use it for positioning the mouse on the taskbar menu can still do it but you need to follow the following procedure:

1 before calling the script click on the desktop background e.g. the desktop wallpaper
2. Position the mouse on the taskbar where ever you want it to click and then call the command
3. Give it a name as usual and then change it from "Application-specific" to "Global"
4. Finally you need to change one digit on the line SetMousePosition, you need to change the "1" to "0" e.g.

SetMousePosition 1, 457, 678

becomes

SetMousePosition 0, 457, 678

This then positions the mouse relative to the top left hand corner of the screen as opposed to the top left-hand corner of the specific window. Changing it from "Application Specific" to "Global" means you can call it at any time and therefore access the taskbar.

Now you could if you want just have a different script for taskbar and desktop commands where instead of having to change it from application-specific to global you can make the script do this and also you can make the script change the 1 to 0. You can then call the command something like "add taskbar position command".

Lindsay
www.pcbyvoice.com

Stecknadel Offline



Beiträge: 78

16.06.2011 18:30
#14 RE: Mouse positioning scripts Zitat · Antworten

Hello Lindsay,
Thank you very much for your help! I tried this today at work and it worked fine! Now I can easily access the taskbar, that's so great!
But unfortunately there is still a little problem: sometimes the mouse positioning script does not work. Occasionally it produces an empty script like that:
" Sub main

end sub"

Then I have to work out the coordinates manually. That's no big deal, but do you know, what's in this could be?
I just used the script that you posted above. And sometimes it works fine, and sometimes not. I recognized that I always used coordinates near the edge of the screen, when the script didn't work. Near the middle of the screen it always worked fine. I have a 24 inch monitor if that makes a difference...
Thank you very much in advance!!

monkey8 Offline



Beiträge: 315

16.06.2011 22:05
#15 RE: Mouse positioning scripts Zitat · Antworten

Hi Susanne

just add 0.2 to every single Wait time on the bottom half of the script e.g.

Wait 0.4

becomes

Wait 0.6

it will slow it down a little but will make it more reliable. In fact to be even safer set the first one after calling the dialogue with the engine control to something like 0.8 initially. You can always then speed it up once you get it working reliably. It's the one thing with Advanced Scripting that I don't like, using Wait states but it just makes it easier than alternative methods.

Best wishes
Lindsay
www.pcbyvoice.com

Seiten 1 | 2
Ähnliche Themen Antworten/Neu Letzter Beitrag⁄Zugriffe
Formatierung Komma
Erstellt im Forum Fragen zur Anwendung von Wossi
6 09.12.2024 16:19
von Marius_ • Zugriffe: 121
Willkürliche Zeilensprünge vor und zurück in der Mitte von Dokumenten
Erstellt im Forum Fragen zur Anwendung von Wolfgang Köln
8 11.10.2024 11:00
von Marius_ • Zugriffe: 416
Optionen für Mikrofoneinstellung PowerMic Diktieren
Erstellt im Forum Geräte und Hardware von Wossi
11 26.04.2024 19:03
von Wossi • Zugriffe: 926
Befehl zur Änderung der Mausposition relativ zur aktuellen Position
Erstellt im Forum Fragen zur Anwendung von
8 25.08.2023 16:29
von • Zugriffe: 723
Word-Makros funktionieren immer wieder einmal nicht.
Erstellt im Forum Skripte und Zusatzprogramme von rc.otto
2 13.03.2023 08:05
von rc.otto • Zugriffe: 195
Erkennt Dragon (englische) Fachausdrücke aus der Luftfahrt?
Erstellt im Forum Fragen zur Anwendung von ryma
2 25.03.2021 17:28
von ryma • Zugriffe: 458
 Sprung  
Xobor Ein Kostenloses Forum | Einfach ein Forum erstellen
Datenschutz