Despotis Posted November 6, 2019 Share Posted November 6, 2019 Hi community I'm completely new to the forums and AutoIt at all. I started desktop automation using AHK about four months ago and read about AutoIt two days ago. It seems, AutoIt is much more powerful than AHK, so i think it's worth a test. So i started to "rewrite" my main AHK script, which is used to manage windows (sizes and positions). Since i have multiple variations and don't want to have each and every key set as a hotkey, i'm working with "parameters". So for example make a chrome window ready for watching a youtube video, i press my "main" Hotkey "^#u" followed by "yt{enter}". Now AHK positions my browser in the left top corner and resizes it. If i enter "ytt{enter}", additionally youtube.com is opened. I'm doing this, using the Input function of AHK. Another usage is, that i pass X, Y coordinates as parameters. I'm using this kind of passing parameters a lot. AutoIt is working with Hotkeys in a completely different way. I checked several Postings and found out, that @HotKeyPressed is my friend. But unfortunately, there is no way to pass additional parameters to the function. _IsPressed seems to be a possibility, but there are 2 caveats for my use. First, i don't want the keys to be send to the current window (because i don't want to have a keylogger ;-)), second, i don't want to check each and every single key on my keyboard if it's pressed. I could use the InputBox, but i don't like to have this window opened every time i enter a Hotkey. I tried to open the InputBox with negativ X, Y coordinates to hide it, but then the script ignores it and doesn't wait for the input. So is there a kind of _Pressed function that returns the pressed key, or is there an invisible modal Input i just don't see? Thanks in advance, any help is appreciated. Link to comment Share on other sites More sharing options...
faustf Posted November 6, 2019 Share Posted November 6, 2019 hi if you want automate chrome firefox and more i suggest use this UDF also if is difficult to use (for me) i prefer automate with _IE for explorer you can find in help of autoit Link to comment Share on other sites More sharing options...
faustf Posted November 6, 2019 Share Posted November 6, 2019 look also this probably could help you https://www.autoitscript.com/autoit3/docs/functions/WinMove.htm you can set a shortcut in top of script for call a function to resize window Link to comment Share on other sites More sharing options...
Nine Posted November 6, 2019 Share Posted November 6, 2019 1 hour ago, Despotis said: Another usage is, that i pass X, Y coordinates as parameters. I'm using this kind of passing parameters a lot. How do you pass new X and Y coordinates on a key pressed ? I wonder... “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Despotis Posted November 6, 2019 Author Share Posted November 6, 2019 @faustf Thanks for your links, but i don't want to move, resize and manipulate not only browser windows. This was just an example. And yes, i'm aware of the WinMove function, which would be the most used function if i get a possibility to have parameters/multiple shortcut combinations. @Nine Quote How do you pass new X and Y coordinates on a key pressed ? I wonder... In AHK i have defined a shortcut ^#u which then calls the Input function. This function accepts user input. It's similar to the InputBox in AutoIt, but has no Box/Window. After that input i parse the given string and e.g. "p 50 100" calls WinMove($hWnd, "", 50, 100). So what i'm looking for is to get a string input after a Hotkey is pressed. The easiest way would be the possibility of hiding the InputBox when waiting for user input. Link to comment Share on other sites More sharing options...
faustf Posted November 6, 2019 Share Posted November 6, 2019 (edited) short cut call a function , the function read a keybord press HotKeySet Sets a hotkey that calls a user function. HotKeySet ( "key" [, "function"] ) https://www.autoitscript.com/autoit3/docs/functions/HotKeySet.htm Edited November 6, 2019 by faustf Link to comment Share on other sites More sharing options...
Despotis Posted November 6, 2019 Author Share Posted November 6, 2019 5 minutes ago, faustf said: short cut call a function , the function read a keybord press And this is the question. I can't find a function that returns the currently pressed key. I only find _IsPressed, which implicates, that i know what key has to be pressed. 😉 And the most important thing, the pressed key should not be passed to the active application. Iow, i don't want the input entered in notepad.exe if this is the active application. Link to comment Share on other sites More sharing options...
Nine Posted November 6, 2019 Share Posted November 6, 2019 21 minutes ago, Despotis said: It's similar to the InputBox in AutoIt, but has no Box/Window. Can you show me what it looks like ? You could simply create a small GUI for that purpose if you don't like inputBox “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
faustf Posted November 6, 2019 Share Posted November 6, 2019 _IsPressed is good solution i think , google is your friend Musashi 1 Link to comment Share on other sites More sharing options...
Nine Posted November 6, 2019 Share Posted November 6, 2019 Ok, I think I understand what you want. After pressing a HotKeySet, you want to simply key in a certain pattern without any box, without even seeing what you are typing. Is that it ? If so you could use a hook and a callback to register the keys you typed until a certain key is entered (like {ENTER} for example). “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
AdamUL Posted November 6, 2019 Share Posted November 6, 2019 Have a look at the HotStrings UDF. Adam Link to comment Share on other sites More sharing options...
Despotis Posted November 7, 2019 Author Share Posted November 7, 2019 On 11/6/2019 at 2:56 PM, Nine said: Ok, I think I understand what you want. After pressing a HotKeySet, you want to simply key in a certain pattern without any box, without even seeing what you are typing. Is that it ? If so you could use a hook and a callback to register the keys you typed until a certain key is entered (like {ENTER} for example). Yes, you got me right! 🙂 I'm trying to use shortcuts in a similar way emacs or vim does. I will check for hooks and callbacks in AutoIt, although i'm close to accept the InputBox. It looks really ugly and since i'm just using hotkeys it makes no sense to have an input box at all. 19 hours ago, AdamUL said: Have a look at the HotStrings UDF. This looks great, but doesn't really work for my problem. 1) Quote Modifiers are not supported, for example ^a for {CTRL}a. This is not CaSE SenSiTiVE. 2) The keystrokes are not "intercepted/absorbed". So when i'm typing in a shortcut, the text is written into the active window. I really wonder, why there is no simple Input in AutoIt like in AHK, although it seems to be much more powerful at all. Link to comment Share on other sites More sharing options...
Nine Posted November 7, 2019 Share Posted November 7, 2019 (edited) Maybe something like this ? expandcollapse popup#include <Constants.au3> #include <GUIConstants.au3> #include <WinAPI.au3> HotKeySet ("{F1}", "TestPattern") HotKeySet ("{END}", "_Exit") While True Sleep (100) WEnd Func TestPattern () Local $aPattern = GetPattern ("^(\d+) +(\d+)$") If Not IsArray ($aPattern) Then Return MouseMove ($aPattern[0], $aPattern[1]) EndFunc Func GetPattern($sRegExp) Local $hGUI = GUICreate("", 200, 200, 663, 317, $WS_POPUP, $WS_EX_LAYERED) GUISetBkColor(0x0000FF) Local $idTxt = GUICtrlCreateInput("", 0, 0, 150, 20, -1) _WinAPI_SetLayeredWindowAttributes($hGUI, 0x0000FF) GUISetState() Local $aTxt While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idTxt $aTxt = StringRegExp (GUICtrlRead ($idTxt),$sRegExp, $STR_REGEXPARRAYMATCH) If Not @error then ExitLoop EndSwitch WEnd GUIDelete () Return $aTxt EndFunc ;==>GetPattern Func _Exit () Exit EndFunc Enter 2 numbers separated by a space (e.g. 100 200) then press Enter...You can use getpattern func in all cases where you need to key in some parameters. Edit : include regexp validation Edited November 7, 2019 by Nine “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Zedna Posted November 7, 2019 Share Posted November 7, 2019 (edited) Use AHK as primary wrapper EXE for hotkeys (as it has all hotkeys funcionality you want) and Autoit as secondary EXE for all other program logic. Run AutoIt's secondary EXE from AHK when needed (after each hotkey processing). Edited November 7, 2019 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search 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