Magikarp7 Posted November 11, 2017 Share Posted November 11, 2017 Hi! I was trying to make a program with an in-built calculator on a separate tab. The calculator works fine with the operators. But the problem is that when I press the "Enter" key it only functions on the form and when I focus on an internet browser, like GOOGLE, the enter key won't work anymore when I type something in google. I know that the program is still running. But I set the hotkeys to not work when the GUIform is not active. How do I fix this? Any help will be appreciated! Gonna post some snippets of the code. Func PressEqual() If WinActive($TrackerForm) Then MsgBox() EndIf EndFunc Link to comment Share on other sites More sharing options...
Magikarp7 Posted November 11, 2017 Author Share Posted November 11, 2017 (edited) Hi! I was trying to make a program with an in-built calculator on a separate tab. The calculator works fine with the operators. But the problem is that when I press the "Enter" key it only functions on the form and when I focus on an internet browser, like GOOGLE, the enter key won't work anymore when I type something in google. I know that the program is still running. But I set the hotkeys to not work when the GUIform is not active. How do I fix this? Any help will be appreciated! Gonna post some snippets of the code.The calculator has 2 inputboxes. One inputbox is for the output and the other is a real time tracker of what the user types in. expandcollapse popupFunc PressEqual() If WinActive($TrackerForm) Then MsgBox(0,"","Enter working!") EndIf EndFunc Switch GUICtrlRead($Tab1) Case 3 ;this is the tab where my calculator is programmed. If WinActive($TrackerForm) Then HotKeySet("{NUMPAD0}", "Press0") HotKeySet("{0}", "Press0") HotKeySet("{NUMPAD1}", "Press1") HotKeySet("{1}", "Press1") ;... ;etc. etc. etc. for the other hotkeys. HotKeySet("{+}", "PressAdd") EndIf Case Else HotKeySet("{NUMPAD0}") HotKeySet("{0}") HotKeySet("{NUMPAD1}") ;... ;etc. etc. etc. for the other hotkeys.. HotKeySet("{ENTER}") EndSwitch Func PressAdd() If WinActive($TrackerForm) Then $getCalcresult = GUICtrlRead($calcresult) ;this inputbox displays the result $getCalcreader = GUICtrlRead($calcreader) ;real time inputbox. If $getCalcresult = "" And $getCalcreader <> "" Then $FirstNum = GUICtrlRead($calcreader) GUICtrlSetData($calcresult, $FirstNum & " + ") EndIf If $getCalcresult <> "" And $getCalcreader <> "" Then If StringInStr($getCalcresult, "+") Then $FirstNum = $getCalcresult + $getCalcreader GUICtrlSetData($calcresult, $FirstNum & " + ") EndIf If StringInStr($getCalcresult, "-") Then $FirstNum = $getCalcresult - $getCalcreader GUICtrlSetData($calcresult, $FirstNum & " + ") EndIf If StringInStr($getCalcresult, "*") Then $FirstNum = $getCalcresult * $getCalcreader GUICtrlSetData($calcresult, $FirstNum & " + ") EndIf If StringInStr($getCalcresult, "/") Then $FirstNum = $getCalcresult / $getCalcreader GUICtrlSetData($calcresult, $FirstNum & " + ") EndIf EndIf GUICtrlSetData($calcreader, "") EndIf EndFunc Edited November 11, 2017 by Jos added codebox Link to comment Share on other sites More sharing options...
Developers Jos Posted November 11, 2017 Developers Share Posted November 11, 2017 Have you tried setting the button style $BS_DEFPUSHBUTTON ? Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Developers Jos Posted November 11, 2017 Developers Share Posted November 11, 2017 (edited) Why did you create a new topic in Examples while you have the question already posted in the other thread? Merged and moved to support Jos Edited November 11, 2017 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
argumentum Posted November 11, 2017 Share Posted November 11, 2017 if you HotKeySet("{NUMPAD1}", "Press1") then, to free it up, you'd need HotKeySet("{NUMPAD1}", "") But I'd use GUISetAccelerators(). Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now