Leaderboard
Popular Content
Showing content with the highest reputation on 02/21/2021 in all areas
-
Ctrl C doesn't work, help me please(
FrancescoDiMuro and 3 others reacted to MrCreatoR for a topic
The problem perhaps is with your keyboard layout set by default, as i see it (from your screenshot), you have Russian system, so probably the default keyboard layout is Russian, to fix it use this (set English as default at start, and reset to the previous one at the end): #include-once #include <WinAPIEx.au3> Global $iKbrdLayout, $aKbrdLayouts OnAutoItExitRegister('__HotKeySendFix_OnExit') __HotKeySendFix_OnStart() Run("notepad.exe") sleep(1000) Send("OK") sleep(1000) Send("^a") send("^c") send("^v") Func __HotKeySendFix_OnStart() $iKbrdLayout = 0x0409 ;English $aKbrdLayouts = _WinAPI_GetKeyboardLayoutList() _WinAPI_LoadKeyboardLayout($iKbrdLayout, $KLF_ACTIVATE) EndFunc Func __HotKeySendFix_OnExit() For $i = 1 To Ubound($aKbrdLayouts) - 1 If Hex($iKbrdLayout) = Hex('0x' & StringRight($aKbrdLayouts[$i], 4)) Then Return EndIf Next _WinAPI_UnloadKeyboardLayout($iKbrdLayout) EndFunc4 points -
@E1M1 I definitely understand what you are saying. I will most likely consider an "out of tree" examples section in the future, maybe it can even be maintained by the community if it gets enough momentum. Anyway, thanks for your input @JockoDundee Whoa, that's some A-level reporting, were you perhaps a journalist at any point in your life?2 points
-
EasyCodeIt - cross-platform AutoIt implementation
TheSaint and one other reacted to JockoDundee for a topic
Fledgling Startup EasyCodeIt Faces Division Over Direction (Feb 20, 2021 - Wire Services) Citing concerns about a perceived dearth of example code, a small but vocal faction of the burgeoning ECI community shared their belief that greater resources invested towards example scripts would, in the end lead to greater “views”, and ultimately “more click on [the] project”. With a shout-out to the iconic, if aging Id title, poster E1M1, speaking for the faction argued: This latest provocation threatens to widen the bifurcation started previously when E1M1 noted simply that such a directory might be “cool”, and was decidedly vague about implementation details. The response from the reclusive and enigmatic “TheDcoder” was swift and unambiguous, countering “cool” with “tedious” and ending with a classic punctuating emoji. What TheDcoder’s response to this latest more aggressive salvo is anyone’s guess, known for being wildly unpredictable, there’s just no telling what his next move may be as the fate of ECI hangs in the balance Stay tuned - this is breaking news...2 points -
This is based on this topic. With this UDF, you can define all the HotKeySet you want on any of the keyboards. The keys registered as HotKeySet are not sent to the active window. I also created a "Event-driven" mode for lengthy procedure. There is still the immediate action mode for short procedure. Note that in Event-driven mode, you will need to create an close loop to intercept the HotKey events. Events are asynchronous. In Event-driven mode only one procedure can be running at a given time. But immediate action procedure can interrupt a Event-driven procedure. All procedures are declared as actual function (without quotes). It is important that lengthy procedure should be declared as Event-driven, otherwise the system may become unstable. Version 2024-01-04 * Added support to {LEFT} and {RIGHT} keys * Added more information about keyboards in list * Added new parameter to _MKHKS_Initialize to exclude a specific keyboard from the list. To do so, you simply provide partial part (as a string) of the device name. Version 2024-01-03 * Added support to Send command, Hotkey must be set for the first keyboard. Version 2022-12-22 * Added support to register the same Hotkey on multiple keyboards (same or different functions) * Added possibility to unregister a Hotkey for a particular keyboard * Added validation on registering the same Hotkey twice It may happen that the list would provide more keyboards than they are actually connected. To exclude one particular keyboard, you could run the following example and test the hotkeys (0, 1, 2, ...) on each keyboard to see which ones are responding. Then you can provide partial string of the device to be excluded with the _MKHKS_Initialize function. #include "MKHKS-UDF.au3" Example() Func Example() HotKeySet("{END}", _Exit) Local $iNumKB = _MKHKS_Initialize() For $i = 0 To $iNumKB - 1 _MKHKS_Register_HotKey(String($i), _Test, $i, False) ; set hotkey to keyboard number (0, 1, 2,...) Next While Sleep(50) WEnd EndFunc ;==>Example Func _Exit() Exit EndFunc ;==>_Exit Func _Test() ConsoleWrite("Test succeeded - " & @HotKeyPressed & " was Key Pressed" & @CRLF) EndFunc ;==>_Test As usual if you have any suggestion, I would be very interested to hear them. MKHKS-UDF.zip1 point
-
Majority of users of AutoIt language likes it because it's easy to learn and very powerful when it comes to automating some basically very complicated stuff on windows. AutoIt often does it in just one line of code while doing it in other languages would be writing a full book of code. How to use AutoIt with other languages? One way would be to use AutoItX. Dll version of AutoIt. In this case you can access it through COM or exported functions. Downside surely is limited number of available functions and user rights for COM option. Other way is... no wait, there is no other way. But, what If I add some magic salt to the soup? Let's say I use some of the code from (thanks Manadar) and, yes you guessed AutoItObject, and make a simple (the most basic) COM server that exports almost the whole AutoIt functionality to anyone wanting to use it. AutoItObject 1.2.8.0 makes objects published to ROT (running object table) more accessible than ever. Accessing the object is as easy as GetObject(...) in any scripting language and CoGetObject() through Windows API. An example of VBS would be: Javascript could be: C# PowerShell (based on ptrex's example) Python (AdmiralAlkex) ...and so on. Server script is really minimalistic: All packed in ZIP: AccessAutoIt.zip What you'll find there is folder named AccessAutoIt. Unzip it somewhere and inside there will be five files: AutoItObject.au3 (1.2.8.0), AutoItServer.au3, Csharp.cs, JS.js and VBS.vbs. Run AutoItServer.au3 and then either vbs or js script or compile Csharp.cs and run resulting executable. I have chosen AutoIt.Application object moniker for no particular reason. Can be anything. Latest AutoItObject, if you want the whole thing, is here. AutoIt on your palm. edit: Added c# example. Don't mind about my usage of other languages. I'm not quite familiar with them.1 point
-
Appears that function isn't available in AutoItX, so you won't be able to use it in Python.1 point
-
Use \$ as in PCRE $ alone has its own meaning1 point
-
Peace Equalizer shows power of AutoIt
argumentum reacted to PeterVerbeek for a topic
I've released the new version 1.5.6.4 of Peace. Besides several minor improvements this version it includes an improved headphones and hearing test interface.1 point -
Ctrl C doesn't work, help me please(
argumentum reacted to KTiger for a topic
Thank you very much, guys! The problem has been solved. I have changed keyboard layout to English in "settings". Thank you again!!!1 point -
Ctrl C doesn't work, help me please(
KTiger reacted to argumentum for a topic
..yes. It does it's thing in English and restores the previous keyboard layout on exit.1 point -
Unselectable Menu!
Dan_555 reacted to argumentum for a topic
Alt-m "Alt-m" then "s" ( if that don't work, then i'll be up for an apology )1 point -
Every now and then I come back to my two big monitors and I can't find the mouse cursor. I'm moving the mouse around but don't seem to be looking in the right place or the right screen. In a few seconds I feel like and idiot and it is very irritating. So finally I wrote a program that waits for 5 minutes of idletime (no keyboard or mouse movement) and draws a nice red circle around the mouse cursor. That I can spot easily, even from across the room as I walk up to the computer. It works nicely coming back from sleep mode if I press a key. If I moved the mouse to come out of sleep I can press the middle mouse button to show the red ring. As soon as I move the mouse it disappears. It has a tray menu so you can change the amount of idletime before it turns on and there is another menu choice to Exit. You can compile the script and set a link in your start menu to come on every day if you like it. I'm attaching a circle icon for the taskbar icon and the exe icon in case want to use it. Thanks to Bam and martin for the circle code using window regions ;circle around mouse cursor #AutoIt3Wrapper_Icon=circle2.ico #NoTrayIcon #include <GUIConstants.au3> #include <WindowsConstants.au3> #include <timers.au3> #include <misc.au3> ;Thanks to Bam and martin for the circle code using window regions https://www.autoitscript.com/forum/topic/85970-draw-a-circle-around-the-mouse/ Global $IdleTime = 5 * 60000 ;change the 5 to the number of minutes before circle appears Opt("TrayMenuMode", 3) ;The default tray menu items will not be shown and items are not checked when selected. These are options 1 and 2 for TrayMenuMode. Opt("TrayOnEventMode", 1) ; Use event trapping for tray menu TraySetToolTip("ms-circle") TrayCreateItem("SetTime") TrayItemSetOnEvent(-1, "__SetTime") TrayCreateItem("Exit") TrayItemSetOnEvent(-1, "_bye") TraySetIcon("circle2.ico") TraySetState() $iCircleR = 20 ; <=== Edit this for different circle radius (in pixels) $iCircleD = $iCircleR * 2 $pt = MouseGetPos() $GUI = GUICreate("test", $iCircleD, $iCircleD, $pt[0] - $iCircleR, $pt[1] - $iCircleR, $WS_POPUP, $WS_EX_TOPMOST) GUISetBkColor(0xFF0000) $a = _CreateRoundRectRgn(0, 0, $iCircleD, $iCircleD, $iCircleD, $iCircleD) $b = _CreateRoundRectRgn(4, 4, ($iCircleD - 8), ($iCircleD - 8), ($iCircleD - 4), ($iCircleD - 4)) _CombineRgn($a, $b) _SetWindowRgn($GUI, $a) GUISetState(@SW_HIDE) While 1 Sleep(250) _chk_Idle() WEnd ;*** Functions *** Func _CreateRoundRectRgn($l, $t, $w, $h, $e1, $e2) $ret = DllCall("gdi32.dll", "long", "CreateRoundRectRgn", "long", $l, "long", $t, "long", $l + $w, "long", $t + $h, "long", $e1, "long", $e2) Return $ret[0] EndFunc ;==>_CreateRoundRectRgn Func _CombineRgn(ByRef $rgn1, ByRef $rgn2) DllCall("gdi32.dll", "long", "CombineRgn", "long", $rgn1, "long", $rgn1, "long", $rgn2, "int", 3) EndFunc ;==>_CombineRgn Func _SetWindowRgn($h_win, $rgn) DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $h_win, "long", $rgn, "int", 1) EndFunc ;==>_SetWindowRgn Func __SetTime() Local $sd, $min $sd = "Number of minutes" $min = InputBox("Now " & $IdleTime / 60000 & " minutes", $sd, "", "", -1, 122 + (13.2 * UBound(StringRegExp($sd, '\R', 3)))) if $min > 0 then $IdleTime = $min * 60000 EndFunc ;==>__SetTime Func _bye() ToolTip("Exiting") Sleep(1000) ToolTip("", 500, 300) Exit EndFunc ;==>_bye Func _chk_Idle() If _Timer_GetIdleTime() > $IdleTime Or _IsPressed(04) Then ;1 minutes idle Local $wh = WinGetHandle("[active]") $pt = MouseGetPos() GUISetState() GUISetState(@SW_DISABLE) If Not @error Then WinMove($GUI, "", $pt[0] - $iCircleR, $pt[1] - $iCircleR) WinActivate($wh) While 1 $ap = MouseGetPos() If $ap[0] <> $pt[0] Then ExitLoop EndIf Sleep(1000) WEnd GUISetState(@SW_HIDE) EndIf EndFunc ;==>_chk_Idle circle2.ico1 point
-
Another good example of what not to use : Send and MouseClick. Try this instead : Run("notepad.exe") $hWnd = WinWait("[CLASS:Notepad]") ControlSetText($hWnd, "", "Edit1", "OK") Sleep(2000) ; time for you to see the text ControlSetText($hWnd, "", "Edit1", "New Text")1 point
-
I use this setting too and never had to search my mouse pointer since. https://www.isunshare.com/windows-10/show-pointer-location-with-ctrl-key-in-windows-10.html1 point
-
It works fine and simply overrides all the selected text, so the old OK is replaced by the new OK. ;) try: Run("notepad.exe") sleep(1000) Send("OK") sleep(1000) Send("^a") send("^c") Send("{right}") send("^v") Jos1 point
-
Press and drag up item in list
thanhvu909x reacted to Nine for a topic
How do you think we can help you with this kind of information ? If you want us to help you, you will need to help us first. Make a runable script that we can actually execute. Since we do not have the application you are using, I suggest you create a snippet running PAINT (or any other app that we all have).1 point -
@E1M1 That does sound cool, but I am a bit hesitant to do something like that for several reasons. I mostly want to keep the tree clean for now and since the code is at the rapid evolution stage, starting to write documentation can become a tedious task. I am having enough trouble as-is And since ECI is mostly the same syntax as AutoIt, there wouldn't be much trouble looking up AutoIt documentation in the interim.1 point
-
Hi Folks, this is a simple example of how to generate a function with and call it during runtime (+ pass data from/to it). It is accomplished by using AutoItObject and inspired by Access AutoIt. #include <AutoItGenFuncEx.au3> $iSleepTime = 500 $oFunction = _AutoItGenFuncEx_CreateFunction("$iTreshold", _; <------ What are the Parameters? '' _; <------ What is the Sourcecode? & @LF & 'For $i = 1 to 100' _ & @LF & ' IF $i <= $iTreshold then ' _ & @LF & ' Sleep(10)' _ & @LF & ' Else' _ & @LF & ' Sleep($iSleepTime) ; slower at the end.' _ & @LF & ' EndIf' _ & @LF & '' _ & @LF & ' ToolTip("Counter:" & $i)' _ & @LF & 'Next', _ "") ; <------ What should be returned? If IsObj($oFunction) Then $oFunction.Call(Random(90, 95, 1)) EndIf There are many discussions about running "dynamic" autoit code on the internet - and there are a lot of alternatives for this. And almost always, it is absolutely not necessary to do such a thing as generating function code at runtime, because you're better off with a different program design choice. My need for this came from a very special use case. People have tried to approach this problem in several ways each with it's own set of advantages and limitations - very simple tasks can be accomplished with Execute(), Call(), Eval(), Assign(), or running source with /AutoItScriptExecuteLine or /AutoItScriptExecute, more advanced tasks can usually be tackled with multiple scripts communicating with each other via files, console streams, windows messages, tcp, dllcallbacks, etc. The most advanced discussions I've found on this included to get 'autoit function pointers', adding threads to the autoit script or copying the function into a new process, which, to my knowledge, have never been really successful, stable, or easy to use. - and this UDF is no exception because it still comes with it's limitations: For example you can't use ByRef parameters at all and global variables from the main program are just copies - but not actual references. Threads / Alternatives: Dynamic functions Is it possible to find out the memory address of a internal function and retreive the struct of it? _DllCall.au3 Callback - no external library (dll) required DotNet.au3 DotNet.au3 UDF to access .NET Framework from AutoIt Lua.au3 Embedding Lua scripts in AutoIt AssembleIt _AssembleIt() for FASM.au3 now with "Debugger" Standalone Example The goal of the standalone script is to showcase the idea & inspire people to explore AutoItObjects and the RoT. Simple UDF "AutoItGenFunc" The goal of the UDF is to have an easy way for beginners and lazy people to use way to allow "complex" AutoIt Coding to be executed during Runtime. Extended UDF "AutoItGenFuncEx" The goal of the extended UDF is to have an easy to use way for beginners and lazy people to allow even more "complex" AutoIt Coding (callbacks) to be executed during Runtime. Download within the corresponding Spoilers, or find version history below: Update 17.02.2021: - added parameter to keep functions alive, see Example #5 - Global Variables are now changeable and copied back into the main script, see Updated Example #4. - added $oFunction.Source which stores the AutoIt-Source of the generated file for debugging purposes. - better handling of global vars and funcs - added logic for also resolving global vars and functions in included files. - added #AutoItGenFuncEx_SkipInclude directive to indicate that a include should not be "wrapped", thus not being callable from a generated function. AutoItGenFuncEx_v3.zip Update 15.02.2021: - access global variables (read-only) and callback functions from main program. - added #AutoItGenFuncEx_AllowCallbacks directive to indicate that functions in the main script should be wrapped into callback-enabled functions. See Example #4. AutoItGenFuncEx_v2.zip Initial Post: generate function.zip AutoItGenFunc.zip I did not find any easier solution for sharing data and functions between scripts yet, so this is my dirty hack. Maybe it's useful for someone with the same problem. I would also be happy if someone would point out alternatives or improvements. I feel like there is potential.1 point
-
AutoIt Snippets
pixelsearch reacted to seadoggie01 for a topic
There's a certain grace that comes with admitting you were wrong (or that someone did something better). Trust me, I've been there... too much. It happens a lot, don't worry about it.1 point -
Set the tray icon as a HIcon
argumentum reacted to Mat for a topic
So I wanted to have my program display a number in the system tray, and decided to do it programatically (e.g. not 99 icons). Reading through MSDN resulted in me writing my own code to do everything myself, and menus were a pain. Ideally I wanted to use all AutoIt tray functions BUT use a HIcon rather than a file path. Impossible eh? Not with the AutoIt source code!! All you need to do is know the following: Global Const $AUT_WM_NOTIFYICON = $WM_USER + 1 Global Const $AUT_NOTIFY_ICON_ID = 1 Global $TRAY_ICON_GUI = WinGetHandle(AutoItWinGetTitle()) And then you have everything you need to use the Shell_NotifyIcon function as if you were AutoIt: MWAHAHAHAHA _GDIPlus_BitmapCreateHICONFromBitmap which strangely does not appear in GDIPlus.au3 means you can use a bitmap: Then all you need is some simple drawing code: complete code: #include <WindowsConstants.au3> #include <GDIPlus.au3> #include <WinAPI.au3> Global Const $tagNOTIFYICONDATA = "dword Size;" & _ "hwnd Wnd;" & _ "uint ID;" & _ "uint Flags;" & _ "uint CallbackMessage;" & _ "ptr Icon;" & _ "wchar Tip[128];" & _ "dword State;" & _ "dword StateMask;" & _ "wchar Info[256];" & _ "uint Timeout;" & _ "wchar InfoTitle[64];" & _ "dword InfoFlags;" & _ "dword Data1;word Data2;word Data3;byte Data4[8];" & _ "ptr BalloonIcon" Global Const $NIM_ADD = 0 Global Const $NIM_MODIFY = 1 Global Const $NIF_MESSAGE = 1 Global Const $NIF_ICON = 2 Global Const $AUT_WM_NOTIFYICON = $WM_USER + 1 ; Application.h Global Const $AUT_NOTIFY_ICON_ID = 1 ; Application.h AutoItWinSetTitle("this is a test 123") Global $TRAY_ICON_GUI = WinGetHandle(AutoItWinGetTitle()) ; Internal AutoIt GUI ;;; _GDIPlus_Startup() Local $hBitmap, $hImage, $hGraphic, $hIcon $hBitmap = _WinAPI_CreateSolidBitmap(0, 0xFFFFFF, 16, 16) $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap) $hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage) For $i = 99 To 1 Step -1 _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF) _GDIPlus_GraphicsDrawString($hGraphic, $i, (StringLen($i) - 2) * - 3, 2, "Arial", 8) $hIcon = _GDIPlus_BitmapCreateHICONFromBitmap($hImage) _Tray_SetHIcon($hIcon) _WinAPI_DestroyIcon($hIcon) Sleep(200) Next _GDIPlus_ImageDispose($hImage) _GDIPlus_GraphicsDispose($hGraphic) _WinAPI_DeleteObject($hBitmap) _GDIPlus_Shutdown() ;;; Func _Tray_SetHIcon($hIcon) Local $tNOTIFY = DllStructCreate($tagNOTIFYICONDATA) DllStructSetData($tNOTIFY, "Size", DllStructGetSize($tNOTIFY)) DllStructSetData($tNOTIFY, "Wnd", $TRAY_ICON_GUI) DllStructSetData($tNOTIFY, "ID", $AUT_NOTIFY_ICON_ID) DllStructSetData($tNOTIFY, "Icon", $hIcon) DllStructSetData($tNOTIFY, "Flags", BitOR($NIF_ICON, $NIF_MESSAGE)) DllStructSetData($tNOTIFY, "CallbackMessage", $AUT_WM_NOTIFYICON) Local $aRet = DllCall("shell32.dll", "int", "Shell_NotifyIconW", "dword", $NIM_MODIFY, "ptr", DllStructGetPtr($tNOTIFY)) If (@error) Then Return SetError(1, 0, 0) Return $aRet[0] <> 0 EndFunc ;==>_Tray_SetHIcon Func _GDIPlus_BitmapCreateHICONFromBitmap($hBitmap) Local $hIcon = DllCall($ghGDIPDll, "int", "GdipCreateHICONFromBitmap", "hwnd", $hBitmap, "int*", 0) If @error Or Not $hIcon[0] Then Return SetError(@error, @extended, $hIcon[2]) Return $hIcon[2] EndFunc ;==>_GDIPlus_BitmapCreateHICONFromBitmap I love AutoIt.1 point