Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
swdev:autohotkey:examples [2018/02/13 14:23] smayr [Keyboard] |
swdev:autohotkey:examples [2018/02/13 17:37] (current) smayr [Messages or Dialogs] |
||
---|---|---|---|
Line 34: | Line 34: | ||
<code autoit> | <code autoit> | ||
; Click method: | ; Click method: | ||
- | Click 310, 65 | + | Click 310, 65 |
; MouseClick method: | ; MouseClick method: | ||
Line 51: | Line 51: | ||
Send, {LAlt down}e{LAlt up} ; menu: < | Send, {LAlt down}e{LAlt up} ; menu: < | ||
- | ; Ctrl-C to copy | + | ; Ctrl-C to copy using Send |
SetKeyDelay, | SetKeyDelay, | ||
Send, {ctrl down}c{ctrl up} ; Copy using send | Send, {ctrl down}c{ctrl up} ; Copy using send | ||
+ | |||
+ | ; Ctrl-C to copy using SendInput | ||
+ | SendInput {ctrl down}c{ctrl up} | ||
+ | |||
+ | ; Ctrl-C to copy using ControlSend | ||
+ | ControlSend, | ||
</ | </ | ||
+ | |||
+ | === Messages or Dialogs === | ||
+ | Send a message with '' | ||
+ | <code autoit> | ||
+ | ; Format: | ||
+ | ; | ||
+ | ; | ||
+ | MsgBox, 4, " | ||
+ | IfMsgBox No { | ||
+ | return | ||
+ | } | ||
+ | |||
+ | ; Show mouse coordinates | ||
+ | MouseGetPos, | ||
+ | MsgBox The current mouse cursor position is X%MouseX% Y%MouseY%. | ||
+ | </ | ||
+ | |||
+ | Send a message with '' | ||
+ | <code autoit> | ||
+ | ; Format: | ||
+ | ; SplashTextOn [, Width, Height, Title, Text] | ||
+ | SplashTextOn, | ||
+ | Sleep, 2000 | ||
+ | SplashTextOn, | ||
+ | WinMove, Clipboard, , 0, 0 ; Move the splash window to the top left corner. | ||
+ | MsgBox, Press OK to dismiss the SplashText | ||
+ | SplashTextOff | ||
+ | </ | ||
+ | |||
+ | Send a messag with '' | ||
+ | <code autoit> | ||
+ | ToolTip, Hello World!!!, 100, 15 ; display ToolTip | ||
+ | Sleep, 5000 ; pause program execution for 5 secs | ||
+ | ToolTip, , 100, 15 ; clear ToolTip | ||
+ | </ | ||
+ | |||
=== Run Application === | === Run Application === | ||
Running an application: | Running an application: | ||
Line 112: | Line 154: | ||
; MouseClick, left, 90, 65 ; Menu: Edit > Copy | ; MouseClick, left, 90, 65 ; Menu: Edit > Copy | ||
| | ||
- | ; | + | ; |
- | ; ;send, {LAlt}e | + | ; ;Send, {LAlt}e |
- | ; ;send, {LAlt down}e{LAlt up} ; menu: < | + | ; ;Send, {LAlt down}e{LAlt up} ; menu: < |
- | ; ;sleep, 1000 | + | ; ;Sleep, 1000 |
- | ; ;send, e ; menu: < | + | ; ;Send, e ; menu: < |
- | ; ;sleep, 1000 | + | ; ;Sleep, 1000 |
- | ; ;send, s ; menu option: Select All | + | ; ;Send, s ; menu option: Select All |
; | ; | ||
- | ; ; SetKeyDelay, | + | ; ; SetKeyDelay, |
- | ; ;send, {ctrl down}c{ctrl up} ; Copy using send | + | ; ;Send, {ctrl down}c{ctrl up} ; Copy using send |
; ;SendInput {ctrl down}c{ctrl up} ; Copy using SendInput | ; ;SendInput {ctrl down}c{ctrl up} ; Copy using SendInput | ||
; | ; | ||
- | ; ; Display window name | ||
- | ; WinGet, OutputVar, ProcessName | ||
- | ; ;MsgBox, " | ||
- | ; ; | ||
- | ; MsgBox, %OutputVar% | ||
| | ||
| | ||
; --- Select All (using click on toolbar) --- | ; --- Select All (using click on toolbar) --- | ||
- | SetControlDelay | + | SetControlDelay, |
- | ; | + | ControlClick, |
- | ; | + | |
- | ControlClick, | + | |
- | | + | |
if ErrorLevel | if ErrorLevel | ||
- | MsgBox, The ControlClick for ToolbarWindow322 ... ' | + | |
+ | ToolTip, The ControlClick for ToolbarWindow322 ... ' | ||
} else { | } else { | ||
- | MsgBox, The ControlClick for ToolbarWindow322 ... ' | + | |
+ | ToolTip, The ControlClick for ToolbarWindow322 ... ' | ||
} | } | ||
; ;Click 310, 66 | ; ;Click 310, 66 | ||
; MouseClick, left, 310, 65 | ; MouseClick, left, 310, 65 | ||
- | | + | |
- | ;Menu, ToolbarWindow322, | + | ToolTip, , 100, 15 ; clear ToolTip |
+ | ;Menu, ToolbarWindow322, | ||
| | ||
- | ; --- Copy (using click on toolbar) --- | + | ; --- Copy to Clipboard |
emptyClipboard() | emptyClipboard() | ||
; ; | ; ; | ||
- | ; | + | ; |
; | ; | ||
- | ControlClick, | + | ControlClick, |
; ;Click 335, 15 | ; ;Click 335, 15 | ||
; MouseClick, left, 335, 15 | ; MouseClick, left, 335, 15 | ||
- | | + | |
- | ; | + | |
; ; | ; ; | ||
+ | | ||
+ | ; --- Copy to Clipboard (using Keyboard) --- | ||
+ | ; | ||
| | ||
; --- Clear Selection (using click on toolbar) --- | ; --- Clear Selection (using click on toolbar) --- | ||
- | ; | + | ; |
| | ||
- | ; --- Copy to Clipboard --- | + | ; --- Paste from Clipboard --- |
- | ; | + | |
pasteFromClipboard() | pasteFromClipboard() | ||
} else { | } else { | ||
Line 180: | Line 220: | ||
| | ||
; Display window name | ; Display window name | ||
- | WinGet, OutputVar, ProcessName | + | |
- | MsgBox, %OutputVar% | + | |
| | ||
; Call File > New (using Mouse) | ; Call File > New (using Mouse) | ||
Line 196: | Line 236: | ||
; | ; | ||
- | ; Paste data to clipboard | + | ; Empty clipboard |
; | ; | ||
- | pasteFromClipboard() | + | emptyClipboard() |
{ | { | ||
- | ;if WinExist(" | + | |
- | if WinExist(" | + | |
- | WinActivate ; use the window found above | + | |
- | MsgBox Found Notepad | + | |
- | } else { | + | |
- | Run, Notepad.exe | + | |
- | MsgBox Running Notepad | + | |
- | } | + | |
- | sleep, 500 | + | |
- | ;Send, %clipboard%. | + | |
- | ;SendInput, {ctrl down}v{ctrl up} | + | |
- | send, {ctrl down}v{ctrl up} | + | |
} | } | ||
; | ; | ||
- | ; Paste data to clipboard | + | ; Copy data to clipboard |
; | ; | ||
copyToClipboard() | copyToClipboard() | ||
Line 221: | Line 250: | ||
emptyClipboard() | emptyClipboard() | ||
;Send, ^c | ;Send, ^c | ||
- | | + | |
ClipWait, 2 | ClipWait, 2 | ||
if ErrorLevel { | if ErrorLevel { | ||
Line 231: | Line 260: | ||
; | ; | ||
- | ; Empty clipboard | + | ; Paste data from clipboard |
; | ; | ||
- | emptyClipboard() | + | pasteFromClipboard() |
{ | { | ||
- | | + | ;if WinExist(" |
+ | if WinExist(" | ||
+ | WinActivate ; use the window found above | ||
+ | MsgBox Found Notepad | ||
+ | } else { | ||
+ | Run, Notepad.exe | ||
+ | MsgBox Running Notepad | ||
+ | } | ||
+ | Sleep, 500 | ||
+ | ;Send, %clipboard%. | ||
+ | ;SendInput, {ctrl down}v{ctrl up} | ||
+ | Send, {ctrl down}v{ctrl up} | ||
} | } | ||
Line 247: | Line 287: | ||
;MsgBox The color at the current cursor position is %color%. | ;MsgBox The color at the current cursor position is %color%. | ||
MsgBox The current mouse cursor position is X%MouseX% Y%MouseY%. | MsgBox The current mouse cursor position is X%MouseX% Y%MouseY%. | ||
- | } | + | } |
</ | </ |