Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Custom Toolbar intermittently crashing
#1
Hi, this is my first time posting here, so please forgive me if I am posting this question in the wrong place.

I created a simple toolbar that is used to enter various text strings into any textbox or other place where you can normally type. The idea is to create form letters and/or parts of messages that can be entered into any window by clicking on the various toolbar buttons.

Here is an example of the function that does the copy paste of the text strings - it would be labeled "TEXT_1"

Code:
Copy      Help
_s="This is a test of copying text to the clipboard then pasting it into wherever the cursor was left or the current active window"; _s.setclip()
key Cv

I used this method since I am working across an RDP session (to a 3rd party server), so I cannot use SetText or any other direct method of entering the desired text. I encounter the crashing even if I am entering the text into a notepad window running on my local windows 10 desktop. This happens in Windows 10 Pro, or on a Surface Pro 3 tablet running Windows 8 Pro, it seems to consistently crash regardless of which computer it is running on, and it crashes the local OS, not the remote session. I designed it on my local computer, testing it in notepad, but the remote user mostly uses it to enter text into apps running on a remote server thru RDP.

Here is a sample of my main toolbar:

Code:
Copy      Help
Category 1:mac "CAT1"
Category 2:mac "CAT2"
Category 3:mac  "CAT3"

Here is an example of the "Category 1" menu

Code:
Copy      Help
Text String 1:mac "TEXT_1"
Text String 2:mac "TEXT_2"
Text String 3:mac "TEXT_3"

Clicking on the "Category 1" button in the toolbar would open up the Menu that has 3 buttons, "Text String 1", "Text String 2" and "Text String 3". Then when you click on the "Text String 1" button in the menu that opened, it performs the copy/paste of the corresponding text string (in the example I provided above).

Should I be using a function to do the copy/pasting, or should that be a macro? I am not sure if there is a difference, it has worked for many years using functions to do the copy/pasting, but it just occurred to me that I might be using a function where I should be using a macro. Can someone explain the proper usage of those types of items to me? I used Quick Macros for many years, for manipulating web pages, entering text strings and clicking on web page buttons and manipulating webpage controls, and I wrote a lot of code that manipulated MS Office applications, so making this little text toolbar should have been no trouble at all, but it is constantly crashing.

The OS's that I ran my software on in the past only had a single software system installed on them, and they were very static environments used for only a specific process. This new text entry toolbar program I am making is being used on various notebook computers that run a lot of different apps, so the environments are very dynamic. One has Dragon Voice recognition software running in the background and its a surface tablet that is also using the windows handwriting recognition tool. It originally worked fine in the Surface Pro tablet, then it started crashing occasionally.... but the occasional crashes became more frequent after I added a new set of menu items to the toolbar.

I am open to suggestions on how to make this work more stable. I want to do whatever I can to make it as stable as possible, and if there is a way to run this as an executable I would love to do that.... right now I am running it inside of the QM app, but I would prefer to make it as executable of possible.

I appreciate any assistance you can provide. Please let me know if you need any further info.

Thanks

Kevin
#2
I recently found one bug in str setclip and setsel. It could be the reason. In current QM version it is still not fixed. It becomes visible only when text contains Unicode (non ASCII) characters. But the paste() function does not have this bug. Try to replace

_s.setclip(); key Cv

with

paste _s

And don't need functions or macros for each text. Everything can be in menu.

Menu CAT1
Code:
Copy      Help
Text String 1 :paste "This is a test of copying text to the clipboard then pasting it into wherever the cursor was left or the current active window"
Text String 2 :sub.TEXT_2
Text String 3 :paste "TEXT_3"
Text String 4 :sub.TEXT_4


#sub TEXT_2 m
_s=
;This is a test of copying text to the clipboard then pasting it into wherever the cursor was left or the current active window
;This is a test of copying text to the clipboard then pasting it into wherever the cursor was left or the current active window
;This is a test of copying text to the clipboard then pasting it into wherever the cursor was left or the current active window
paste _s


#sub TEXT_4 m
_s=
;This is a test of copying text to the clipboard then pasting it into wherever the cursor was left or the current active window
;This is a test of copying text to the clipboard then pasting it into wherever the cursor was left or the current active window
;This is a test of copying text to the clipboard then pasting it into wherever the cursor was left or the current active window
paste _s
#3
Gintaras, thanks so much for the help. I am not a programmer, Quick Macros was the only language I ever learned (aside from Transact-SQL). I appreciate the advice on the better way to write the code, your examples were invaluable to me.

