ak
New Member
Posts: 7
|
Post by ak on Mar 27, 2019 18:20:08 GMT
Is there a way to guarantee that the input box is the window in focus when it pops up? I'm using a barcode scanner that automatically enters a string and hits "enter", and then the program pastes that string in an appropriate place and loops to do it again. Upon looping the Input Box is not in focus, forcing me to click on it before I'm able to scan another barcode. Any ideas?
Thanks!
|
|
|
Post by Steve on Mar 29, 2019 5:33:16 GMT
The first would be to ensure that the main Mini Mouse Macro window is not 'On Top' (Program Options - Options - Uncheck 'On Top' enabled at startup and also Check 'On Top' check box removed).
When Mini Mouse Macro creates the input box it puts in above the main Mini Mouse Macro window. If another window is opened the input box will be behind the current window that has the main focus. To get the input box back to the main focus it needs to be called back to the primary focus. We can do this using a mouse click, the keyboard (alt-tab), or programmatically. I am assuming you want this done automatically. I would suggest something like this as a demo:
- inputbox.mmmacro
1 | RUN ACTION | OUTPUT TO FILE | E:\Dropbox\Macro\INPUT\windowtitle.txt::OVERWRITE::Title of the InputBox 2 | RUN ACTION | INPUT BOX | enter number::Title of the InputBox::STRING 3 | RUN ACTION | MESSAGE PROMPT | %string%::::0 4 | RUN ACTION | OUTPUT TO FILE | E:\Dropbox\Macro\INPUT\windowtitle.txt::OVERWRITE::InputBox Title 2 5 | RUN ACTION | INPUT BOX | enter number::InputBox Title 2::STRING 6 | RUN ACTION | MESSAGE PROMPT | %string%::::0
- getfocus.mmmacro
1 | RUN ACTION | INPUT FROM FILE | STRING::REFRESH::E:\Macro\INPUT\windowtitle.txt 2 | IF | WINDOW TITLE | %STRING% | EXIST | SELECT WINDOW BY NAME | %STRING% 3 | RUN ACTION | WAIT MILLISECONDS | 250 4 | RUN ACTION | GOTO MACRO LINE | 1
The two macro's are run in seperate instances of minimousemacro.exe. getfocus.mmmacro started first.
getfocus.mmmacro is fed it's input from windowtitle.txt. inputbox.mmmacro passes this value prior to launching the input box.
This will ensure that each input box will always have focus.
|
|
ak
New Member
Posts: 7
|
Post by ak on Apr 2, 2019 17:25:37 GMT
Wow, thank you so much for the reply, I hadn't thought of running a separate MMM instance! I tried implementing a version of this, and at first I was thrilled to find a solution, but unfortunately I'm still having issues. It will work a few times, but then for some reason that I can't ascertain, the input box stops grabbing focus. Here's a video to illustrate: www.dropbox.com/s/37tcenib3vkgzal/IMG_1273.MOV?dl=0Any ideas?
|
|
|
Post by Steve on Apr 13, 2019 5:19:41 GMT
Hi,
Thanks for the video and great application use incorporating the scanner. Hmmm your GTM_AK macro syntax looks a little off.
If you post your code I'll check it out. I think your first two lines may be causing an issue but it's hard to say without checking it first.
Also can you paste in your MMM Event log (https://www.turnssoft.com/faq2.html#eventlog).
Cheers, Steve.
|
|
ak
New Member
Posts: 7
|
Post by ak on Apr 22, 2019 19:05:50 GMT
Hi Steve,
Thanks for taking the time to try and help me with this. If I can solve this, it would be huge for me, haha.
So here is the script I am currently using:
* | Click Play
1 | 499 | 92 | 500 | Left Click Down
2 | 499 | 92 | 80 | Left Click Release
* | Click Play
3 | 499 | 92 | 2500 | Left Click Down
4 | 499 | 92 | 80 | Left Click Release
* | Click LV
5 | 1734 | 55 | 100 | Left Click Down
6 | 1734 | 55 | 80 | Left Click Release
* | Adjust ISO to max
7 | 1374 | 461 | 100 | Left Click Down
8 | 1374 | 461 | 80 | Left Click Release
9 | 1323 | 821 | 100 | Left Click Down
10 | 1323 | 821 | 80 | Left Click Release
10 | RUN ACTION | | | | INPUT BOX | Scan Code::Scan Code::STRING
11 | IF | STRING VARIABLE | %STRING% | IS | | STOP
* | Adjust ISO back to 125
12 | 1372 | 462 | 100 | Left Click Down
13 | 1372 | 462 | 80 | Left Click Release
14 | 1304 | 510 | 100 | Left Click Down
15 | 1304 | 510 | 80 | Left Click Release
* | Close LV
16 | 2543 | 11 | 100 | Left Click Down
17 | 2543 | 11 | 80 | Left Click Release
* | Change Description
18 | 568 | 692 | 100 | Left Click Down
19 | 568 | 692 | 80 | Left Click Release
20 | 568 | 692 | 80 | Left Click Down
21 | 568 | 692 | 80 | Left Click Release
22 | 483 | 1189 | 100 | Keypress %STRING%
23 | 496 | 95 | 100 | Left Click Down
24 | 496 | 95 | 80 | Left Click Release And here is the looping script to check for window focus that I have running as well:
1 | IF | WINDOW TITLE | Scan Code | EXIST | SELECT WINDOW BY NAME | Scan Code
2 | RUN ACTION | WAIT MILLISECONDS | 500
3 | RUN ACTION | GOTO MACRO LINE | 1 I can see in the event log that it recognizes the window is there when it pops up (see below). But it isn't able to successfully focus it. The MMM icon in the taskbar flashes to let me know that it has some sort of alert for me, but the input prompt is not the subject of focus.
04/22/2019 11:53:25.94 AM Macro action - Running ACTION: GOTO MACRO LINE - Macro line(1)
04/22/2019 11:53:26.02 AM Macro condition - Condition TRUE
04/22/2019 11:53:26.54 AM Macro action - Thread sleeping for 500 milliseconds
04/22/2019 11:53:27.03 AM Macro action - Running ACTION: GOTO MACRO LINE - Macro line(1)
04/22/2019 11:53:27.11 AM Macro condition: 2 | RUN ACTION | WAIT MILLISECONDS | 500
04/22/2019 11:53:27.18 AM Macro action - Thread sleeping for 500 milliseconds
If I click on the MMM window that is running that condition loop, the focus jumps to the text input. I have a feeling I'm running in to impenetrable issues with how Windows handles these system events..
|
|
|
Post by Steve on Apr 25, 2019 6:31:10 GMT
Closer look at your video i see that the input box seems to be getting suck behind the main application on the left screen. The set focus to the input box does not seem to be working as we expect in this case. I have a work around: MMM focus1.mmmacro1 | RUN ACTION | WAIT SECONDS | 1 2 | RUN ACTION | INPUT BOX | test::test::STRING 3 | RUN ACTION | COPY TO CLIPBOARD | CONTINUE 4 | RUN ACTION | WAIT SECONDS | 1 5 | RUN ACTION | GOTO MACRO LINE | 1 MMM focus2.mmmacro1 | IF | CLIPBOARD | VALUE | TEXT IS | CONTINUE | CONTINUE 2 | IF | WINDOW TITLE | test | EXIST | CONTINUE 3 | X | X | 500 | Keypress Alt+ | tab 4 | IF | WINDOW TITLE | test | EXIST | SELECT WINDOW BY NAME | MMM focus2.mmmacro 5 | RUN ACTION | WAIT MILLISECONDS | 250 6 | IF | WINDOW TITLE | test | EXIST | SELECT WINDOW BY NAME | test 7 | RUN ACTION | COPY TO CLIPBOARD | NEXT 8 | RUN ACTION | GOTO MACRO LINE | 1 Using CLIPBOARD conditions ( www.turnssoft.com/conditions.html#clipboard and www.turnssoft.com/conditions.html#copytoclipboard) we pass the second focus app a queue to when it expects a new window. We then check the title exists, and throw an Alt+ tab to select the macro window off focus from our primary application. We then select the input box window.
|
|
ak
New Member
Posts: 7
|
Post by ak on Apr 25, 2019 20:08:15 GMT
Steve,
That's amazing. This inspired me to figure it out! I basically took what you put together there and just have the second script click the mouse when "continue" is detected in the clipboard.
1 | IF | CLIPBOARD | VALUE | TEXT IS | CONTINUE | CONTINUE 3 | 1226 | 690 | 500 | Left Click Down 4 | 1226 | 690 | 70 | Left Click Release 5 | RUN ACTION | COPY TO CLIPBOARD | NEXT 6 | RUN ACTION | WAIT SECONDS | 1 7 | RUN ACTION | GOTO MACRO LINE | 1 I have the other script copying "CONTINUE" in to the clipboard immediately before triggering the input dialog. Within a second or two, the mouse automatically clicks on the half-hidden input dialog and makes it the active window. Which is what I was doing manually anyway, so it's kind of obvious in retrospect. Thank you so much for your cleverness!
|
|