Baritonomarchetto Posted June 25, 2012 Share Posted June 25, 2012 Hi, toying with "button pressing" I run into the different handling of inputs of this 2 functions: "IsPressed" rely on Hex values, "HotKeySet", instead, on "actual" keys (with some known ecception). This makes, i.e., difficult to set a variable in a .ini file and use it with both the functions. Is there a solution to this? Thanks Link to comment Share on other sites More sharing options...
abberration Posted June 25, 2012 Share Posted June 25, 2012 Would _HexToString help? Easy MP3 | Software Installer | Password Manager Link to comment Share on other sites More sharing options...
Baritonomarchetto Posted June 25, 2012 Author Share Posted June 25, 2012 (edited) Surely helps, thanks but what about the use of lowercase letters? Why capital letters are used (in hex format) in _IsPressed and not lowercase? Just asking because with "Send" and "HotKeySet" is better to use lowercase ... EDIT: Hmm, I had no success trying to use both _IsPressed and HotKeySet with the same variable, even converting string to hex (_StringToHex). Any solution to this? Thanks Edited June 25, 2012 by Baritonomarchetto Link to comment Share on other sites More sharing options...
abberration Posted June 25, 2012 Share Posted June 25, 2012 If you post an example script, we could be more helpful. I don't know exactly what your problem is. Easy MP3 | Software Installer | Password Manager Link to comment Share on other sites More sharing options...
Baritonomarchetto Posted June 25, 2012 Author Share Posted June 25, 2012 (edited) Let me explain: the function "IsPressed" accepts only a little (predefinite?) group of hex values. You can notice that letters are uppercase. While dealing with Send or HotKeyset, instead, it's generally good rule to use lower case letters. Than, if i define a variable and its hexLocal $var = i ;just an example: "i" could be a value loaded from an ini file Local $hexvar = _StringToHex($var)it's not handled correctly by IsPressed because it's not recognizedHotKeySet("$var", "myfunction") ... ... myfunction() ... If _IsPressed($hexvar, $hDLL) Then ... ...Tell me if i was not clear (veeery probable ) Edited June 25, 2012 by Baritonomarchetto Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 25, 2012 Moderators Share Posted June 25, 2012 Baritonomarchetto,Why are you using HotKeySet and _IsPressed on the same key in the same script? Why not just use one or the other? M23  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area  Link to comment Share on other sites More sharing options...
abberration Posted June 25, 2012 Share Posted June 25, 2012 If caps/uppercase is the problem, you can use StringLower or StringUpper to give a consistent upper or lowercase value. Easy MP3 | Software Installer | Password Manager Link to comment Share on other sites More sharing options...
BrewManNH Posted June 25, 2012 Share Posted June 25, 2012 _IsPressed will only accept the hex value of the uppercase letter, in other words, if your ini file has "i" in it, use StringUpper("i") to make it uppercase. Also, do not put the variable $var in quotes inside the hotkeyset, because it's not going to work that way. 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 Link to comment Share on other sites More sharing options...
Baritonomarchetto Posted June 25, 2012 Author Share Posted June 25, 2012 Baritonomarchetto,Why are you using HotKeySet and _IsPressed on the same key in the same script? Why not just use one or the other? M23I wrote a little script that uses _IsPressed, but i am not able to avoid that the key that trigger the script is sent. With HotKeySet the "key" is completely "hidden"... not sent Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 25, 2012 Moderators Share Posted June 25, 2012 Baritonomarchetto,Could you let us see an example of this "little script", because I am having trouble understanding what you mean. From your explanation above it sounds as if using only one of the two (HotKeySet) is exactly what you need. So why the two together? M23  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area  Link to comment Share on other sites More sharing options...
Baritonomarchetto Posted June 25, 2012 Author Share Posted June 25, 2012 _IsPressed will only accept the hex value of the uppercase letter, in other words, if your ini file has "i" in it, use StringUpper("i") to make it uppercase. Also, do not put the variable $var in quotes inside the hotkeyset, because it's not going to work that way. Thanks: i wrote those strings by heart, so it's very likely that contain errors Could it be a solution to write something like: Local $var = i Local $hexvar = _StringToHex(StringUpper($var)) Will the pressure of lowercase "i" on the keyboard ("captured" by HotKeySet) be seen by also by _IsPressed when uppercased? Link to comment Share on other sites More sharing options...
Baritonomarchetto Posted June 25, 2012 Author Share Posted June 25, 2012 Sure: i will show you something tomorrow (i have it in another PC and diggin it up to my mind is difficult for a newbie like me )Baritonomarchetto,Could you let us see an example of this "little script", because I am having trouble understanding what you mean. From your explanation above it sounds as if using only one of the two (HotKeySet) is exactly what you need. So why the two together? M23 Link to comment Share on other sites More sharing options...
Baritonomarchetto Posted June 26, 2012 Author Share Posted June 26, 2012 (edited) Ok, here we are: take a look at this (reduced) script please #include <Misc.au3> Local $hDLL = DllOpen("user32.dll") Local $keypressed = IniRead(".prog.ini", "key_assign", "key", 41) ;"A" in hex format Local $otherkey = IniRead(".prog.ini", "otherkey_assign", "otherkey", "i") ; "i" in dec format While 1 If WinActive("[CLASS:XLMAIN]") Then bpress() EndIf Sleep(50) WEnd func bpress() If _IsPressed($keypressed, $hDLL) Then Send($otherkey) While _IsPressed($keypressed, $hDLL) Sleep(5) WEnd EndIf EndFunc DllClose($hDLL) This allows you to send a "i" when "a" key is pressed. The problem is that also "a" is sent then you will write "ai". Notice also on the iniread that the format of the button pressed is hex ("_IsPressed" function deals with this) and the format of the "other key" is dec (to deal with send function). To obtain a sort of uniformation of formats for the key pressed and the other key sent, i thought to start dealing with HotKeySet. This solves the problem of the "ai" sending instaed of only "i" and uses dec format for keys BUT doesn't allow you to use i.e. parts like While _IsPressed($keypressed, $hDLL) Sleep(5) WEnd wich is usefull if you wanna stop a ciclying. Writing something like: While HotKeySet($keypresed) Sleep(5) WEnd doesn't stop the key being sent if the button is kept pressed This is essentially why i want to use both the functions ... So the questions are: 1) how can modify the script to avoid the send of the key (i.e. "a") that pressed triggers the "otherkey" (i.e. "i")? 2) Couldn't the formats be uniformed (dec hex) with some trick or, eventually, lower case letters be introduced in _IsPressed ? Thanks for the support Edited June 26, 2012 by Baritonomarchetto 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