I was able to resolve the issue by using the paste command, that stopped the crashing. Everything worked great for a week, then a new problem with the toolbar suddenly started one morning. Clicking on the toolbar in the past never changed the position of the cursor, therefore whatever textbox and/or window I clicked on last would receive the pasted text. Starting on Thursday morning, as soon as you click on the toolbar it moves the cursor out of the active window and sets it to nowhere. For example, I open notepad manually. Then I click into the notepad window because I want to paste text into there. Prior to Thursday, if I clicked on a toolbar menu item it would paste the corresponding text into the notepad window. Now when I click on the toolbar, the notepad window becomes inactive (the same effect happens if I click on the taskbar or anywhere else). Now I am unable to paste text into anything. I cannot use accessible objects to paste since I am working thru an RDP session. Normally since the RDP window is full screen and the toolbar sits on top of it, the text pastes into wherever the cursor is inside the RDP session. Since the RDP window is becoming inactive now, the text pastes to nowhere. I then started troubleshooting this on the local desktop using notepad, it has the same effect. I toggled the "lock foregroung window" option in QM, no change. There was no changes to the notebook other than a Windows Defender definition update that was pushed by Microsoft, no setting changes or software installs. I cannot figure out why the toolbar acts this way now.

To update you on what I did in response to your initial advice, I explain all my changes below. After all those changes, the toolbar worked flawlessly:

I decided to rewrite the entire program after I got your message. Since this program will constantly be added to, I decided to put all the templates (text strings) into a single function names "GLOBAL_TEXT". I declare each template as a global variable, the function is triggered by the start of QM.

Here is my toolbar itself:

Code:
Copy      Help
/hook __tb_auto_size
REASON :mac "REASON"
EXAM :mac "EXAM"
TEST :mac "TEST"
:clo val(_command) * close.ico

This is my GLOBAL_TEXT function where I keep all the text templates themselves.

Code:
Copy      Help
def reason_one "Reason Toolbar Menu Item one is entered here."
def reason_two "Reason Toolbar Menu Item two is entered here."
def exam_one "Exam Toolbar Menu Item one is entered here."
def exam_two "Exam Toolbar Menu Item two is entered here."
def test_one "Test Toolbar Menu Item one is entered here. "


This allows me to update the text menus or add new items in a much more organized manner. I will update my menus themselves as you suggested, doing the paste within the menu itself. I did not change the menu structure itself yet, first I put all the text strings in a single function since I have at least 20 of them and I constantly add more. Today I will put all the paste commands in the menu's themselves.

Please let me know if you are able to determine why clicking on the menu suddenly takes focus off the last window that was active? I know that I can change focus to the prior window that was open using the acc command with no window name, but if I do that and then this new problem resolves itself, it will then make the focus change back to the window I clicked on prior to the unintentional change in cursor position that is currently happening (change, meaning focus changes to nowhere).

Is there a way to make this toolbar a standalone program or an exe, or do I have to run this within quick macros itself?

Thanks for your assistance.

Kevin
#4
What is your Windows version? If 10, what is its build number?
Does it happen when you click the toolbar, or when you click a menu (which is started from the toolbar)?
If toolbar, does it happen with any toolbar? I see there is a hook function, maybe it is the reason.
If menu, does it happen when the menu is started not from a toolbar too?
What window is then activated? To discover it, right-click the QM output area, select Log -> Window events, OK.
Tried to restart Windows?

Quote:Is there a way to make this toolbar a standalone program or an exe
No.
#5
Hi Gintaras,

I will answer as many questions as I can right now, I don't have that computer with me right now so I will have to get you more details later. I will first mention that the toolbar works fine on several computers, but not on the computer it was specifically built for. It works on my development workstation and on a random notebook I tried, but not the Microsoft Surface Pro 3 tablet that it is being used on (or is supposed to be used on). The toolbar user initially complained a few days prior to the complete failure that they needed to "double-click on the toolbar to get it to work", they explained that a single click didn't open up the menu and it would only open up the (drop-down) menu after double clicking the toolbar button - I even watched that user doing this double-clicking when we met in person so I could investigate the failure. I assumed the computer user was mistaken or they were confused about something, but I just realized that their statement might be relevant and perhaps they did in fact need to double-click a toolbar button to get the menu to open.

