MyEarth Posted December 13, 2013 Share Posted December 13, 2013 (edited) Someone know if there is a way to set a single hotkey (like CTRL+1) to start a software without have the script always running? Hotkeyset() need a loop, the Windows shortcut combination is bugged, maybe some hook procedure to set the key (it work until reboot obv). If it's possible please share an example. Many thanks Edited December 13, 2013 by MyEarth Link to comment Share on other sites More sharing options...
jdelaney Posted December 13, 2013 Share Posted December 13, 2013 (edited) Right click on an application, select properties, add a shortcut key under the shortcut tab...must be Ctrl+Alt+#{something}...not really autoit related Edited December 13, 2013 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
MyEarth Posted December 13, 2013 Author Share Posted December 13, 2013 (edited) Did you read my post? ...Windows shortcut combination is bugged... Sometime work but not always, if you reboot probaly lost the hotkey, you can't change it until reboot or killing explorer and many other issue, search on google and you'll find people with the same problems. So i want to use autoit for the same purpose but without the malus of windows original function Edited December 13, 2013 by MyEarth Link to comment Share on other sites More sharing options...
jdelaney Posted December 13, 2013 Share Posted December 13, 2013 (edited) Then I'm going with: no. Mabye google how to reset the windows process, without resetting your comp. Edited December 13, 2013 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
MyEarth Posted December 13, 2013 Author Share Posted December 13, 2013 Ok, thanks for your opinion Hope someone has an idea how to accomplish this, maybe something like register a global hotkey to a process like explorer.exe instead of our .exe Link to comment Share on other sites More sharing options...
jdelaney Posted December 13, 2013 Share Posted December 13, 2013 (edited) There are autoit wrapped DLL calls to do what windows does...maybe you can reset the hotkeys when they stop working...must unregister, then register, per MSDN: _WinAPI_UnregisterHotKey _WinAPI_RegisterHotKey I think these are part of the _WinAPI addon, which needs to be downloaded from example scripts Yeap, WinAPIEx.au3... expandcollapse popup; #FUNCTION# ==================================================================================================================== ; Name...........: _WinAPI_UnregisterHotKey ; Description....: Frees a hot key previously registered by the calling thread. ; Syntax.........: _WinAPI_UnregisterHotKey ( $hWnd, $ID ) ; Parameters.....: $hWnd - Handle to the window associated with the hot key to be freed. This parameter should be 0 if the ; hot key is not associated with a window. ; $ID - Specifies the identifier of the hot key to be freed. ; Return values..: Success - 1. ; Failure - 0 and sets the @error flag to non-zero. ; Author.........: Yashied ; Modified.......: ; Remarks........: None ; Related........: ; Link...........: @@MsdnLink@@ UnregisterHotKey ; Example........: Yes ; =============================================================================================================================== Func _WinAPI_UnregisterHotKey($hWnd, $ID) Local $Ret = DllCall('user32.dll', 'int', 'UnregisterHotKey', 'hwnd', $hWnd, 'int', $ID) If (@error) Or (Not $Ret[0]) Then Return SetError(1, 0, 0) EndIf Return 1 EndFunc ;==>_WinAPI_UnregisterHotKey ; #FUNCTION# ==================================================================================================================== ; Name...........: _WinAPI_RegisterHotKey ; Description....: Defines a system-wide hot key. ; Syntax.........: _WinAPI_RegisterHotKey ( $hWnd, $ID, $iModifiers, $vKey ) ; Parameters.....: $hWnd - Handle to the window that will receive WM_HOTKEY messages generated by the hot key. If this parameter ; is 0, WM_HOTKEY messages are posted to the message queue of the calling thread and must be processed in ; the message loop. ; $ID - Specifies the identifier of the hot key. An application must specify an id value in the range ; 0x0000 through 0xBFFF. ; $iModifiers - Specifies keys that must be pressed in combination with the key specified by the $vKey parameter ; in order to generate the WM_HOTKEY message. The $iModifiers parameter can be a combination of the ; following values. ; ; $MOD_ALT ; $MOD_CONTROL ; $MOD_SHIFT ; $MOD_WIN ; ; Windows 7 or later ; ; $MOD_NOREPEAT ; ; $vKey - Specifies the virtual-key code of the hot key ($VK_*). ; Return values..: Success - 1. ; Failure - 0 and sets the @error flag to non-zero. ; Author.........: Yashied ; Modified.......: ; Remarks........: When a key is pressed, the system looks for a match against all hot keys. Upon finding a match, the system posts ; the WM_HOTKEY message to the message queue of the window with which the hot key is associated. If the hot key is ; not associated with a window, then the WM_HOTKEY message is posted to the thread associated with the hot key. ; ; _WinAPI_RegisterHotKey() fails if the keystrokes specified for the hot key have already been registered by ; another hot key. ; ; In Windows XP and previous versions of Windows, if a hot key already exists with the same $hWnd and $ID parameters, ; it is replaced by the new hot key. ; ; In Windows Vista and subsequent versions of Windows, if a hot key already exists with the same $hWnd and $ID ; parameters, it is maintained along with the new hot key. In these versions of Windows, the application must ; explicitly call _WinAPI_UnregisterHotKey() to unregister the old hot key. ; Related........: ; Link...........: @@MsdnLink@@ RegisterHotKey ; Example........: Yes ; =============================================================================================================================== Func _WinAPI_RegisterHotKey($hWnd, $ID, $iModifiers, $vKey) Local $Ret = DllCall('user32.dll', 'int', 'RegisterHotKey', 'hwnd', $hWnd, 'int', $ID, 'uint', $iModifiers, 'uint', $vKey) If (@error) Or (Not $Ret[0]) Then Return SetError(1, 0, 0) EndIf Return 1 EndFunc ;==>_WinAPI_RegisterHotKey Edited December 13, 2013 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
MyEarth Posted December 13, 2013 Author Share Posted December 13, 2013 Thanks, i'll check it out ( ill try to set the handle to explorer.exe process and see if work ) Link to comment Share on other sites More sharing options...
MyEarth Posted December 14, 2013 Author Share Posted December 14, 2013 I have try with no success: expandcollapse popupLocal $IPID = "", $iHandle = "" Local Const $MOD_ALT = 0x0001 Local Const $MOD_CONTROL = 0x0002 Local Const $MOD_SHIFT = 0x0004 Local Const $MOD_WIN = 0x0008 $list = ProcessList("explorer.exe") For $i = 1 To $list[0][0] $IPID = $list[$i][1] ConsoleWrite($list[$i][0] & ": " & $list[$i][1] & @CRLF) Next $iHandle = _GetHwndFromPID($IPID) ConsoleWrite("HANDLE: " & $iHandle & @CRLF) _WinAPI_RegisterHotKey($iHandle, 0x0000, $MOD_CONTROL, 0x31) If @error then ConsoleWrite("ERROR: " & @error) Func _WinAPI_RegisterHotKey($hWnd, $ID, $iModifiers, $vKey) Local $Ret = DllCall('user32.dll', 'int', 'RegisterHotKey', 'hwnd', $hWnd, 'int', $ID, 'uint', $iModifiers, 'uint', $vKey) If (@error) Or (Not $Ret[0]) Then Return SetError(1, 0, 0) EndIf Return 1 EndFunc ;==>_WinAPI_RegisterHotKey Func _GetHwndFromPID($PID) $hWnd = 0 $winlist = WinList() Do For $i = 1 To $winlist[0][0] If $winlist[$i][0] <> "" Then $iPID2 = WinGetProcess($winlist[$i][1]) If $iPID2 = $PID Then $hWnd = $winlist[$i][1] ExitLoop EndIf EndIf Next Until $hWnd <> 0 Return $hWnd EndFunc ;==>_GetHwndFromPID Link to comment Share on other sites More sharing options...
guinness Posted December 14, 2013 Share Posted December 14, 2013 Search for Yashied's HotKey UDF. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
MyEarth Posted December 14, 2013 Author Share Posted December 14, 2013 Thanks for suggestion but as you can see in the example always require the script running: #Include <HotKey.au3> Global Const $VK_ESCAPE = 0x1B Global Const $VK_F12 = 0x7B ; Assign "F12" with Message() and set extended function call _HotKey_Assign($VK_F12, 'Message', BitOR($HK_FLAG_DEFAULT, $HK_FLAG_EXTENDEDCALL)) ; Assign "CTRL-ESC" with Quit() _HotKey_Assign(BitOR($CK_CONTROL, $VK_ESCAPE), 'Quit') While 1 ; <<<< HERE Sleep(10) ; <<<< HERE WEnd ; <<<< HERE Func Message($iKey) MsgBox(0, 'Hot key Test Message', 'F12 (0x' & Hex($iKey, 4) & ') has been pressed!') EndFunc ;==>Message Func Quit() Exit EndFunc ;==>Quit If i have misunderstood and if possible to use the UDF for register the Hotkey without have the script running tell me 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