Author |
Topic |
|
chandisciple
75 Posts |
Posted - 05/29/2016 : 22:40:02
|
Hi all,
Wondering why below statement close notepad and automatically click on dont save. Please help.
acCloseApplication(nil, gsx, gsy) acSendKeys("n")
OR
acCloseApplication(nil, gsx, gsy) acSendKeys("{TAB}{ENTER}")
|
|
Rob
USA
2615 Posts |
Posted - 05/29/2016 : 22:42:30
|
Have you tried putting an acDelay call after close application? It may be sending the keys too quickly |
|
|
chandisciple
75 Posts |
Posted - 05/30/2016 : 00:20:08
|
Did all combinations of acdelay rob no go.
acCloseApplication(nil, gsx, gsy) acDelay (500) acSendKeys("n")
when i do the above for example, and i run it, i get the options to click on "save" "dont save" "cancel"
when i click on cancel the cursor returns back to the notepad file naturally and i see that it types "n" in the text file no matter how long i take to click on cancel. Is that a helpful ?
so if the text in the notepad was "test" it is later "testn"
|
Edited by - chandisciple on 05/30/2016 00:24:48 |
|
|
newbie
9 Posts |
Posted - 05/30/2016 : 01:26:24
|
for me, this works: acSendKeys("%{F_4}n") no need acCloseApplication nor acDelay |
Edited by - newbie on 05/30/2016 01:30:55 |
|
|
chandisciple
75 Posts |
Posted - 05/30/2016 : 02:32:31
|
Wow that works Newbie ! Thanks !
Just curious whats wrong with my code, in fact very curious. |
|
|
newbie
9 Posts |
Posted - 05/30/2016 : 04:42:53
|
Nothing wrong with your code! maybe acCloseApplication() use SendMessage method: acSendMessage(acGetForegroundWindow(),0x10,0,0) -- 0x10 WM_CLOSE acSendKeys("n") will bring you "...n"
acPostMessage(acGetForegroundWindow(),0x10,0,0) acSendKeys("n") will do what you want.
Sending a message to an app will send the message, and then WAIT for the message to be processed BEFORE RETURNING. Posting a message to an app send the message to the applications message queue, and then returns immediately, WITHOUT WAITING for the message to be processed.
What do you think, ROB?! |
|
|
Rob
USA
2615 Posts |
Posted - 06/06/2016 : 19:13:31
|
Yes, newbie, you're quite correct! I should probably use PostMessage instead... |
|
|
|
Topic |
|
|
|