Jump to content

Search the Community

Showing results for tags 'Keyboard'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • Forum FAQ
  • AutoIt

Calendars

  • Community Calendar

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 22 results

  1. I/O Port Functions UDF Windows 7 and x64-compatible! This is a simple I/O (Input/Output) UDF for interacting with ports. The ability to write to ports was stripped from Windows with Vista+. While many do not miss this ability, there are some uses still in existence: Re-enable the internal PC Speaker - the good ol' "Beep" function can be restored using basic I/O PS/2 Keyboard Functions - Turn it off/on, mess with LED's, inject keys into the keyboard output stream - even thwart UAC prompts! =O Also work with Parallel, Serial (COM), PS/2 mouse, and miscellaneous ports that devices interface through using I/O operations For some good lists of ports and programming, see: PORTS.LST Chapters from 'The Art of Assembly Language': 20: The PC Keyboards - Part One and Part Two 21: The PC Parallel Ports - Part One, Part Two, and Part Three 22: The PC Serial Ports - Part One and Part Two 23: The PC Video Display 24: The PC Game Adapter - Part One, Part Two, Part Three and Part Four On the PS/2 Keyboard and PS/2 Mouse, some more links: 8042 Keyboard Controller 8042 Keyboard Commands & Responses Keyboard Controller Commands, Keyboard Commands and Keyboard Scancodes The PS/2 Mouse The I/O DLL's, which will install the I/O drivers (they are embedded as a resource in the DLL), come from Phillip Gibbons. His webpage, where more information, and extra downloads are, is available here: InpOut32 and InpOutx64. Note: everything you need is already included in my UDF. IOInstallx86 and IOInstallx64 are included to help with the install. Run these once to install the DLL's and drivers. (Administrator rights are required!) In addition to the base _IOFunctions UDF, I've included _IOBeep, which is based on trancexx's _Beep function, and _IOKeyboardFunctions [PS/2 only*]. There are now three examples of the UDF usage included: IOBeepExample, IOCMOSReadExample (based on trancexx's CMOS code), and IOKeyboardExamples. If anyone else has more code suggestions, feel free to add to the thread. *Update: Some BIOS's allow Legacy USB Port 64/60 Emulation, which may allow the _IOKeyboardFunctions to work for USB (non-PS/2) Keyboards, though this is untested thus far. While I bundle the binaries with my code, remember they are not my own. However, they are released as freeware. To ensure proper credit goes where it belongs, I've included the Readme files from the download (linked above), as well as a link to the original page. Ascend4nt's AutoIT Code License agreement Screw silly licenses. Just make sure you remember the people you get free stuff from! IOFunctions.zip UPDATES: 07/11/2013: - Updated to use (and install) v1.5.0.0 of InpOut32 & InpOutx64 - Version check & compare before install - Fixed links - Tiny bug fixes InpOut32 and InpOutx64 ChangeLog: v1.5.0.0 New Build (20-Jan-2011): - Added _stdcall to DlPortReadPortUshort, DlPortWritePortUshort, DlPortReadPortUlong, DlPortWritePortUlong to maintain compatibility with old DLPortIO driver. v1.4.0.0 New Build (13-Jan-2011): - Removed references to WinRing0 which was discontinued. - Fixed uninitialized buffers & return from Inp32 > byte value! v1.3.0.0 New Build (15-Aug-2010): - Removed bool's from header (replaced with BOOL). This is to maintain compatibility with other DLL’s (DLPortIO etc.). 10/22/2010: Added _IOKeyboardFunctions UDF Added IOKeyboardExamples and IOCMOSReadExample (based on trancexx's CMOS code)
  2. If you like to launch a game that has uncomfortable key combination, can you use AutoIt to map better keys just for that game without affecting the entire system? For the sake of example, let's say your game's executable is notepad.exe and you'd like the letter / to actually type \, but only inside Notepad.
  3. Hi AutoIt Programmers!, I just looking for a way to change entered keys in English to Russian keys and reverse, i must clear for you to understand. For example: I write keys on keyboard and i forgot to change input language and then the result will be: Dkflbvbh (Thing we write in fact) ====> Владимир (Thing we want) And reverse: Владимир ====> Dkflbvbh Is there any solution without writing constant for each words? for example dlls or WinAPIs.
  4. Hello, i searched the forum for something near, but with no success... I have Combobox control with $CBS_DROPDOWNLIST style with some items (for example (one, two, nine). When i want to select the item, using keyboard, the items are selected only on First letter base (for example when i type "on", Nine is selected). Is there some trick to force the combobox with $CBS_DROPDOWNLIST style to accept more than the First letter during selecting the items from the list? Mi wanted result is the same as for example - when you type "fir" on the desktop, Firefox is automatically selected. Thank you so much. Fenzik
  5. Hello, need help to remap '<' button and SHIFT+'<' I made a little editor that allows to my users to write using proprietary codes. In production we have 2 keys/symbols that i want to 'emulate'. So, when is press on my keyboard : < = « SHIFT+< = » Try to use help example _IsPressed : #include <Misc.au3> #include <MsgBoxConstants.au3> Local $hDLL = DllOpen("user32.dll") While 1 If _IsPressed("10", $hDLL) Then ConsoleWrite("_IsPressed - Shift Key was pressed." & @CRLF) ; Wait until key is released. While _IsPressed("10", $hDLL) Sleep(250) WEnd ConsoleWrite("_IsPressed - Shift Key was released." & @CRLF) ElseIf _IsPressed("1B", $hDLL) Then MsgBox($MB_SYSTEMMODAL, "_IsPressed", "Close the application.") ExitLoop EndIf Sleep(250) WEnd DllClose($hDLL) but how manage keys combination ? thank you for any help, m.
  6. Hi All, I've bought a Ergodox EZ programmable keyboard with layers of key maps (eg, layer 0 = dvorak, layer 1 = numberpad & nav, layer 2 = qwerty, etc), I've also got a small USB screen that can pull information from the registry. What I would like to determine is a way to pull the value of each current key from the keyboard, I can then write the values to the registry and pull them into my USB screen so I can see the keyboard key layout. I'm stuck with retrieving the key values, I've looked at _IsPressed(), _WinAPI_GetKeyState(), _WinAPI_GetKeyboardState(), _WinAPI_GetKeyboardType(), _WinAPI_GetKeyNameText(), but none of them appear to be able to pull the keyboard key values without user interaction. The idea being, in pseudo code, bear in mind no error checking etc in this code, "GetKeyValue()" is what I'm needing help with and is a made up function, as is "HardwareKey1" etc: $keyOnePrev = "" $numOfKeys = 76 While 1 $keyOneCurrent = GetKeyValue(HardwareKey1) If $keyOneCurrent <> $keyOnePrev Then For $key = 1 To $numOfKeys $keyToWrite = GetKeyValue(HardwareKey & $key) RegWrite("HKEY_CURRENT_USER\Software\myKeyboard", "key" & $key, "REG_SZ", $keyToWrite) Next EndIf $keyOnePrev = $keyOneCurrent Sleep(5000) WEnd Thanks guys!
  7. Example of Subclassing listviews using setwindowSubclass in order to intercept WM_KEYUP events Also pops context menu on Shift + F10 #include <Misc.au3> #include <ListViewConstants.au3> #include <GUIConstants.au3> #include <GuiMenu.au3> #include <WinAPIShellEx.au3> Global $g_hCB, $g_pCB, $g_ahProc[2][2] ;Stores the Data for subclassing listview Global $g_LVKEYUP = 0xFE00, $g_LVKEYDN = 0xFD00 ;Our Own Custom messages (Key Up/Dn) Global $g_iDummyData Global $g_hGui = GUICreate("test") Global $g_hList1 = GUICtrlCreateListView("#|x|y", 5, 24, 161, 70, $LVS_SHOWSELALWAYS Or $LVS_SINGLESEL) GUICtrlCreateListViewItem("text", $g_hList1) Global $g_hList1_LVN = GUICtrlCreateDummy() ;Recieves Messages from the callback Global $g_hContext1 = GUICtrlCreateContextMenu($g_hList1) GUICtrlCreateMenuItem("1", $g_hContext1) GUICtrlCreateMenuItem("2", $g_hContext1) Global $g_hList2 = GUICtrlCreateListView("#|x|y", 5, 100, 161, 70, $LVS_SHOWSELALWAYS Or $LVS_SINGLESEL) GUICtrlCreateListViewItem("text", $g_hList2) Global $g_hList2_LVN = GUICtrlCreateDummy() ;Recieves Messages from the callback Global $g_hContext2 = GUICtrlCreateContextMenu($g_hList2) GUICtrlCreateMenuItem("3", $g_hContext2) GUICtrlCreateMenuItem("4", $g_hContext2) GUISetState(@SW_SHOW) SubClassListView() ;Creates our subclass Func SubClassListView() OnAutoItExitRegister("Cleanup") ;to remove our subclass $g_hCB = DllCallbackRegister('_SubclassProc', 'lresult', 'hwnd;uint;wparam;lparam;uint_ptr;dword_ptr') $g_pCB = DllCallbackGetPtr($g_hCB) $g_ahProc[0][0] = $g_hList1 ;Add the Ids of the controls we'd like to subclass $g_ahProc[1][0] = $g_hList2 ;Set up the subclass _WinAPI_SetWindowSubclass ( $hWnd, $pSubclassProc, $idSubClass [, $pData = 0] ) $g_ahProc[0][1] = _WinAPI_SetWindowSubclass(GUICtrlGetHandle($g_ahProc[0][0]), $g_pCB, $g_ahProc[0][0], $g_hList1_LVN) $g_ahProc[1][1] = _WinAPI_SetWindowSubclass(GUICtrlGetHandle($g_ahProc[1][0]), $g_pCB, $g_ahProc[1][0], $g_hList2_LVN) EndFunc ;==>SubClassListView Func _SubclassProc($hWnd, $iMsg, $wParam, $lParam, $iID, $pData) #forceref $iID Local $iRtnMsg = 0 ;Events we'd like to intercept If $iMsg = $WM_KEYUP Or $iMsg = $WM_SYSKEYUP Then $iRtnMsg = $g_LVKEYUP ElseIf $iMsg = $WM_KEYDOWN Or $iMsg = $WM_SYSKEYDOWN Then $iRtnMsg = $g_LVKEYDN EndIf ;We Recieve the Id of the dummy through $pData and pass our RtnMsg to the dummy control If $iRtnMsg Then GUICtrlSendToDummy($pData, BitOR($iRtnMsg, $wParam)) ;Pass messages on to the default handler Return _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam) EndFunc ;==>_SubclassProc Func Cleanup() For $i = 0 To UBound($g_ahProc) - 1 ;Remove Our Subclass' by setting it back to the original proc _WinAPI_RemoveWindowSubclass(GUICtrlGetHandle($g_ahProc[$i][0]), DllCallbackGetPtr($g_ahProc[$i][1]), $g_ahProc[$i][0]) Next DllCallbackFree($g_hCB) EndFunc ;==>Cleanup While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $g_hList1_LVN ;This is just a dummy it only recieves events ConsoleWrite("LV1 EVENT 0x" & Hex($g_iDummyData, 4) & @CRLF) $g_iDummyData = GUICtrlRead($g_hList1_LVN) ;Retrieve the code that was sent Switch BitAND($g_iDummyData, 0xFF00) ;Get the keyup/dn status Case $g_LVKEYDN If BitAND($g_iDummyData, 0x00FF) = 0x79 And (_IsPressed("A0") Or _IsPressed("A1")) Then ;Right/ Left Shift & F10 ShowMenu($g_hGui, $g_hList1, $g_hContext1) Else ConsoleWrite("Lv1 KeyDn Vk: 0x" & Hex(BitAND($g_iDummyData, 0x00FF), 2) & @CRLF) ;Get the Virtual keycode EndIf Case $g_LVKEYUP ConsoleWrite("Lv1 KeyUp Vk: 0x" & Hex(BitAND($g_iDummyData, 0x00FF), 2) & @CRLF) ;Get the Virtual keycode EndSwitch Case $g_hList2_LVN $g_iDummyData = GUICtrlRead($g_hList2_LVN) ;Retrieve the code that was sent ConsoleWrite("LV2 EVENT 0x" & Hex($g_iDummyData, 4) & @CRLF) Switch BitAND($g_iDummyData, 0xFF00) ;Get the keyup/dn status Case $g_LVKEYDN ConsoleWrite("Lv2 KeyDn Vk: 0x" & Hex(BitAND($g_iDummyData, 0x00FF), 2) & @CRLF) ;Get the Virtual keycode Case $g_LVKEYUP ConsoleWrite("Lv2 KeyUp Vk: 0x" & Hex(BitAND($g_iDummyData, 0x00FF), 2) & @CRLF) ;Get the Virtual keycode EndSwitch EndSwitch WEnd Func ShowMenu($hWnd, $idCtrl, $idContext) Local $aPos, $iX, $iY Local $hMenu = GUICtrlGetHandle($idContext) $aPos = ControlGetPos($hWnd, "", $idCtrl) $iX = $aPos[0] $iY = $aPos[1] + $aPos[3] ClientToScreen($hWnd, $iX, $iY) ; Show at the given coordinates (x, y) the popup menu (hMenu) which belongs to a given GUI window (hWnd) _GUICtrlMenu_TrackPopupMenu($hMenu, $hWnd, $iX, $iY) EndFunc ;==>ShowMenu ; Convert the client (GUI) coordinates to screen (desktop) coordinates Func ClientToScreen($hWnd, ByRef $iX, ByRef $iY) Local $tPoint = DllStructCreate("int;int") DllStructSetData($tPoint, 1, $iX) DllStructSetData($tPoint, 2, $iY) DllCall("user32.dll", "int", "ClientToScreen", "hwnd", $hWnd, "struct*", $tPoint) $iX = DllStructGetData($tPoint, 1) $iY = DllStructGetData($tPoint, 2) ; release Struct not really needed as it is a local $tPoint = 0 EndFunc ;==>ClientToScreen Old Code Using setWindowLong
  8. I have a situation where the desktop is designed in java swings. The nodes JTree is not allowing me to do checkbox selection using "spacebar". I am able to navigate through the nodes using up, down arrow and a tab. When I reach to the desire node selection, mouse left click is not working due a flaw a JTree core. However since it is selected, if mouse cursor auto moved to the position of the selection and send a "click" then it should be solved. Any ideas much appreciated. the problem with having fixed coordinates are the main windows is divided to 2panels where right panel containing this JTree can be expanded or shrink-ed.
  9. Hi guys, I've seen the @kblayout macro, but the information I'm after is the keyboard layout (aka "Input Method") so I can detect if I'm using "US Keyboard" or "United States-Dvorak Keyboard" rather than 00000c09 or 00000409 which relate to languages such as EN AU or EN US for example. For example I have 1 language set up (English Australia) in my regional settings, but then under the language I have "US Keyboard" and "United States-Dvorak Keyboard" setup, so that when I press WIN+SPACE I can toggle between them. Effectively I want a way of determining if I'm running qwerty or dvorak. Thanks guys!!
  10. Hi, First of all I would like say infinite thanks to the team involved in designing this great tool. Here is my problem 1. Press windows button 2. ESC 3. TAB 4. It will take me to the first pinned icon in the taskbar 5. If I I do SHIFT F10 which usually opens context menu like right click of the mouse. 6. For one of the application I am using it does not support Shift + F10 context menu rather it listens to only mouse right click event. 7. I do a search in a tree view of my application and the search item is selected or focused 8. For eg User1 User2 User3 Now if I search for User1 the tab or focus move to User 1 (Red) User1 User2 User3 If I search for User3 the tab or focus moves to User 3 Now my question is how can I move the mouse automatically go to the focused item on the window. Such that during automation I can issue MoveClick("{RIGHT}") as {SHIFT F10} is not working from the keyboard. It is a java app, unfortunately it is not honoring the right click events from keyboard to open the context WinMinimizeAll(); Send("^{ESC}") Sleep(200) Send("{ESC}") Send("{TAB}") the above scripts take the tab to the first pinned icon in the taskbar. Now i want MouseMove( "move to tab" selection") Regards, Tarakesh
  11. Hi! I post here because i was wonderring if someone in this forum could help me with my script. What i'm trying to do, is to basically install a new keyboard layout in Windows and activate it. I want to acheive by the registry or the command line, but not with the autoit automation tools, i don't find it stable... Thanks for your help and have a good day!
  12. Hi There, I'm currently rebinding some of my keys (multimedia ones) and I have two keys that handle the Zoom (+ & -) (just after the calc key) I looked everywhere (in the help file and on Google) but I was not able to find the matching code. Do some of you could have a little idea on how to get their "name" so I'll be able to remap them? Thanks
  13. Here's a hacky script I made to make the music key on my keyboard click the back button on my Chrome browser. You need to compile the script in to an exe, and associate "cda" file extension to the executable. Note- this also means you can reassign the music key on your keyboard to whatever executable you want using this method! AutoItSetOption("WinTitleMatchMode", 2) HotKeySet("{Escape}", "exitScript") $chromePos = WinGetPos("Chrome") If (@error <> 0) Then ConsoleWriteError("Can not find Chrome window - WinGetPos returned @error: " & @error & @CRLF) Exit EndIf $originalMousePos = MouseGetPos() MouseClick("primary", $chromePos[0] + 20, $chromePos[1] + 45, 1, 2) MouseMove($originalMousePos[0], $originalMousePos[1], 2) Func exitScript() ConsoleWrite("Exiting script..." & @CRLF) Exit EndFuncYay AutoIt3 community. Unfortunately, for the most part at work I've moved on to OSX machines (meh). Seems like that's what all the companies are developing on lately.
  14. Hello, I am trying to create an input box that when a user types something like the character "." that it will prevent that character from entering the input box and display a message stating why the input was prevented. Something like what $ES_NUMBER style does for the input box, but for a floating point number. I can work out the logic of how to do that, but I am not yet sure how to correctly capture keyboard input before it arrives IN the input box. This should only run on the particular input box in question as it is an aid to help clean up user input before it gets sent to a SQL query. I was hoping for something like: $msg = GUIGetMsg() Switch $msg Case $keyboardInput ; pre processing function called hereI have searched for something similar to this but I cannot seem to find one that does exactly what I am looking for. Any help is appreciated. Thanks, K
  15. I have a shortcut in the startup group to: "c:\Program Files (x86)\Internet Explorer\iexplore.exe" -k http://whatever.com/hello.html This page does nothing but load a flash object which includes a text field for searching. Now all I'm trying to do is detect when somebody taps or clicks on any editable text so I can launch "C:\Program Files\Common Files\microsoft shared\ink\TabTip.exe" and give them a keyboard. Any help is appreciated, I'm rusty
  16. Hi These example apps can be used to lock the keyboard and mouse (useful for test automation). I've also included a Toddler/Child Lock app which lets them press some keys A-Z and 0-9 and move the mouse and plays a sound. Its uses BlockInputEx UDF Most example ALT+ESC to end enjoy KeyBoardMouseLock.zip
  17. Hello all I'm trying to send keys to a program and it works well, but if I changed the keyboard layout to language other than English it fails ex: Run("Notepad.exe") $hWnd = WinWait("Untitled - Notepad2") WinActivate($hWnd) ControlSend($hWnd, "", "", "^s") this works and opens the save as dialogue if I'm using English keyboard only not Arabic keyboard for example I've tried using in send command {CTRL} , {LCTRL} , {RCTRL} but didn't work so how I automatically change keyboard if it's not English and then send the keys or what I should do Thanks
  18. I always knew I'd have to write a configure joystick routine to record and return desired user input to be used for player controls. This example UDF is mainly to help people just getting started, who have never written a configure joystick routine. but it's also a dialog that will setup and load custom controls for as many players as you like. Just try -12 players for example. Example using Configure Controls to setup controls for Tanks that ride on the desktop. Damn I broke the jump shadow before the video, ha. I fixed it before the source upload. http://www.youtube.com/watch?v=I94yrKrDq-E Having seen plenty of configure joystick functions from a user stand point, I had some criteria. 1. All players controls should be accessible from a single call to the configure function. Navigating back a dialog just to assign the next player is bullshit. 2. Can handle analog and digital controls, and not become broken b/c the joystick is special. Testing please let me know! 3. GUI but only Nes joystick GUI at this point. Todo: 1. I should be able to detect when the GUIHotkey changes and focus the next field. A joystick does this already. 2. After seeing better written UDFs I am still considering better variable names. 3. When you can assign all types of input devices to a single player controls, you allow for multiplayer single player. B/c of the re-write using both GUIHotkey controls and input fields, I have decided to wait and add this feature latter. The data is setup to handle it, but the configurecontrols dialog creates all the fields based on the first control type. Meaning at this point only one input type per player. Note: These scripts require an SDL folder environment! See download at end of post. Configure Controls UDF.au3 #include-once ; #INDEX# ======================================================================================================================= ; Title .........: Configure Controls ; AutoIt Version : 3.3.10.2 works older versions of AutoIt, unsure how far back ; Description ...: Methods to record user input to a customizable control array ; Author(s) .....: Xandy ; Dll ...........: SDL.dll, SDL_Image.dll ; Functions......: ; _configurecontrols($hgui, $screen, $players, $aControlLabelNames= Default) - - - returns $a_control[$controlmax][$g_cc_controldatamax] ; _cc_savecontrols($control, $filename, $controlinput) ; _cc_loadcontrols($filename, $controlmax, $g_cc_controldatamax) ; _cc_updatecontrolinput($control, byref $controlinput) ; _cc_nesgui_selectiondefine(byref $nespadbuttonselectsurf, byref $nespadrect) ; _cc_surfget($surf, byref $width, byref $height) - - - get the width and height of a SDL_Surface ; _cc_controlchanged($control, $player, $g_cc_controldatamax, $controlinput) ; _cc_openjoystick(byref $joystick, $joystickid, byref $joystickbuttons, byref $joystickaxes, byref $joystickhats) ; _cc_mouseoverrect($mousex, $mousey, $rect, $rect_y= default, $rect_w= default, $rect_h= default) ; _cc_deletecontrolinput(byref $controlinput, byref $control) ; _cc_createcontrolinput(byref $controlinput, $control, $hgui, $guirect) ; _cc_getkeycode($keycode) ; _cc_clearcontrols(byref $control) ; =============================================================================================================================== ; AutoIt source script file #include <Misc.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GuiComboBoxEx.au3> #include "Include Lib\SDL v14\SDL.au3";created by AdmiralAlkex #include "Include Lib\SDL v14\SDL_Image.au3";created by AdmiralAlkex #include "Include Lib\GUIHotkey\GUIHotkey.au3";created by Mat global $g_cc_controlsavepath= @scriptdir&"\Player Config\" global $g_cc_controlsavefilename= "Player_" global $g_cc_controldatamax= 3 global $analog_threshold= 20000 global $buttontypemax= 3 global $buttontype[$buttontypemax][2];min[type][0] and max[type][1] range global enum $e_button= 0, $e_axis= 1, $e_hat= 2 $buttontype[$e_button][0]= 10 $buttontype[$e_button][1]= 10 $buttontype[$e_axis][0]= 20 $buttontype[$e_axis][1]= 9999 $buttontype[$e_hat][0]= 10000 $buttontype[$e_hat][1]= 19999 ; #FUNCTION# ;=============================================================================== ; ; Name...........: _configurecontrols ; Description ...: Saves player control files for keyboard or joystick ; Saves one file per player, but only if the data changes without 'cancel' ; Syntax.........: _configurecontrols($hgui, $screen, $players, $controlmax) ; Parameters ....: $hgui - GUI handle, probably should be the one with $screen attached ; $screen - SDL_Video Surface attached to $hgui ; $players - How many possiable player config files to create or modify ; $aControlNames - An array that has the names of player controls. If Default 8 Nespad controls will be used. func _configurecontrols(byref $hgui, byref $screen, $players, $aControlNames= default) local $controlmax= 8 if $aControlNames= default then local $controllabel[$controlmax]= ["Up", "Down", "Left", "Right", "Select", "Start", "B", "A"] else $controlmax= ubound($aControlNames) local $controllabel[$controlmax] for $i= 0 to $controlmax-1 $controllabel[$i]= $aControlNames[$i] next endif local $a_winrect= wingetpos($hgui) local $joysticks= _SDL_NumJoysticks() local $player= 0 local $joystickbuttons= -1, $joystickaxes= -1, $joystickhats= -1 local $disableaxes= 0 local $guirect= _SDL_Rect_Create(0, 40, $a_winrect[2]-1, 129); local $joystick= 0 local $colorblack= 0 local $control= _cc_loadcontrols($g_cc_controlsavepath&$g_cc_controlsavefilename&$player&".txt", $controlmax, $g_cc_controldatamax) local $joystickid= $control[0][0] local $confirm= 0 ;Prepare screen surface _SDL_FillRect($screen, 0, _SDL_MapRGB($screen, 152, 152, 152));whole screen grey $drect= _SDL_Rect_Create(0, $guirect.y+$guirect.h, $a_winrect[2]-200, $a_winrect-$guirect.h);rect to fill with black _SDL_FillRect($screen, $drect, $colorblack);fill black area _SDL_Flip($screen) ;All GUI controls local $controlinput[$controlmax][2] local $filemenu= guictrlcreatemenu("File") local $filesaveconfig= guictrlcreatemenuitem("Save a backup copy", $filemenu) local $fileloadconfig= guictrlcreatemenuitem("Load a backup config", $filemenu) local $fileexit= guictrlcreatemenuitem("Exit", $filemenu) ;populate input controls and labels for $i= 0 to $controlmax-1;create gui button controls for nespad $controlinput[$i][0]= guictrlcreatelabel($controllabel[$i], $a_winrect[2]-200, $guirect.h+1+($i*25), 75, 25);controlinput guictrlsetfont(-1, 12, 1200) next _cc_createcontrolinput($controlinput, $control, $hgui, $guirect) ;Setup Cancel and Ok button $buttoncancel= guictrlcreatebutton("Cancel", $a_winrect[2]-170, $guirect.h+($controlmax*25)+20, 75, 20) guictrlsetfont($buttoncancel, 14, 400) $buttonok= guictrlcreatebutton("Ok", $a_winrect[2]-80, $guirect.h+($controlmax*25)+20, 55, 20) guictrlsetfont($buttonok, 14, 400) ;Player Number: label and combobox $playerlabel= guictrlcreatelabel("Player Number:", 45, 17, 175, 22) guictrlsetfont($playerlabel, 18, 400) $playercombo= guictrlcreatecombo("1", 45, 40, 55, 30) guictrlsetfont($playercombo, 16, 400) for $i= 1 to $players guictrlsetdata($playercombo, $i) next ;Setup Joystick Name: label and combobox $joysticklabel= guictrlcreatelabel(" Joystick Name: ", 45, 80, 175, 22) guictrlsetfont($joysticklabel, 18, 400) $joysticknamecombo= guictrlcreatecombo("Keyboard", 45, 103, 550, 20, $CBS_DROPDOWNLIST) guictrlsetfont($joysticknamecombo, 14, 400) for $i= 0 to $joysticks-1 guictrlsetdata($joysticknamecombo, _SDL_JoystickName($i)&"|") next _guictrlcombobox_setcursel($joysticknamecombo, $control[0][0]) ;Disable Axes checkbox $disableaxescheckbox= guictrlcreatecheckbox("Disable Axes", 245, 80, 95) guictrlsetfont($disableaxescheckbox, 9, 400) ;Setup Max Axes: label and input $axesmaxlabel= guictrlcreatelabel("Max Axes:", 370, 58, 85) guictrlsetfont($axesmaxlabel, 14, 400) guictrlsettip($axesmaxlabel, "Use when a joystick reports axises incorrectly, but still needs some axis") $axesmaxinput= guictrlcreateinput("", 370, 80, 45, 21, $ES_NUMBER) ;Setup Threshold: label and input $analog_thresholdlabel= guictrlcreatelabel("Threshold:", 485, 58, 90) guictrlsetfont($analog_thresholdlabel, 14, 400) $analog_thresholdinput= guictrlcreateinput($analog_threshold, 485, 80, 55, 21, $ES_NUMBER) _cc_updatecontrolinput($control, $controlinput) guisetstate() local $w= 0, $h= 0 local $nespadsurf= _IMG_Load(@scriptdir&"\..\Graphics\Nespad\nes-pad.png") _cc_surfget($nespadsurf, $w, $h) local $nespadrect= _SDL_Rect_Create(10, $guirect.y+$guirect.h+1-10, $w, $h) local $highlightbutton= -1 local $nespadbuttonselectsurf[$controlmax][4];[$control][0]surf, [1]rect, [2]possiable surf, [3]possiable rect local $mousex= 0, $mousey= 0;to detect graphic control under mouse ; Define GUI button selection graphic placement _cc_nesgui_selectiondefine($nespadbuttonselectsurf, $nespadrect);defines area to blit controls to gui local $rx= 0, $ry= 0, $rw= 0, $rh= 0 local $rect_a= 0 local $redraw= 1 local $newbutton= "do nothing" local $oldhighlightbutton= -1 ;local $msg= $joysticknamecombo local $msg= 0 if $joystickid> 0 then;joystick $joystick= _cc_openjoystick($joystick, $joystickid, $joystickbuttons, $joystickaxes, $joystickhats) endif;joystickid> 0 guictrlsetdata($axesmaxinput, $joystickaxes) $drect= _SDL_Rect_Create($nespadrect.x, $nespadrect.y, $nespadrect.w, $nespadrect.h);nes pad rect do if winactive($hgui) then switch $msg case $joysticknamecombo;joystick selection _cc_deletecontrolinput($controlinput, $control) _cc_clearcontrols($control) $joystickid= _guictrlcombobox_getcursel($joysticknamecombo) $control[0][0]= $joystickid $joystick= _cc_openjoystick($joystick, $joystickid, $joystickbuttons, $joystickaxes, $joystickhats) _cc_createcontrolinput($controlinput, $control, $hgui, $guirect) _cc_updatecontrolinput($control, $controlinput) guictrlsetdata($axesmaxinput, $joystickaxes) case $playercombo if _cc_controlchanged($control, $player, $g_cc_controldatamax, $controlinput) then _cc_savecontrols($control, $g_cc_controlsavepath&$g_cc_controlsavefilename&$player&".txt", $controlinput) _cc_deletecontrolinput($controlinput, $control) $player= _guictrlcombobox_getcursel($playercombo) $control= _cc_loadcontrols($g_cc_controlsavepath&$g_cc_controlsavefilename&$player&".txt", $controlmax, $g_cc_controldatamax) _guictrlcombobox_setcursel($joysticknamecombo, $control[0][0]);use the first control type as combo selection $joystickid= $control[0][0] $joystick= _cc_openjoystick($joystick, $joystickid, $joystickbuttons, $joystickaxes, $joystickhats) _cc_createcontrolinput($controlinput, $control, $hgui, $guirect) _cc_updatecontrolinput($control, $controlinput) guictrlsetdata($axesmaxinput, $joystickaxes) case $disableaxescheckbox $disableaxes= guictrlread($disableaxescheckbox) case $analog_thresholdinput $analog_threshold= int(guictrlread($analog_thresholdinput)) case $buttoncancel exitloop case $fileexit exitloop case $buttonok $confirm= 1 exitloop case $fileloadconfig $loadpath= fileopendialog("Load Control File", $g_cc_controlsavepath, "txt(*.txt)") if @error= 0 then $control= _cc_loadcontrols($loadpath, $controlmax, $g_cc_controldatamax) $joystickid= $control[0][0];use the first control type as combo selection _guictrlcombobox_setcursel($joysticknamecombo, $joystickid) _cc_deletecontrolinput($controlinput, $control) _cc_createcontrolinput($controlinput, $control, $hgui, $guirect) $joystick= _cc_openjoystick($joystick, $joystickid, $joystickbuttons, $joystickaxes, $joystickhats) _cc_updatecontrolinput($control, $controlinput) endif case $filesaveconfig $savepath= filesavedialog("Save Config File", $g_cc_controlsavepath, "txt(*.txt)") if @error= 0 then $temp= stringmid($savepath, stringlen($savepath)-3);test file name extention if $temp<> ".txt" then $savepath= $savepath&".txt";if no .txt ext add one _cc_savecontrols($control, $savepath, $controlinput) endif case $axesmaxinput $joystickaxes= int(guictrlread($axesmaxinput)) endswitch;msg $msg= guigetmsg() ;Enables image click for control selection if _ispressed(1) then;left mouse button down _SDL_GetMouseState($mousex, $mousey) for $i= 0 to 7;$controlmax-1 ; this example only has 8 nespad rects $rect_a= $nespadbuttonselectsurf[$i][1] if _cc_mouseoverrect($mousex, $mousey, $nespadbuttonselectsurf[$i][1].x-9, $nespadbuttonselectsurf[$i][1].y-9, $nespadbuttonselectsurf[$i][1].w+9, $nespadbuttonselectsurf[$i][1].h+9) then $oldhighlightbutton= $highlightbutton $highlightbutton= $i guictrlsetstate($controlinput[$highlightbutton][1], $gui_focus) exitloop endif if $nespadbuttonselectsurf[$i][2]<> 0 then $rect_a= $nespadbuttonselectsurf[$i][3] if _cc_mouseoverrect($mousex, $mousey, $nespadbuttonselectsurf[$i][3]) then $oldhighlightbutton= $highlightbutton $highlightbutton= $i guictrlsetstate($controlinput[$highlightbutton][1], $gui_focus) exitloop endif endif next endif;_ispressed(1) image clicking if $highlightbutton> -1 then;capture user input if int($joystickid)> 0 then;detect joystick _SDL_JoystickUpdate($joystick) ;joystick buttons for $i= 0 to $joystickbuttons;check all the joystick buttons to find button pressed if _SDL_JoystickGetButton($joystick, $i) > 0 then $control[$highlightbutton][0]= $joystickid;keyboard or joystickid $control[$highlightbutton][1]= 10;type: 10button $newbutton= $i $control[$highlightbutton][2]= $newbutton;button or state endif next;button ;joystick axes if $disableaxes<> 1 then;if axes not disabled for $i= 0 to $joystickaxes-1;check the axi $axisintensity= _SDL_JoystickGetAxis($joystick, $i) if $axisintensity < -$analog_threshold then $control[$highlightbutton][1]= $buttontype[$e_axis][0]+$i;type: > 19 to 9999 axis $newbutton= "axis "&$i&" "&$axisintensity $control[$highlightbutton][2]= $axisintensity+1 else if $axisintensity > $analog_threshold then $control[$highlightbutton][1]= $buttontype[$e_axis][0]+$i;type: > 19 to 9999 axis $newbutton= "axis "&$i&" "&$axisintensity $control[$highlightbutton][2]= $axisintensity-1;button or state endif endif next;axis endif;disableaxis ;joystick hats for $i= 0 to $joystickhats $hat= _SDL_JoystickGetHat($joystick, $i) if $hat<> 0 then $control[$highlightbutton][1]= $buttontype[$e_hat][0]+$i $control[$highlightbutton][2]= $hat;button or state $newbutton= "hat "&$i&" "&$hat endif next;hat endif;joystickid> 0 if $newbutton== "do nothing" then ;do nothing else;update the control input fields with user input $control[$highlightbutton][0]= $joystickid;keyboard or joystickid guictrlsetdata($controlinput[$highlightbutton][1], "J"&$joystickid&" "&$newbutton) if $highlightbutton+1> $controlmax-1 then $highlightbutton= -1 guictrlsetstate($buttonok, $gui_focus);last control set, select buttonok else;select next input button to set guictrlsetstate($controlinput[$highlightbutton+1][1], $gui_focus) endif;select next control sleep(400);easy way to prevent spam assignment $newbutton= "do nothing" endif;newbutton else if _ispressed("1B") then exitloop;when no control is highlighted, ESC cancels out of configurejoystick() endif;highlightbutton> -1 if $oldhighlightbutton<> $highlightbutton then $redraw= 1 if $redraw= 1 then $redraw= 0 _SDL_BlitSurface($nespadsurf, 0, $screen, $drect);draw nes pad ;draw button highlight if $highlightbutton> -1 and $highlightbutton< $controlmax then _SDL_BlitSurface($nespadbuttonselectsurf[$highlightbutton][0], 0, $screen, $nespadbuttonselectsurf[$highlightbutton][1]);draw button selected rect1 if $nespadbuttonselectsurf[$highlightbutton][2]<> 0 then _SDL_BlitSurface($nespadbuttonselectsurf[$highlightbutton][2], 0, $screen, $nespadbuttonselectsurf[$highlightbutton][3]);draw button selected rect2 endif endif;highlightbutton control range _SDL_UpdateRect($screen, $nespadrect.x, $nespadrect.y, $nespadrect.w, $nespadrect.h) endif;redraw ;find target button focus if any if $control[0][0]= 0 then $focus_s= controlgetfocus($hgui) for $i= 0 to $controlmax-1 if $focus_s= "msctls_hotkey32"&$i+1 then $oldhighlightbutton= $highlightbutton $highlightbutton= $i exitloop endif next else $focush= ControlGetHandle ($hgui, "", ControlGetFocus($hgui));find the windows control focus $focusid= _WinAPI_GetDlgCtrlID ($focush);find the focus controlid for $i= 0 to $controlmax-1 if $focusid= $controlinput[$i][1] then $oldhighlightbutton= $highlightbutton $highlightbutton= $i endif;a= buttoninput[i][1] next endif endif;winactive(hgui) until $msg= $gui_event_close if $confirm= 1 then _cc_savecontrols($control, $g_cc_controlsavepath&$g_cc_controlsavefilename&$player&".txt", $controlinput) for $i= 0 to $controlmax-1 _SDL_FreeSurface($nespadbuttonselectsurf[$i][0]) next guictrldelete($filemenu) guictrldelete($playerlabel) guictrldelete($playercombo) guictrldelete($joysticknamecombo) guictrldelete($joysticklabel) guictrldelete($disableaxescheckbox) guictrldelete($axesmaxlabel) guictrldelete($axesmaxinput) guictrldelete($analog_thresholdlabel) guictrldelete($analog_thresholdinput) guictrldelete($buttoncancel) guictrldelete($buttonok) for $i= 0 to $controlmax-1 guictrldelete($controlinput[$i][0]);delete label if $control[0][0]= 0 then _GUICtrlHotkey_Delete($controlinput[$i][1]);delete hotkey control else guictrldelete($controlinput[$i][1]);delete gui input control endif next _SDL_FreeSurface($nespadsurf) _SDL_FillRect($screen, 0, $colorblack) _SDL_Flip($screen) sleep(100) return $confirm EndFunc;_configurecontrols($players, $controlmax) ; Save controls to disk func _cc_savecontrols($control, $filename, $controlinput) dircreate($g_cc_controlsavepath) $file= fileopen($filename, 2) if $file<> -1 then for $i= 0 to ubound($control)-1 if $control[0][0]= 0 then $control[$i][0]= 0 $control[$i][1]= 10 $control[$i][2]= _GUICtrlhotkey_GetHotkeyCode($controlinput[$i][1]) endif for $ii= 0 to $g_cc_controldatamax-1 filewriteline($file, $control[$i][$ii]) next next else msgbox(0, "Save Error", "Player controls could NOT be Saved to:"&@CRLF&$filename) endif fileclose($file) EndFunc;_cc_savecontrols($control, $filename, $controlinput) ; Load controls from disk, return control[controlmax][controldatamax] func _cc_loadcontrols($filename, $controlmax, $g_cc_controldatamax) local $control[$controlmax][$g_cc_controldatamax] $file= fileopen($filename) if $file<> -1 then for $i= 0 to $controlmax-1 for $ii= 0 to $g_cc_controldatamax-1 $control[$i][$ii]= int(filereadline($file)) next next fileclose($file) else msgbox(0, "Load Error", "Player controls could NOT be Loaded", 2000) endif;file<> -1 return $control EndFunc;_cc_loadcontrols($filename, $controlmax, $g_cc_controldatamax)() ; updates the control input fields func _cc_updatecontrolinput($control, byref $controlinput) local $newbutton= "" for $i= 0 to ubound($control)-1 if $control[0][0]= 0 then _GUICtrlHotkey_SetHotkeyCode($controlinput[$i][1], $control[$i][2]) else switch $control[$i][1] case $buttontype[$e_button][0] to $buttontype[$e_button][1] $newbutton= $control[$i][2] case $buttontype[$e_axis][0] to $buttontype[$e_axis][1];axis $newbutton= "axis "&$control[$i][1]-20&" "&$control[$i][2] case $buttontype[$e_hat][0] to $buttontype[$e_hat][1];hat $newbutton= "hat "&$control[$i][1]-10000&" "&$control[$i][2] case else;to prevent a J1, J0..controlmax spam on blank controls $newbutton= Null endswitch if $newbutton<> Null then $newbutton= "J"&$control[$i][0]&" "&$newbutton guictrlsetdata($controlinput[$i][1], $newbutton) endif next EndFunc;_cc_updatecontrolinput($control, byref $controlinput) ; Sets the positions and images of selected buttons on the nespad gui func _cc_nesgui_selectiondefine(byref $nespadbuttonselectsurf, byref $nespadrect) local $graphicpath= @scriptdir&"\..\Graphics\Nespad" $nespadbuttonselectsurf[0][0]= _IMG_Load($graphicpath&"\nes-select-up 95 105 28 26.png");up $nespadbuttonselectsurf[0][1]= _SDL_Rect_Create($nespadrect.x+95, $nespadrect.y+105, 28, 26) $nespadbuttonselectsurf[1][0]= _IMG_Load($graphicpath&"\nes-select-down 95 177 28 26.png");down $nespadbuttonselectsurf[1][1]= _SDL_Rect_Create($nespadrect.x+95, $nespadrect.y+177, 28, 26) $nespadbuttonselectsurf[2][0]= _IMG_Load($graphicpath&"\nes-select-left 58 140 25 29.png");left $nespadbuttonselectsurf[2][1]= _SDL_Rect_Create($nespadrect.x+58, $nespadrect.y+140, 25, 29) $nespadbuttonselectsurf[3][0]= _IMG_Load($graphicpath&"\nes-select-right 133 141 26 26.png");right $nespadbuttonselectsurf[3][1]= _SDL_Rect_Create($nespadrect.x+133, $nespadrect.y+141, 26, 26) $nespadbuttonselectsurf[4][0]= _IMG_Load($graphicpath&"\nes-select-select 228 178 30 12.png");select button highlight $nespadbuttonselectsurf[4][1]= _SDL_Rect_Create($nespadrect.x+228, $nespadrect.y+178, 30, 12) $nespadbuttonselectsurf[4][2]= _IMG_Load($graphicpath&"\nes-select-label 205 125 73 13.png");select text label $nespadbuttonselectsurf[4][3]= _SDL_Rect_Create($nespadrect.x+205, $nespadrect.y+125, 73, 13) $nespadbuttonselectsurf[5][0]= _IMG_Load($graphicpath&"\nes-select-select 228 178 30 12.png");start button highlight $nespadbuttonselectsurf[5][1]= _SDL_Rect_Create($nespadrect.x+306, $nespadrect.y+178, 30, 12) $nespadbuttonselectsurf[5][2]= _IMG_Load($graphicpath&"\nes-select-start-label 295 125 61 13.png");start text label $nespadbuttonselectsurf[5][3]= _SDL_Rect_Create($nespadrect.x+289, $nespadrect.y+125, 61, 13) $nespadbuttonselectsurf[6][0]= _IMG_Load($graphicpath&"\nes-select-B.png");button B $nespadbuttonselectsurf[6][1]= _SDL_Rect_Create($nespadrect.x+413, $nespadrect.y+170, 25, 24) $nespadbuttonselectsurf[6][2]= _IMG_Load($graphicpath&"\nes-select-B-label 447 224 15 14.png");B text label $nespadbuttonselectsurf[6][3]= _SDL_Rect_Create($nespadrect.x+447, $nespadrect.y+223, 15, 14) $nespadbuttonselectsurf[7][0]= _IMG_Load($graphicpath&"\nes-select-B.png");A button highlight $nespadbuttonselectsurf[7][1]= _SDL_Rect_Create($nespadrect.x+491, $nespadrect.y+170, 25, 24) $nespadbuttonselectsurf[7][2]= _IMG_Load($graphicpath&"\nes-select-A-label 524 223 15 15.png");A text label $nespadbuttonselectsurf[7][3]= _SDL_Rect_Create($nespadrect.x+524, $nespadrect.y+223, 15, 15) EndFunc;_cc_nesgui_selectiondefine(byref $nespadbuttonselectsurf, byref $nespadrect)( ; Get width and Height from a SDL Surface func _cc_surfget($surf, byref $w, byref $h) $struct= DllStructCreate($tagSDL_SURFACE, $surf) $w= DllStructGetData($struct, "w") $h= DllStructGetData($struct, "h") $struct= 0 EndFunc;_cc_surfget($surf, byref $w, byref $h) ; _cc_controlchanged() compairs the current controls to the user control file on disk func _cc_controlchanged($control, $player, $g_cc_controldatamax, $controlinput) local $controlmax= ubound($control) local $control_temp= _cc_loadcontrols($g_cc_controlsavepath&$g_cc_controlsavefilename&$player&".txt", $controlmax, $g_cc_controldatamax) for $i= 0 to $controlmax-1 for $ii= 0 to $g_cc_controldatamax-1 if $control[$i][0]= 0 then if _GUICtrlHotkey_GetHotkeyCode($controlinput[$i][1])<> $control_temp[$i][$ii] then return 1 else if $control[$i][$ii]<> $control_temp[$i][$ii] then return 1 endif next;$ii next;$i return 0 EndFunc;_cc_controlchanged($control, $player, $g_cc_controldatamax) ; returns a joystick object func _cc_openjoystick(byref $joystick, $joystickid, byref $joystickbuttons, byref $joystickaxes, byref $joystickhats) _SDL_JoystickClose($joystick) $joystick= 0 $joystickbuttons= -1 $joystickaxes= -1 $joystickhats= -1 if $joystickid> 0 then;joystick $joystick= _SDL_JoystickOpen($joystickid-1);b/c joystickid is 1 greater to allow for keyboard in the combobox $joystickbuttons= _SDL_JoystickNumButtons($joystick) $joystickaxes= _SDL_JoystickNumAxes($joystick) $joystickhats= _SDL_JoystickNumHats($joystick) endif return $joystick EndFunc;_cc_openjoystick($joystickid, byref $joystickbuttons, byref $joystickaxes, byref $joystickhats) ; $rect is for a SDL_Rect, however if $rect_y<> default then $rect is treated as $rect_x func _cc_mouseoverrect($mousex, $mousey, $rect, $rect_y= default, $rect_w= default, $rect_h= default) if $rect_y= default then if $mousex> $rect.x-1 and $mousex< $rect.x+$rect.w+1 then if $mousey> $rect.y-1 and $mousey< $rect.y+$rect.h+1 then return 1 endif endif else if $mousex> $rect-1 and $mousex< $rect+$rect_w+1 then if $mousey> $rect_y-1 and $mousey< $rect_y+$rect_h+1 then return 1 endif endif endif return 0 EndFunc;_cc_mouseoverrect($x, $y, $w, $h) func _cc_deletecontrolinput(byref $controlinput, byref $control) ;if $control[0][0]= 0 then for $i= 0 to ubound($control)-1 _GUICtrlHotkey_Delete($controlinput[$i][1]) next ;endif EndFunc;_cc_deletecontrolinput(byref $controlinput, byref $control) ; uses the first control type to determine guihotkey controls or input fields func _cc_createcontrolinput(byref $controlinput, $control, $hgui, $guirect) if $control[0][0]= 0 then;hotkey controls for $i= 0 to ubound($controlinput)-1 guictrldelete($controlinput[$i][1]) $controlinput[$i][1]= _GUICtrlHotkey_Create($hgui, $guirect.w-124, $guirect.h+($i*25), 121, 25) next else;input fields for joystick controls for $i= 0 to ubound($controlinput)-1 guictrldelete($controlinput[$i][1]);delete input field $controlinput[$i][1]= guictrlcreateinput("", $guirect.w-124, $guirect.h+($i*25), 121, 25) guictrlsendmsg(-1, $EM_SETREADONLY, 1, 0);read-only next endif EndFunc;_cc_createcontrolinput(byref $controlinput, $control, $hgui, $guirect) ; First time I've done this so I might be explaining wrong! ; Adapted from Mat's GUIHotkey.au3 to produce a _ispressed() hex keycode ; $keycode : keycode > 255 will have it's key modifier attributes removed ; returns a single _ispressed() keycode func _cc_getkeycode($keycode) Local $iLoByte= $keycode if $keycode> 255 then Local $iHiByte = BitShift($keycode, 8) $iLoByte = BitAND($keycode, 0xFF) endif return hex($iLoByte) EndFunc;_cc_getkeycode($keycode) ; clear the control object func _cc_clearcontrols(byref $control) for $i= 0 to ubound($control)-1 for $ii= 0 to $g_cc_controldatamax-1 $control[$i][$ii]= 0 next next EndFunc;_cc_clearcontrols(byref $control)Simple Example #include "configure controls udf.au3" global $debug= 0 test_main() func test_main() local $players= 3 local $controlmax= 8, $controldatamax= 3 local $player[$players][3];control, x, y ;AutoIt options opt("GUICloseOnESC", 0);disable escape closing AutoIt dialog opt("GUIResizeMode", $GUI_DOCKALL);force consistent control spacing of gui controls ;Windows GUI with SDL $hgui= guicreate(@scriptname, 850, 600, default, default, bitor($WS_MAXIMIZEBOX, $WS_MINIMIZEBOX));$WS_SIZEBOX if $debug= 0 then EnvSet("SDL_WINDOWID", $hgui);remark this to create AutoIt window and recieve error messages from AutoIt guisetstate();show screen hgui, screen window ;init SDL _SDL_Init_image() _SDL_Init($_SDL_INIT_EVERYTHING) ;SDL Video Surface $screen $screen= _SDL_SetVideoMode(850, 600, 0, $_SDL_SWSURFACE);bitor($_SDL_SWSURFACE, $_SDL_RESIZABLE) local $joysticks= _SDL_NumJoysticks(); local $joystickobj[$joysticks] if _configurecontrols($hgui, $screen, $players)= 1 then for $i= 0 to $players-1 $player[$i][0]= _cc_loadcontrols($g_cc_controlsavepath&$g_cc_controlsavefilename&$i&".txt", $controlmax, $controldatamax) $control= $player[0][0] if $control[0][0]> 0 then $joystickobj[$control[0][0]-1]= _SDL_JoystickOpen($control[0][0]-1) else;keyboard convert saved keypresses to _ispressed hex codes for $ii= 0 to $controlmax-1 $control[$ii][2]= _cc_getkeycode($control[$ii][2]) next $player[0][0]= $control endif next local $label= guictrlcreatelabel("Press the control assigned to 'Up', to exit", 15, 15) do if $control[0][0]= 0 then if _ispressed($control[0][2]) then exitloop else _SDL_JoystickUpdate($joystickobj[$control[0][0]-1]);update the joystick in question switch $control[0][1] case $buttontype[$e_button][0] to $buttontype[$e_button][1] if _SDL_JoystickGetButton($joystickobj[$control[0][0]-1], $control[0][2])> 0 then exitloop case $buttontype[$e_axis][0] to $buttontype[$e_axis][1];axis $axis= _SDL_JoystickGetAxis($joystickobj[$control[0][0]-1], $control[0][1]-$buttontype[$e_axis][0]) if $control[0][2]< 0 then if $axis< $control[0][2] - 1 then exitloop else if $axis> $control[0][2] - 1 then exitloop endif case $buttontype[$e_hat][0] to $buttontype[$e_hat][1];hat $hat= _SDL_JoystickGetHat($joystickobj[$control[0]-1], $control[0][1]-$buttontype[$e_hat][0]) if $hat= $control[0][2] then exitloop endswitch endif until guigetmsg()= $gui_event_close endif ;close systems If $__SDL_DLL <> -1 Then _SDL_Quit();"Once upon a time... You saw me ;)" If $__SDL_DLL_image <> -1 Then _SDL_Shutdown_image() EndFunc;main()Tank Player Example:Tank.au3 #include <Array.au3>;_arraydisplay() #include "configure controls udf.au3" #include "tank.h.au3" global $debug= 0 ; AutoIt options opt("GUICloseOnESC", 0);disable escape closing AutoIt dialog main() func main() makeconsole(); create a console gui ;then make transpartent gui main dialog local $hgui = GUICreate("Tank", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP, $WS_EX_LAYERED) _WinAPI_SetLayeredWindowAttributes($hgui, 0x000000, 255);transparency of main screen $hgui, black, 100%transparent if $debug= 0 then EnvSet("SDL_WINDOWID", $hgui);Attaches the next call to _SDL_SetVideoMode() surface to $hgui, idk really ; $debug turns off the attachment to the SDL Video Surface, and then gives us 2 windows 1 for the $hgui and 1 for the SDL Video Surface (I think). This will allow SciTE or whatever to pin point the errors and return them rather then just hang the script. ; Now $debug is a useful variable b/c if you ever need to detect window active in say a nested function environment then you can also check against $debug to toggle the check of active b/c in debug mode you'll have 2 ; windows, $hgui might not be the window you need it to be, when debuging whatever problem you are debuging. $debug can be used to easily avoid this problem. if(winactive($hgui) or $debug= 1) _SDL_Startup_sge() _SDL_Init_image() _SDL_Init($_SDL_INIT_EVERYTHING) local $screen = _SDL_SetVideoMode(@DesktopWidth, @DesktopHeight, 32, $_SDL_HWSURFACE);$screen is now the SDL Video Surface _AutoItObject_Startup(0) for $i= 0 to $players-1 $otank[$i]= tankobject() next local $tank_controlnames[]= ["Forward", "Reverse", "Left", "Right", "Nitro", "Jump", "Drill", "a"] loadplayercontrols() maketrig() loadpics() $redraw= 1 guisetstate();main screen turn on while 1 switch guigetmsg() case $gui_event_close exitloop case $fileexit exitloop case $fileconfigurecontrols winsetstate($hguiconsole, "", @sw_hide);the console doesn't work in the next dialog _WinAPI_SetLayeredWindowAttributes($hgui, 0x000001, 255);transparency to color not in configure controls dialog _configurecontrols($hgui, $screen, $players, $tank_controlnames);dialog for players to setup controls loadplayercontrols();reload the player control files _WinAPI_SetLayeredWindowAttributes($hgui, 0x000000, 255);transparency back to colorblack winsetstate($hguiconsole, "", @sw_show); endswitch _SDL_FillRect($screen, 0, $colorblack);clear the screen surface for $i= 0 to $players-1 $control= $a_tankcontrol[$i] tankcontrols($otank[$i], $i) $otank[$i].loopactions() $otank[$i].draw($screen, $i) next _SDL_Flip($screen);update the screen surface wend;main loop _SDL_Quit() _SDL_Shutdown_image() _SDL_Shutdown_sge() EndFunc;main() func loadplayercontrols() for $i= 0 to $players-1 $control= _cc_loadcontrols($g_cc_controlsavepath & $g_cc_controlsavefilename & $i & ".txt", $controlmax, $controldatamax) for $ii= 0 to $controlmax-1 if $control[$ii][0]> 0 then $joystickobj[$i]= _SDL_JoystickOpen($control[$ii][0]-1) consolewrite("Joystick "&$control[$i][0]-1& "opened") exitloop else;convert keystrokes $control[$ii][2]= _cc_getkeycode($control[$ii][2]) endif next $a_tankcontrol[$i]= $control next EndFunc;loadplayercontrols() func makeconsole($startup_output= "Hello world.") $hguiconsole= guicreate("Tank", $consolew, $consoleh) $filemenu= guictrlcreatemenu("File") $fileexit= guictrlcreatemenuitem("Exit", $filemenu) $g_consoleedit= guictrlcreateedit($startup_output, 10, 20, 300, 80) $fileconfigurecontrols= guictrlcreatemenuitem("Configure Controls", $filemenu) guictrlsendmsg($g_consoleedit, $EM_SETREADONLY, 1, 0);read-only guisetstate() EndFunc;makeconsole()Tank.h.au3 #include-once #include "tank.global.au3" #include "configure controls udf.au3" func consoleout($output) ; insert new line at end of edit control $iEnd = StringLen(GUICtrlRead($g_consoleedit));Melba23 ref: http://www.autoitscript.com/forum/topic/110948-add-text-to-edit-box-and-scroll-it-down/#entry778671 _GUICtrlEdit_SetSel($g_consoleedit, $iEnd, $iEnd) _GUICtrlEdit_Scroll($g_consoleedit, $SB_SCROLLCARET) guictrlsetdata($g_consoleedit, @crlf & $output, 1) EndFunc;consoleout($output) func loadpics() $path= @scriptdir & "\..\graphics\" consoleout("Load graphics from: " & $path&@crlf) local $w= 0, $h= 0 for $a= 0 to 180-1 for $i= 0 to $tank_tredframemax-1 $tank_tredl[$a][$i]= _SDL_LoadBMP($path & "lefttred\"&$a&"_"&$i&".bmp") _SDL_SetColorKey($tank_tredl[$a][$i], $_SDL_SRCCOLORKEY, _SDL_MapRGB($tank_tredl[$a][$i], 0x00, 0x00, 0x00)) $tank_tredr[$a][$i]= _SDL_LoadBMP($path & "righttred\"&$a&"_"&$i&".bmp") _SDL_SetColorKey($tank_tredr[$a][$i], $_SDL_SRCCOLORKEY, _SDL_MapRGB($tank_tredl[$a][$i], 0x00, 0x00, 0x00)) next;tred frame $tank_body[$a]= _SDL_LoadBMP($path & "body\"&$a&".bmp") _SDL_SetColorKey($tank_body[$a], $_SDL_SRCCOLORKEY, _SDL_MapRGB($tank_body[$a], 0x00, 0x00, 0x00)) for $i= 0 to $tank_drillframemax-1 $tank_drill[$a][$i]= _SDL_LoadBMP($path & "drill\"&$a&"_"&$i&".bmp") _SDL_SetColorKey($tank_drill[$a][$i], $_SDL_SRCCOLORKEY, _SDL_MapRGB($tank_drill[$a][$i], 0x00, 0x00, 0x00)) next;drill frame next;angle for $i= 0 to $tank_personmax-1 $tank_person[0][$i]= _SDL_LoadBMP($path & "person\"&$i&".bmp") _SDL_SetColorKey($tank_person[0][$i], $_SDL_SRCCOLORKEY, _SDL_MapRGB($tank_person[0][$i], 0x00, 0x00, 0x00)) next _cc_surfget($tank_person[0][0], $w, $h) if $players> 1 then for $i= 1 to $players-1 $colormask= $i*25 if $colormask> 255 then while $colormask> 255 $colormask-= 255 wend endif for $ii= 0 to $tank_personmax-1 $tank_person[$i][$ii]= _SDL_CreateRGBSurface($_SDL_HWSURFACE, $w, $h, 32, $colormask, $colormask, $colormask, 255) _SDL_BlitSurface($tank_person[0][$ii], 0, $tank_person[$i][$ii], 0) next next endif consoleout("Graphics Loaded") EndFunc;end loadpics() func fixa($a) if $a>= 359.9 then $a-= 360; if $a< 0 then $a+= 359.9; return $a EndFunc;end fixa($a) func maketrig() for $a= 0 to 359 $mycos[$a]= cos($a*3.1416/180) $mysin[$a]= sin($a*3.1416/180) next EndFunc;end maketrig() func tankcontrols(byref $tankobj, $player) local $action= -1 local $control= $a_tankcontrol[$player] _SDL_JoystickUpdate($joystickobj[$player]) for $i= 0 to $controlmax-1 $action= -1 if $control[$i][0]> 0 then;joystick ;_SDL_JoystickUpdate($joystickobj[$player]) ;joystick axis switch $control[$i][1];button type case $buttontype[$e_button][0] to $buttontype[$e_button][1];gamepad button if _SDL_JoystickGetButton($joystickobj[$player], $control[$i][2])> 0 then $action= $i endif case $buttontype[$e_axis][0] to $buttontype[$e_axis][1];axis $axis= _SDL_JoystickGetAxis($joystickobj[$player], $control[$i][1]-$buttontype[$e_axis][0]) if $control[$i][2]< 0 then if $axis< $control[$i][2] - 1 then $action= $i else if $axis> $control[$i][2] - 1 then $action= $i endif case $buttontype[$e_hat][0] to $buttontype[$e_hat][1];hat $hat= _SDL_JoystickGetHat($joystickobj[$player], $control[$i][1]-$buttontype[$e_hat][0]) if $hat= $control[$i][2] then $action= $i endswitch else;keyboard if _ispressed($control[$i][2], $hdll) then $action= $i endif endif;joystick or keyboard if $action> -1 then if $action= $e_tankctrl_forward then $tankobj.control_forward= 1 endif if $action= $e_tankctrl_backward then $tankobj.control_backward= 1 endif if $action= $e_tankctrl_left then $tankobj.control_left= 1 endif if $action= $e_tankctrl_right then $tankobj.control_right= 1 endif if $action= $e_tankctrl_nitro then $tankobj.control_nitro= 1 endif if $action= $e_tankctrl_jump then $tankobj.control_jump= 1 endif if $action= $e_tankctrl_drill then $tankobj.control_drill= 1 endif endif next;control EndFunc;end tankobjectcontrols()Tankclass.au3 #include-once #include "tank.global.au3" #include "configure controls udf.au3" func tankobject($iStartup = False) local $oObj = _AutoItObject_Create() _AutoItObject_AddMethod($oObj, "draw", "tankobjectdraw") _AutoItObject_AddMethod($oObj, "loopactions", "tankobjectloopactions") _AutoItObject_AddProperty($oObj, "x", $ELSCOPE_Public, random(32, @DesktopWidth-32, @DesktopHeight-32)) _AutoItObject_AddProperty($oObj, "y", $ELSCOPE_Public, random(32, 359)) _AutoItObject_AddProperty($oObj, "drillframe", $ELSCOPE_Public, 0) _AutoItObject_AddProperty($oObj, "angle", $ELSCOPE_Public, random(0, 359)) _AutoItObject_AddProperty($oObj, "acc", $ELSCOPE_Public, 0) _AutoItObject_AddProperty($oObj, "v", $ELSCOPE_Public, 0) _AutoItObject_AddProperty($oObj, "anglev", $ELSCOPE_Public, 0) _AutoItObject_AddProperty($oObj, "surf", $ELSCOPE_Public, 0) _AutoItObject_AddProperty($oObj, "tredframel", $ELSCOPE_Public, 0) _AutoItObject_AddProperty($oObj, "tredframer", $ELSCOPE_Public, 0) _AutoItObject_AddProperty($oObj, "distancetraveled", $ELSCOPE_Public, 100000) _AutoItObject_AddProperty($oObj, "distancetraveledl", $ELSCOPE_Public, 100000) _AutoItObject_AddProperty($oObj, "distancetraveledr", $ELSCOPE_Public, 100000) _AutoItObject_AddProperty($oObj, "nitroup", $ELSCOPE_Public, 0) _AutoItObject_AddProperty($oObj, "jumpy", $ELSCOPE_Public, 0) _AutoItObject_AddProperty($oObj, "jumpa", $ELSCOPE_Public, 0) _AutoItObject_AddProperty($oObj, "jumpv", $ELSCOPE_Public, 0) _AutoItObject_AddProperty($oObj, "updown", $ELSCOPE_Public, 0) ;controls local $a_control[$controlmax][$controldatamax] _AutoItObject_AddProperty($oObj, "a_control", $ELSCOPE_Public, $a_control) _AutoItObject_AddProperty($oObj, "control_forward") _AutoItObject_AddProperty($oObj, "control_backward") _AutoItObject_AddProperty($oObj, "control_left") _AutoItObject_AddProperty($oObj, "control_right") _AutoItObject_AddProperty($oObj, "control_drill") _AutoItObject_AddProperty($oObj, "control_jump") _AutoItObject_AddProperty($oObj, "control_nitro") $path= @scriptdir & "\..\graphics\" $oObj.surf= _SDL_LoadBMP($path & "drill\"&0&"_"&0&".bmp");create a tank surface to construct the tank on _SDL_SetColorKey($oObj.surf, $_SDL_SRCCOLORKEY, _SDL_MapRGB($oObj.surf, 0x00, 0x00, 0x00)) if $iStartup then $oObj.Startup return $oObj EndFunc;end tankobject func tankobjectdraw($oself, $screen, $player) _SDL_FillRect($oself.surf, 0, $colorblack);clear the tank surface $angleint= int($oself.angle/2) _SDL_BlitSurface($tank_tredl[$angleint][$oself.tredframel], 0, $oself.surf, 0);left tred _SDL_BlitSurface($tank_tredr[$angleint][$oself.tredframer], 0, $oself.surf, 0);right tred _SDL_BlitSurface($tank_body[$angleint], 0, $oself.surf, 0) _SDL_BlitSurface($tank_drill[$angleint][$oself.drillframe], 0, $oself.surf, 0) $personframe= int($oself.angle/360*$tank_personmax) _SDL_BlitSurface($tank_person[$player][$personframe], 0, $oself.surf, 0);draw person rider if $oself.jumpy< 0 then;surf,x,y,r,c,al _sge_FilledCircleAlpha($screen, $oself.x+32, $oself.y+48, 10+($oself.jumpy/6), _SDL_MapRGB($screen, 10, 10, 10), 100-($oself.jumpy)); _SDL_BlitSurface($oself.surf, 0, $screen, _SDL_Rect_Create($oself.x, $oself.y+$oself.jumpy, 64, 64));draw the tank surface else _SDL_BlitSurface($oself.surf, 0, $screen, _SDL_Rect_Create($oself.x, $oself.y, 64, 64));draw the tank surface endif;endif jumpy< 0 EndFunc;end draw() func tankobjectloopactions($oself) $oself.distancetraveledl= $oself.distancetraveledl+$oself.v+(17*$oself.anglev*3.1416/180) $oself.distancetraveledr= $oself.distancetraveledr+$oself.v+(-17*$oself.anglev*3.1416/180) $oself.distancetraveled= $oself.distancetraveled+$oself.v if $oself.jumpy> -1 then if $oself.control_forward= 1 then;26 up arrow $oself.acc= $oself.acc+.0009 $oself.v= $oself.v+$oself.acc else $oself.v= $oself.v*.9 if $oself.acc> 0 then $oself.acc= $oself.acc*.0005 endif if $oself.control_backward= 1 then;28 down arrow ;$oself.x-= $mysin[$tank_angle] $oself.x= $oself.x- $mysin[$oself.angle] $oself.y= $oself.y+ $mycos[$oself.angle] $oself.distancetraveledl= $oself.distancetraveledl-1 $oself.distancetraveledr= $oself.distancetraveledr-1 endif if $oself.control_left= 1 then;25 left arrow if $oself.anglev> 0 then $oself.anglev= 0 $oself.anglev= $oself.anglev-.1 $oself.angle= $oself.angle+$oself.anglev endif if $oself.control_right= 1 then;27 right arrow if $oself.anglev< 0 then $oself.anglev= 0 $oself.anglev= $oself.anglev+.1 $oself.angle= $oself.angle+$oself.anglev endif if $oself.control_drill= 1 then;44 'd' $oself.drillframe= $oself.drillframe+1 if $oself.drillframe> $tank_drillframemax-1 then $oself.drillframe= $oself.drillframe-$tank_drillframemax endif if $oself.control_nitro= 1 then;0x4E 'n' if $oself.nitroup= 0 then $oself.nitroup= 5 endif endif if $oself.control_jump= 1 then $oself.control_jump= 0 if $oself.jumpy> -1 and $oself.updown= 0 then $oself.jumpy= -45 endif endif else $oself.jumpy= $oself.jumpy+2 endif;jumpy= 0 if $oself.nitroup> 0 then $oself.control_nitro= 0 $oself.v= $oself.v*1.2 $oself.nitroup= $oself.nitroup-1 endif;endif $nitroup> 50 if $oself.x< -31 then $oself.x= $oself.x+@DesktopWidth if $oself.x> @DesktopWidth then $oself.x= $oself.x-@DesktopWidth if $oself.y< -31 then $oself.y= $oself.y+@DesktopHeight if $oself.y> @DesktopHeight+31 then $oself.y= $oself.y-@DesktopHeight if $oself.distancetraveled< 0 then $oself.distancetraveled= $oself.distancetraveled+100000 if $oself.distancetraveledl< 0 then $oself.distancetraveledl= $oself.distancetraveledl+100000 if $oself.distancetraveledr< 0 then $oself.distancetraveledr= $oself.distancetraveledr+100000 $oself.tredframel= $tank_tredframemax-1-mod(int($oself.distancetraveledl/$tank_tredframemax), $tank_tredframemax) $oself.tredframer= $tank_tredframemax-1-mod(int($oself.distancetraveledr/$tank_tredframemax), $tank_tredframemax) if $oself.control_left= 0 and $oself.control_right= 0 then $oself.anglev= 0 $oself.control_forward= 0 $oself.control_backward= 0 $oself.control_left= 0 $oself.control_right= 0 $oself.control_drill= 0 $oself.control_jump= 0 while $oself.angle>= 359.9 $oself.angle= $oself.angle-360; wend while $oself.angle< 0 $oself.angle= $oself.angle+359.9; wend if $oself.acc> 0 then;friction $oself.acc= $oself.acc-.01 else $oself.acc= 0 endif;end friction $oself.x= $oself.x- ($mysin[int($oself.angle)])*($oself.v) $oself.y= $oself.y+ ($mycos[int($oself.angle)])*($oself.v) EndFunc;end tankloopactions()Tank.global.au3 #include-once #Include "Include Lib\SDL v14\SDL.au3" #include "Include Lib\AutoItObject\AutoitObject.au3" #Include "Include Lib\SDL v14\SDL_sge.au3" #include <GUIConstantsEx.au3> #Include <WinAPI.au3> #include <WindowsConstants.au3> #Include <Color.au3> #Include <misc.au3> #include <GUIConstantsEx.au3> #include <EditConstants.au3> #Include <GUIEdit.au3> #Include <ScrollBarConstants.au3> global $hgui= 0 global $players= 3 global $otank[$players] global $a_tankcontrol[$players] global $joystickobj[$players] global $controlmax= 8, $controldatamax= 3 global $colorblack= 0 global $tank_tredframemax= 8, $tank_drillframemax= 3 global $tank_tredl[180][8], $tank_tredr[180][8], $tank_body[180], $tank_drill[180][3] global $tank_personmax= 32 global $tank_person[$players][$tank_personmax] global enum $e_tankctrl_forward= 0, $e_tankctrl_backward= 1, $e_tankctrl_left= 2, $e_tankctrl_right= 3, $e_tankctrl_nitro= 4, $e_tankctrl_jump= 5, $e_tankctrl_drill= 6 global $mycos[361], $mysin[361] global $tank_control_forward= 0 global $tank_control_backward= 0 global $tank_control_left= 0 global $tank_control_right= 0 global $tank_control_drill= 0 global $tank_control_jump= 0 global $hdll= dllopen("user32.dll") ;console window for tank global $consolew= 320, $consoleh= 200 global $hguiconsole= 0 global $filemenu= 0 global $fileexit= 0 global $g_consoleedit= 0 global $fileconfigurecontrols= 0 #include "tankclass.au3"Both tank and configure controls have a graphics pack. It's best to just download the Source Folder.If you like this idea, I encourage you to say something. It's a good way to keep me working on this. I think I dropped this tank project for at least a year.
  19. Hello guys I would like to be able to change songs on spotify using shourtcuts on my keyboard due to the fact i don't own a keyboard with extra keys providing this feature. Therefor I've made a script binding my keys to make this possible, but i have a few issues and I think there is a easier or better way of creating this script. I hope someone can have a look and tell me what i could improve. Some of the issues are: I have to wait a little time before i will be able to change song right after i just changed. (I can't spam ALT + Right) Doesn't work when im inside a game. This is actually a big issue for me. My current code which works: HotKeySet("!{left}", "Previous") HotKeySet("!{right}","naeste") HotKeySet("!{down}","current") HotKeySet("{DEL}","quit") While 1 Sleep(100) WEnd Func naeste() Sleep(400) ControlSend("Spotify", "", "", "^{right}") EndFunc Func Previous() Sleep(400) ControlSend("Spotify", "", "", "^{left}") EndFunc Func Current() Local $song = WinGetTitle("Spotify", "") TrayTip("", $song, 1) EndFunc Func quit() Exit 0 EndFunc - AliOzturk
  20. I am creating a GUI that uses mostly GDI work, and a few standard controls. This is the same one that I posted about >before. When my GUI has focus, I want to watch for the user to press the numbers 1-9. I do not want to monitor keyboard input when the GUI does not have focus. There are multiple ways to do this. Here are my ideas so far: Use _IsPressed. Currently I'm using the standard GUIGetMsg() loop, but I could easily convert to GUIOnEventMode and poll _IsPressed continuously. I haven't tested yet, but I assume it fires whether or not the GUI has focus. That's easy to watch for, though. Register WM_KEYUP. Oh how I wish that GUI controls didn't hog this message for themselves! The only way to make this work is to convert my GUI controls into "manual GDI controls" that I draw & manage myself. Then the GUI itself will receive WM_KEYUP (etc) messages. (I've already tested that with an empty GUI.) For GUI controls, all I have is a Tab control with a button on the first tab, and 2 buttons and a ListBox on the 2nd tab. Given the GDI work I'm already doing, it wouldn't be that much more work to make it happen. It also gives me more control over the style and look of things. Use HotKeySet. I would have to set and unset all 9 when the GUI gains/loses focus. This doesn't seem like the most elegant solution, but it's a good fall-back. Technically, I could hook the keyboard, but that's really shady and goes way beyond what I need. I'm not going to do that. So, which way is "best"? How do you define "best"? I think #1 is my best option, but I want to know what everyone else thinks and why. Maybe there's a better way? I doubt I've thought of everything.
  21. IsPressed_UDF is based on original _IsPressed function. Description : -This udf can detect if some keys are pressed by user on keyboard or mouse. -IsPressed functions extend possibility to choice keys to check. -Keys are specified in functions by their hexadecimal number, ['0D' = 'ENTER'] you can also translate hexadecimal key to alpha key (see functions and examples) Update : [Latest: 12 Jun 2013] Functions : Exemples : IsPressed_UDF 2.3 : IsPressed_UDF.au3 IsPressed_UDF 2.2 : IsPressed_UDF.au3 Add IsPressed_UDF functions to SciTE : IsPressed_Function Enjoy !
  22. Hello. How can I toggle Caps Lock mode other way than Send("{CAPSLOCK on/off/toggle}")? The problem is about Caps Lock button binded to other button from registry.
×
×
  • Create New...