Finding available shortcut keys (originally "Where's the 'New Window' command?")
-
@Ekopalypse said in Finding available shortcut keys (originally “Where’s the ‘New Window’ command?”):
while True: result = notepad.messageBox('','', MESSAGEBOXFLAGS.ABORTRETRYIGNORE) if result != MESSAGEBOXFLAGS.RESULTRETRY: breakOkay, but where do I put the code that I want it to retry, and where do I put the code that tests whether to show the MessageBox? (without having to duplicate either of those?)
@Alan-Kilborn said in Finding available shortcut keys (originally “Where’s the ‘New Window’ command?”):
It boggles the mind
Yeah, but isn’t it nice to know that your mind can still be boggled? 😁
Stop Script should only be run from the menus as a last resort
This was a stopgap measure for me - a placeholder until I could understand my difficulties with scope for variables. I think I got that under control; I just need to test it out and then I’ll do like you said.
-
@TBugReporter said in Finding available shortcut keys (originally “Where’s the ‘New Window’ command?”):
Okay, but where do I put the code that I want it to retry
while True: result = notepad.messageBox('','', MESSAGEBOXFLAGS.ABORTRETRYIGNORE) if result != MESSAGEBOXFLAGS.RESULTRETRY: break # code to redo goes hereor alternately, if it makes more sense to you,
while True: result = notepad.messageBox('','', MESSAGEBOXFLAGS.ABORTRETRYIGNORE) if result == MESSAGEBOXFLAGS.RESULTRETRY: # code to redo goes here else: break # code to redo goes here -
It seems to me that that structure won’t do the “code to redo” a first time without first putting up the A/R/I box…?
-
It seems to me that that structure won’t do the “code to redo” a first time without first putting up the A/R/I box…?
Then put the code in whatever order you think is logical for your needs.
while True: # code to do every loop goes here result = notepad.messageBox('','', MESSAGEBOXFLAGS.ABORTRETRYIGNORE) if result != MESSAGEBOXFLAGS.RESULTRETRY: break -
@PeterJones
I’ve now tried this …def bailout(msg): print(msg) user_response = notepad.messageBox(msg, "Error", MB_CANCELTRYCONTINUE | MB_ICONWARNING) if user_response == MB_RESULTCANCEL: notepad.runPluginCommand('Python Script', 'Stop Script') else: return user_response def main(): # ... while True: sk_mapper_hwnd = user32.FindWindowW(None, u"Shortcut mapper") if not sk_mapper_hwnd: action_to_take = bailout("Mapper window not found!") if action_to_take != MB_RESULTTRYAGAIN: break # ...… but that gives me …
UnboundLocalError: local variable 'action_to_take' referenced before assignmentWhere did I go wrong?
-
Scope problem. An if-block introduces a new scope and the variables defined there are only valid within this scope. Either the comparison with
MB_RESULTTRYAGAINis indented to have it in the same scope, oraction_to_takemust be defined at the same scoping level as the comparison. -
I don’t know that I like the trend of this thread. It seems we’re teaching Python??
-
@Alan-Kilborn please can i get your attention? I need help pls
-
@Mendella-Replacement said in Finding available shortcut keys (originally “Where’s the ‘New Window’ command?”):
@Alan-Kilborn please can i get your attention? I need help pls
-
This discussion has stopped being about “new window” or about “shortcut keys”, and really ceased even being about Notepad++. And now it’s even attracting random posts as well.
This topic is being locked. If anyone has Noteapd++ related discussion, a new topic can be started quite easily; if you need to, provide a link back to this discussion for reference.
-
P PeterJones locked this topic on
-
A Alan Kilborn referenced this topic on
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login