PassWordRequester with keyboard access [Resolved]
Posted: Fri Feb 13, 2009 11:21 am
Hello at all
I want to create a PassWordRequester but only if i push the CTRL key in the time where i launch my application.
But the problem, is that when i press the key CTRL in the same time that i run the code, my windows loose the focus
It's funny but the TextGadget have the focus and not the windows
You believe you have the focus, but if you press any key, there are not character who appears
This is the code who don't work
A friend STEFOU (to the french forum) find to me a solution.
It's to simulate a click on the windows in a loop
It's works fine, but him and i knows it's not a really nice solution
Have you a better way to do that ??? :roll:
This is the code who work's fine
Thanks for your help
Good day
I want to create a PassWordRequester but only if i push the CTRL key in the time where i launch my application.
But the problem, is that when i press the key CTRL in the same time that i run the code, my windows loose the focus

It's funny but the TextGadget have the focus and not the windows

You believe you have the focus, but if you press any key, there are not character who appears

This is the code who don't work

Code: Select all
Procedure.s InputBox(Prompt$, TexteDefaut$, Password)
Enumeration
#FormMsgBox
#GadgetLabel
#GadgetText
#GadgetBoutonOk
EndEnumeration
Hwnd = OpenWindow(#FormMsgBox, 0, 0, 500, 100, "Entrée de données", #PB_Window_ScreenCentered|#PB_Window_BorderLess)
TextGadget(#GadgetLabel, 15, 8, 460, 30, Prompt$, #PB_Text_Center)
If Password = 1
Flags = #PB_String_Password
EndIf
StringGadget(#GadgetText, 15, 35, 460, 20, TexteDefaut$, Flags)
ButtonGadget(#GadgetBoutonOk, 365, 70, 60, 23, "OK")
StickyWindow(#FormMsgBox, #True)
Delay(500)
SetFocus_(Hwnd)
Repeat
Ev = WaitWindowEvent()
If (Ev = #PB_Event_Gadget And EventGadget() = #GadgetBoutonOk)
Text$ = GetGadgetText(#GadgetText)
Break
EndIf
ForEver
CloseWindow(#FormMsgBox)
ProcedureReturn Text$
EndProcedure
If GetAsyncKeyState_(#VK_CONTROL) < 0
CodeAcces$ = InputBox("Veuillez entrer le code d'acces", "", #True)
Debug CodeAcces$
Else
MessageRequester("Essai", "Ok pas de mot de passe")
EndIf
It's to simulate a click on the windows in a loop

It's works fine, but him and i knows it's not a really nice solution

Have you a better way to do that ??? :roll:
This is the code who work's fine

Code: Select all
Procedure.s InputBox(Prompt$, TexteDefaut$)
Enumeration
#FormMsgBox
#GadgetLabel
#GadgetText
#GadgetBoutonOk
EndEnumeration
OpenWindow(#FormMsgBox, 0, 0, 500, 100, "Entrée de données", #PB_Window_ScreenCentered|#PB_Window_BorderLess)
TextGadget(#GadgetLabel, 15, 8, 460, 30, Prompt$, #PB_Text_Center)
AddKeyboardShortcut(#FormMsgBox, #PB_Shortcut_Return, 13) ; Pour Return
StringGadget(#GadgetText, 15, 35, 460, 20, TexteDefaut$, #PB_String_Password)
ButtonGadget(#GadgetBoutonOk, 365, 70, 60, 23, "OK")
StickyWindow(#FormMsgBox, #True)
x = WindowX(#FormMsgBox)
y = WindowY(#FormMsgBox)
SetCursorPos_(x,y)
Repeat
mouse_event_(#MOUSEEVENTF_ABSOLUTE | #MOUSEEVENTF_LEFTDOWN, x, y, 0, 0)
mouse_event_(#MOUSEEVENTF_ABSOLUTE | #MOUSEEVENTF_LEFTUP, x, y, 0, 0)
Delay(10)
Until GetActiveWindow() = #FormMsgBox
SetActiveGadget(#GadgetText)
Repeat
Ev = WaitWindowEvent()
If (Ev = #PB_Event_Gadget And EventGadget() = #GadgetBoutonOk) Or (Ev = #PB_Event_Menu And EventMenu() = 13)
Break
EndIf
ForEver
CodeAcces$ = GetGadgetText(#GadgetText)
CloseWindow(#FormMsgBox)
ProcedureReturn CodeAcces$
EndProcedure
If GetAsyncKeyState_(#VK_CONTROL) < 0
Debug InputBox("Veuillez entrer le code d'acces", "")
Else
MessageRequester("Essai", "Ok pas de mot de passe")
EndIf
Good day