auth100488 Posted August 28, 2015 Posted August 28, 2015 Hi guys, i'm trying to change data via GUICtrlSetData when two keys are pressed.I've been lurking the forums but i haven't found a way to do it that works.So far i've tried using :$hMain = GUICreate("",810,75,2475,980, $WS_POPUP, 0x00080028) _WinAPI_SetLayeredWindowAttributes($hMain, 0, 100) Global $labelex = GUICtrlCreateLabel("", 5, 5, 150, 25) Global $labelexvalue = GUICtrlCreateLabel("", 25, 5, 150, 25) Global $labelc = GUICtrlCreateLabel("", 5, 650, 150, 25) Global $labelcvalue = GUICtrlCreateLabel("", 25, 650, 150, 25) Local $try1 Local $try2 Local $aAccelKeys[2][2] = [["^c", $try1], ["^n", $try2]] GUISetAccelerators($aAccelKeys) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $try1 MsgBox($MB_SYSTEMMODAL, "", "whatever") EndSwitch WEndBut when i hit CTRL + c it does not work. (Copy)I have also tried with the "Case _Ispressed("11", $hDLL) And _Ispressed("43", $hDLL) It works even though i haven't pressed any key. Ultimately all i want to do is to display some informations through the GUICtrlSetData based on whats in the clipboard.I already go the clipboard part figured out in two separate function ... but i still can't figure out how to do this. Thanks a lot for your time/help.
bobsyuruncle Posted August 28, 2015 Posted August 28, 2015 (edited) Could you use hotkeyset instead?*edit: probably can't use ctrl+c if your objective is to capture the clipboard as it will probably intercept the command.$hMain = GUICreate("",810,75,2475,980, $WS_POPUP, 0x00080028) _WinAPI_SetLayeredWindowAttributes($hMain, 0, 100) Global $labelex = GUICtrlCreateLabel("", 5, 5, 150, 25) Global $labelexvalue = GUICtrlCreateLabel("", 25, 5, 150, 25) Global $labelc = GUICtrlCreateLabel("", 5, 650, 150, 25) Global $labelcvalue = GUICtrlCreateLabel("", 25, 650, 150, 25) Local $try1 Local $try2 ;Local $aAccelKeys[2][2] = [["^c", $try1], ["^n", $try2]] ;GUISetAccelerators($aAccelKeys) GUISetState(@SW_SHOW) HotKeySet("^c", "whatever") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $try1 MsgBox($MB_SYSTEMMODAL, "", "whatever") EndSwitch WEnd Func whatever() ;grab windows clipboard ;do your GUICtrlSetData EndFunc Edited August 28, 2015 by bobsyuruncle update for intercept
auth100488 Posted August 28, 2015 Author Posted August 28, 2015 Could you use hotkeyset instead? $hMain = GUICreate("",810,75,2475,980, $WS_POPUP, 0x00080028) _WinAPI_SetLayeredWindowAttributes($hMain, 0, 100) Global $labelex = GUICtrlCreateLabel("", 5, 5, 150, 25) Global $labelexvalue = GUICtrlCreateLabel("", 25, 5, 150, 25) Global $labelc = GUICtrlCreateLabel("", 5, 650, 150, 25) Global $labelcvalue = GUICtrlCreateLabel("", 25, 650, 150, 25) Local $try1 Local $try2 ;Local $aAccelKeys[2][2] = [["^c", $try1], ["^n", $try2]] ;GUISetAccelerators($aAccelKeys) GUISetState(@SW_SHOW) HotKeySet("^c", "whatever") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $try1 MsgBox($MB_SYSTEMMODAL, "", "whatever") EndSwitch WEnd Func whatever() ;grab windows clipboard ;do your GUICtrlSetData EndFunc Well I've tried your solution before but it wasn't working well because it binds my CTRL +C to the program .. by that i mean i cannot copy new text once the programs is started.(Or am I missing something here?¿)
BrewManNH Posted August 28, 2015 Posted August 28, 2015 Accelerator keys don't work like that, the second parameter is a control that the key is tied to, not a random variable.Try it this way, the accelerator keys are tied to the labels $labelc and $labelex; *** Start added by AutoIt3Wrapper *** #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <WindowsConstants.au3> ; *** End added by AutoIt3Wrapper *** #AutoIt3Wrapper_Add_Constants=n $hMain = GUICreate("", 810, 75, -1, -1, $WS_POPUP) ;~ _WinAPI_SetLayeredWindowAttributes($hMain, 0, 100) Global $labelex = GUICtrlCreateLabel("", 5, 5, 150, 25) Global $labelexvalue = GUICtrlCreateLabel("", 25, 5, 150, 25) Global $labelc = GUICtrlCreateLabel("", 5, 650, 150, 25) Global $labelcvalue = GUICtrlCreateLabel("", 25, 650, 150, 25) Local $aAccelKeys[2][2] = [["^c", $labelex], ["^n", $labelc]] GUISetAccelerators($aAccelKeys) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $labelex MsgBox($MB_SYSTEMMODAL, "", "$labelex") Case $labelc MsgBox($MB_SYSTEMMODAL, "", "$labelc") EndSwitch WEnd If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
auth100488 Posted August 28, 2015 Author Posted August 28, 2015 (edited) Accelerator keys don't work like that, the second parameter is a control that the key is tied to, not a random variable.Try it this way, the accelerator keys are tied to the labels $labelc and $labelex; *** Start added by AutoIt3Wrapper *** #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <WindowsConstants.au3> ; *** End added by AutoIt3Wrapper *** #AutoIt3Wrapper_Add_Constants=n $hMain = GUICreate("", 810, 75, -1, -1, $WS_POPUP) ;~ _WinAPI_SetLayeredWindowAttributes($hMain, 0, 100) Global $labelex = GUICtrlCreateLabel("", 5, 5, 150, 25) Global $labelexvalue = GUICtrlCreateLabel("", 25, 5, 150, 25) Global $labelc = GUICtrlCreateLabel("", 5, 650, 150, 25) Global $labelcvalue = GUICtrlCreateLabel("", 25, 650, 150, 25) Local $aAccelKeys[2][2] = [["^c", $labelex], ["^n", $labelc]] GUISetAccelerators($aAccelKeys) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $labelex MsgBox($MB_SYSTEMMODAL, "", "$labelex") Case $labelc MsgBox($MB_SYSTEMMODAL, "", "$labelc") EndSwitch WEnd I really have no clue what's going on haha!even using this code ... the msgbox will not prompt:$hMain = GUICreate("",810,75,2475,980, $WS_POPUP, 0x00080028) _WinAPI_SetLayeredWindowAttributes($hMain, 0, 100) Global $labelex = GUICtrlCreateLabel("", 5, 5, 150, 25) Global $labelexvalue = GUICtrlCreateLabel("", 25, 5, 150, 25) Global $labelc = GUICtrlCreateLabel("", 5, 650, 150, 25) Global $labelcvalue = GUICtrlCreateLabel("", 25, 650, 150, 25) Local $aAccelKeys[2][2] = [["^c", $labelex], ["^n", $labelc]] GUISetAccelerators($aAccelKeys) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $labelex MsgBox($MB_SYSTEMMODAL, "", "$labelex") Case $labelc MsgBox($MB_SYSTEMMODAL, "", "$labelc") EndSwitch WEndBtw thanks a lot for trying to help me out! it is much appreciated!EDIT1: Nvm its working but i forgot to let you know of something important, the GUI will not be in focus.For your method to work i need to make sure its in focus, however, it act as an ... "info band" just something receiving informations to display. Edited August 28, 2015 by auth100488
kylomas Posted August 28, 2015 Posted August 28, 2015 Maybe this is what you are looking for...#include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> #AutoIt3Wrapper_Add_Constants=n $hMain = GUICreate("", 810, 75, 100, 100, $WS_POPUP, 0x00080028) _WinAPI_SetLayeredWindowAttributes($hMain, 0, 100) Global $labelex = GUICtrlCreateLabel("", 5, 5, 150, 25) Global $labelexvalue = GUICtrlCreateLabel("", 25, 5, 150, 25) Global $labelc = GUICtrlCreateLabel("", 5, 650, 150, 25) Global $labelcvalue = GUICtrlCreateLabel("", 25, 650, 150, 25) Local $try1 = GUICtrlCreateDummy() Local $try2 = GUICtrlCreateDummy() Local $aAccelKeys[2][2] = [["^c", $try1], ["^n", $try2]] GUISetAccelerators($aAccelKeys) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $try1 MsgBox($MB_SYSTEMMODAL, "", "whatever") Case $try2 MsgBox($mb_systemmodal, '', 'Whatever, again...') EndSwitch WEndkylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill
BrewManNH Posted August 28, 2015 Posted August 28, 2015 EDIT1: Nvm its working but i forgot to let you know of something important, the GUI will not be in focus.For your method to work i need to make sure its in focus, however, it act as an ... "info band" just something receiving informations to display.The whole point of Accelerator keys is that they're only active with the GUI in focus, otherwise a hot key would suffice. You can make it so that your hotkeys are only active wihen the GUI is in focus by checking WinActive, but that defeats the purpose as well. If you want to have it only work in your script, you'll have to use some unused hotkey combinations, and CTRL+C and CTRL+N are already taken for a lot of Windows programs. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
auth100488 Posted August 28, 2015 Author Posted August 28, 2015 First of all thanks a lot for your help (both of you).Since CTRL + C is already reserved by the system and that i need not to have the actual gui in focus, i went the HotkeySet way.Using an unbound key "F2" the user will be required to copy the text then press F2.. then the program will fetch the website data.This is now solved! thanks again!
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