Automation 自动热键Win XP自动执行小任务
我有一个小任务,我想用Autohotkey自动执行,它看起来或多或少可以直接转换为Autohotkey语法:Automation 自动热键Win XP自动执行小任务,automation,windows-xp,autohotkey,Automation,Windows Xp,Autohotkey,我有一个小任务,我想用Autohotkey自动执行,它看起来或多或少可以直接转换为Autohotkey语法: 1. Ctrl+v 2. Alt+tab 3. Click certain link in a window (no combo-key for this but it's always in the same place) 4. Enter (carriage return) 5. Alt+s 6. Ctrl+v 7. Enter 现在最好将此组合映射到其他对象,例如Windows键
1. Ctrl+v
2. Alt+tab
3. Click certain link in a window (no combo-key for this but it's always in the same place)
4. Enter (carriage return)
5. Alt+s
6. Ctrl+v
7. Enter
现在最好将此组合映射到其他对象,例如Windows键+空格
到目前为止,我得到的是:
0. SetWinDelay 100 (using a connection to an remote computer)
0. SetKeyDelay 0
1. Send, ^c
1. ClipWait, 0.1
2. Send, {Alt down}{tab}
2. Send, {Alt up}
3. ?????
4. Send, {enter}
5. Send, !s
6. Send, ^v
7. Send, {enter}
这大致正确吗?可以说,有人因为帮我修理或填补漏洞而受到责备:)
第3步、第4步和第6步的另一个替代方法是简单地循环剪贴板的内容(一个数字字符串),并将字符串中的每个字母发送到按键?如果您想“单击”某个位置,要打开菜单,您可以先右键单击自动热键图标并打开“窗口间谍”,这可能是更简单的方法。此窗口间谍将向您显示鼠标位置。您可以使用鼠标位置在活动应用程序中执行操作
例如:
SoundBeep 1000, 300 ; Wake up user
SplashTextOn, 200, 100, Script Preparations, Please Click on the person icon link. ; Show new Instructions text
WinMove, Script Preparations,, (A_ScreenWidth/2)+150, (A_ScreenHeight/2)+200 ; Move the window with the name "Script Preparations" Down and Right on the main screen
KeyWait, LButton, D ; Wait for LeftMouseButton click Down
MouseGetPos, xposE ,yposE ; Store the position where the mouse was clicked (Employee)
MouseClick, left, %xposE% ,%yposE%, 2 ; Perform a double mouse click on the captured mouse location
SplashTextOff ; Remove Text box
在本例中,我首先要求用户手动单击正确的位置。仅当要单击的位置在活动窗口(活动窗口中的可变平铺)中更改时,才需要此选项。一旦存储了位置,就可以在整个脚本中重复使用它
b、 t.w.我建议使用以下选项,而不是使用Alt+Tab:
settitlematchmode, 1 ; Set search in title to start with....
settitlematchmode, Fast ; Slow is not required here. Slow is only required when hidden text needs to be found.
SwitchWindow("Microsoft Excel - 1 QRM Upload and Change Template") ; Activate the
window with the title: Microsoft Excel - 1 QRM Upload and Change Template
You could even use someting like this:
SetTitleMatchMode, 2 ; Ensure that the Title Match mode is set to 2: Find anywhere in the title
SetTitleMatchMode, Fast ; Ensure that the Title Match mode is set to FAST
winactivate, %WindowName% ; Activate the window with the title stored in the variable WindowName
WinWaitActive, %WindowName%, , 5 ; Wait up to five seconds for the screen
if ErrorLevel ; Execute this when the window is not activated within 5 seconds
{ ; Start-If Wait failed
SoundBeep 1000 , 1000 ; Warn the user
MsgBox,4097,Time Out, Script timed out while waiting for %WindowName%.`n`rYou Must manually activate %WindowName% and then continue the script by pressing OK. ; Message to user
IfMsgBox, Cancel ; Do when the user clicked on Cancel
{ ; Start-If User clicked Cancel
ExitApp ; Exit this program when the user clicked on Cancel
} ; End-If User clicked Cancel
WinWaitActive, %WindowName%, , 5 ; Try to activate the window AGAIN
if ErrorLevel ; If window can't be found
{ ; Start-If window can't be found
MsgBox,4096,Exit, %WindowName% still NOT Active. ; Warn user
ExitApp ; Exit this program when the expected window is still not found
} ; End-If window can't be found
} ; End-If Wait failed
问候,
罗伯特·伊尔布林克谢谢。WinActivate派上了用场,在我使用了许多“发送”之后,我使用了一些睡眠。我没有使用鼠标单击来更改粘贴模式,因为剪贴板的内容可以通过“发送,%clipboard%”进行“伪粘贴”