I think its important to point out that the computer is a tablet PC, the Microsoft Surface Pro 3, it has a touch screen which is used along with the onscreen keyboard. We do not attach a mouse or the detachable keyboard/touchpad cover, we just use the stylus and touchscreen. During my attempts to diagnose the issue, I would turn off the on-screen keyboard and use a mouse instead of the touchscreen, it had no effect on the problem. This computer is a fairly static environment, nothing gets installed on it, it does not get used for web browsing, it only runs RDP to connect to a remote system where all of the text entry is done. It has Dragon Voice recognition software that is used for dictation into that remote system, but even after turning off every part of the Dragon software, it didn't change anything.

The toolbar worked great on this computer (which was surprising to me)... the toolbar had the ability to paste across the RDP session, running side by side with the on-screen keyboard (used for handwriting recognition), and running side by side with the Dragon Voice dictation software..... all used to enter text into a software system accessed thru an remote desktop RDS session to a remote server.

Answers to your questions - in the order you asked them:

1. Windows 8.1 Pro (I believe its 8.1, otherwise its 8, I will get the build number as soon as I can).
2. It happens when you click on the toolbar itself - the initial click on any toolbar button deactivates the active window, you do not need to even move the mouse over a menu item, the second you click on the toolbar your cursor is removed from the window it was on.
3. There is a hook function, I added the _tb_auto_size function that I downloaded (thru a link found in the forum). I am not aware of how hook functions work or what they really are to start with, I simply used the sample code I downloaded and I figured out how to integrate it into my toolbar. The hook function is used on all 3 computers (2 that work and the 1 that doesn't), but I can remove it from the computer with the problem and see if that resolves the problem. I will get back to you on that. If it starts working properly without the auto_size function, would we be able to determine why that is the case so that I can continue to use the auto-size feature?
3. I will try to see what window is activated when I have that computer next, I will try to get access to it today.
4. I restarted QM, I restarted the computer, I even installed the latest version of QM (I had one version older than the most current). I deleted the entire program folder completely and installed a fresh copy from my development workstation by importing every toolbar, function and menu. I even used Windows System restore to revert back to a system state that was saved a week prior.... I thought that maybe the latest Windows Update caused the problem. None of those remedies helped...

The only thing I didn't try was to completely remove QM, reboot, then reinstall a fresh copy of QM. I am fairly sure that this is somehow related to the Microsoft Surface Pro tablet itself since the toolbar program works fine on 2 other computers, but I need to figure out what happened. I right clicked the toolbar and tried toggling every possible option on or off, no change. I can also try exporting my QM settings and importing them to the Surface Pro 3 tablet, maybe that will change something?

I will try to get the computer here today so I can check the build number and try to see which window is activated. I should be able to reply within the next few hours. I am in Eastern Time USA (NJ), may I ask what time zone you are in and/or what times of day you are typically online and able to answer questions? Knowing this will help me determine if I should bother having the person bring the computer to me this afternoon or if I should just wait until I see them tomorrow in the late morning.

Let me know if you have any ideas... I appreciate your help.

Kevin
#6
A QM toolbar can be attached to a window or not. Try to change it. If now attached, remove the window trigger, else add a window trigger.

The hook function probably is not the reason, but try to remove the /hook __tb_auto_size line.

The "Log window events" tool would show what windows are activated when the toolbar clicked first time and second time.

Quote:I right clicked the toolbar and tried toggling every possible option on or off
Can suspect "Activate owner window on click". Possibly the window is attached to a wrong window, because its trigger matches that window. Then need to edit the trigger.

Quote: I can also try exporting my QM settings and importing them to the Surface Pro 3 tablet, maybe that will change something?
Probably not.

My time is GMT+2, Lithuania. Now here is ~21:00. Usually I am at or near my PC 8:00 - 22:00.

Quote: If I want to sell ....
Alternatively we can create a toolbar that works in exe. It could have less options, maybe not attached to a window, and maybe would not have that problem. Because not many people will want to buy licenses and install QM.

To send email or private message, there are small icons at the right from this text.


Forum Jump:


Users browsing this thread: 1 Guest(s)