
Markos
Active Members-
Posts
33 -
Joined
-
Last visited
Profile Information
-
Location
Czech Rep
Markos's Achievements

Seeker (1/7)
0
Reputation
-
Hotkey problem with a simple timer
Markos replied to Newscritpz's topic in AutoIt General Help and Support
Basically what you want to do is to register a one-time timer on your hotkey press, which after the period plays the sound. When the timer is running, and hotkey is pressed again, you want to unregister the previous timer and register a new one. -
With _IsPressed you have to poll for mouse click very often. For your need its better to use windows hooks. Take a look at _WinAPI_SetWindowsHookEx example, just use $WH_MOUSE_LL as hook type. MSDN documentation should help you understand how this works: http://msdn.microsoft.com/en-us/library/windows/desktop/ms644990(v=vs.85).aspx
-
If used directly in AutoIt, we can use: $hWnd = WinGetHandle("some window", "") $hCtrl = ControlGetHandle($hWnd, "", "some control") ControlClick("", "", $hCtrl) This simply works, however if I want to do the same from DLL, to use handles, we have to use the [HANDLE:] advanced window description: var hWnd = AU3_WinGetHandle("some window", ""); var hCtrl = AU3_ControlGetHandle("[HANDLE:" + hWnd + "]", "", "some control"); //this WORKS, but we have to use the HANDLE:, to tell autoit that it is a handle, not just a text //now I want to do line 3 from previous example: AU3_ControlClick("", "", [HANDLE:" + hCtrl + "]"); //this does NOT WORK while the same code in autoit does. //I have also tried to use just the handle; to use WinTitleMatchMode=3 and "handle="+hCtrl, but always no luck. (example is simplified to demonstrate the problem, I know that I have to use buffer to get return values) (the issue isnt getting ControlClick to work, but to get the hCtrl to work; using ControlClick without using handle does work of course) Is this part unimplemented in the autoit dll? Or do I have to do something special? Maybe this is a bug? Maybe it is on purpose? Or I am just too tired to see what is wrong? I just need to use handles, because I am doing a search in messy window. The only workaround that comes to me right now would be to find the control and get its ID, then rerference it as (windowHandle, controlID) tuple. But I have no idea how would I get the ID. And the control hwnd would still suit me better, because i wouldnt need to reference the control using also window handle. I am looking forward to see your suggestions. Markos
-
C# use of the dll, some idears for you.
Markos replied to jcddcjjcd's topic in AutoItX Help and Support
No need to register, but you must put the AutoItX dll in the path (next to exe or to any folder referenced by PATH variable), so it can be loaded at runtime -
ControlSend by using only windows funcs
Markos replied to Markos's topic in AutoIt General Help and Support
Justo clarify what I wanted to say: Some games dont have ANY controls. For example Guild Wars. $hWnd = WinGetHandle('Guild Wars') ControlSend($hwnd, '', '', 'My Text to send') I am 100 % sure that this works with guild wars on non-active window (my friend told me that i works for WoW too, but I didnt try it). It does not have any controls, so I am not specifying any control as Authenticity said nor I am sending text to active window as enaiman said. I tried to send using Sendmessage or Postmessage directly to the hwnd but it does not work. But it DOES work (100 %) with controlsend (as I wrote in 1st post and you dont believe me). So I believe autoit does "something" jsut before the postmessage, and I dont know what exactly. The autoit source code is huge so its not so easy to find. Thats what I wanted to get help with. So one more time: I am hundred percent sure that sending to GW using ControlSend withou using any control to non-active window works. -
ControlSend by using only windows funcs
Markos replied to Markos's topic in AutoIt General Help and Support
Well, I am sorry to be rude. If you dont want to help, dont post anything please. You obviously didnt read my post. ControlSend without control specified does not behave exactly like send. It just behaves exactly like controlsend witjout control specified. But thanx for your advices. -
ControlSend by using only windows funcs
Markos replied to Markos's topic in AutoIt General Help and Support
This one quite didnt help since i dont want to use controlsend as I wrote before. -
Hello, I am trying to translate ControlSend to C#. I have been successful with sending to windows that actually have some controls (like notepad has Edit) but not to windows that dont have any controls (such as games). I know it HAS to be possible, since Autoits' ControlSend function CAN send to window without controls. I have tried to find answer in AutoIt SourceCode that Jon released a long, long time ago, but i wasn't succesful. So what I want to do: Be able to use ControlSend feature without actually calling ControlSend. If we can accomplis this in AutoIt, I can translate it to C#. If the window has controls, I can simply get the control handle and succesfully send to it: #include <sendmessage.au3> #Include <String.au3> $hwnd = WinGetHandle('[CLASS:Notepad]') $child = _GetTopChild($hwnd) Global $WM_CHAR = 0x102 _SendMessage($Child, $WM_CHAR, '0x' & _StringToHex('d'), 0) Func _GetTopChild($aParent) Local $last_top Local $hwnd_top = $aParent Do $last_top = $hwnd_top ConsoleWrite('last top: ' & $last_top & @CRLF) $hwnd_top = _GetTopWindow($last_top) Until $hwnd_top = 0 Return $last_top EndFunc Func _GetTopWindow($hwnd) Local $ret = DllCall('user32.dll', 'hwnd', 'GetTopWindow', 'hwnd', $hwnd) Return $ret[0] EndFunc This does not work with windows that dont have any controls (like games). I have tried to search in the AutoIt source code and I think that autoit just Attaches to window and if it does not find any controls it sends to main window. (but it is probably wrong, since it does not work too) This is my translation from AutoIt source code to autoit code, which does not work and needs some improvement. #include <winapi.au3> #include <WindowsConstants.au3> #Include <String.au3> $hwnd = WinGetHandle('[CLASS:Notepad]') $vk = 0x44;D $scan = _MapVirtualKey($vk, 0) _WinAttach($hwnd, True) $lparam = BitOR( 0x00000001, BitShift($scan, -16) ) $ret = _WinAPI_PostMessage($hwnd, $WM_KEYDOWN, $vk, $lparam) ConsoleWrite($ret & @CRLF) Sleep(100);sleep between keyDown and keyUp $lparam = BitOR( 0xC0000001, BitShift($scan, -16) ) $ret = _WinAPI_PostMessage($hwnd, $WM_KEYUP, $vk, $lparam) ConsoleWrite($ret & @CRLF) Func _MapVirtualKey($uCode, $uMapType) $ret = DllCall('user32.dll', 'int', 'MapVirtualKey', 'int', $uCode, 'int', $uMapType) ConsoleWrite('scan: ' & $ret[0] & @CRLF) Return $ret[0] EndFunc Func _WinAttach($hWnd, $fAttach) Local $myThread = _GetCurrentThreadId(); Local $curthread, $newThread If $fAttach Then $curthread = _GetWindowThreadProcessId(_GetForegroundWindow() , 0) _AttachThreadInput($myThread, $curthread, 1) If $hWnd Then $newThread = _GetWindowThreadProcessId($hwnd, 0) _AttachThreadInput($curthread, $newThread, 1) _AttachThreadInput($myThread, $newThread, 1) EndIf Else EndIf EndFunc Func _GetCurrentThreadId() Local $ret = DllCall('kernel32.dll', 'int', 'GetCurrentThreadId') ConsoleWrite('currentThreadID: ' & $ret[0] & @CRLF) Return $ret[0] EndFunc Func _GetWindowThreadProcessId($hwnd, $processid) Local $ret = DllCall('user32.dll', 'int', 'GetWindowThreadProcessId', 'hwnd', $hwnd, 'int', $processid) ConsoleWrite('GetWindowThreadProcessId: ' & $ret[0] & @CRLF) Return $ret[0] EndFunc Func _GetForegroundWindow() Local $ret = DllCall('user32.dll', 'int', 'GetForegroundWindow') ConsoleWrite('GetForegroundWindow: ' & $ret[0] & @CRLF) Return $ret[0] EndFunc Func _AttachThreadInput($idAttach, $idAttachTo, $fAttach) Local $ret = DllCall('user32.dll', 'int', 'AttachThreadInput', 'int', $idAttach, 'int', $idAttachTo, 'int', $fAttach) ConsoleWrite('AttachThreadInput: ' & $ret[0] & @CRLF) Return $ret[0] EndFunc So if ANYBODY has ANY idea, I would be glad to see it, Markos
-
So I have finally took deeper look into ascendant's functions. Thank you - your funcs are gr8 piece of work, that is exactly what I was looking for. If anybody is interested in what I was trying to accomplish - here is the code: #include "_PDH_PerformanceCounters.au3" #include "Native_Wifi_Func_V2_1.au3" Local $sObject = '\Rozhraní sítě(Bezdrátová dvoupásmová minikarta Dell 1490 WLAN)\Aktuální šířka pásma' Global $sSSID = 'Mi-Fi' Global $iRecheckTime = 60000 Global $iReconnectIfLowerThan = 5500000 Global $hPDH_QueryHandle = _PDH_GetNewQueryHandle() Global $hPDH_CounterHandle = _PDH_AddCounter($hPDH_QueryHandle, $sObject) Global $hClientHandle = _Wlan_OpenHandle() Global $pGUID = _Wlan_EnumInterfaces($hClientHandle) Global $aInterfaceRes While 1 $aInterfaceRes = _Wlan_QueryInterface($hClientHandle, $pGUID[0][0], 3) ;~ If Not IsArray($aInterfaceRes) ThenConsoleWrite('Disconnected' & @CRLF) If IsArray($aInterfaceRes) And $aInterfaceRes[1] = $sSSID And _PDH_UpdateCounter($hPDH_QueryHandle,$hPDH_CounterHandle) <= $iReconnectIfLowerThan Then _Wlan_Disconnect($hClientHandle, $pGUID[0][0]) _Wlan_Connect($hClientHandle, $pGUID[0][0], $sSSID) EndIf Sleep($iRecheckTime) WEnd Func OnAutoItExit() _Wlan_CloseHandle($hClientHandle) _PDH_FreeQueryHandle($hPDH_QueryHandle) _PDH_UnInit($hPDH_QueryHandle) EndFunc
-
nobody?
-
Hi, I am trying to make script that detects the actual speed of my Wlan - it sometimes stucks on 5.5 Mbits and i have to reconnect to wlan to get the full speed again. I've been searching quite long for func that can retrieve the information - without success. Now I found some function on MSDN that should be able to return the speed - MultinetGetConnectionPerformance. The point is that the function requires input from another function and that from another function, ... and so I got lost. I really dont know how to continue so I would be glad if somebody gives me a helping hand. ;http://msdn.microsoft.com/en-us/library/aa385353(VS.85).aspx ;typedef struct _NETRESOURCE {DWORD dwScope;DWORD dwType;DWORD dwDisplayType;DWORD dwUsage;LPTSTR lpLocalName;LPTSTR lpRemoteName;LPTSTR lpComment; LPTSTR lpProvider; Local $NETRESOURCESTRUCT = DllStructCreate('dword;dword;dword;dword;str;str;str;str') ;typedef struct _NETCONNECTINFOSTRUCT { DWORD cbStructure; DWORD dwFlags; DWORD dwSpeed; DWORD dwDelay; DWORD dwOptDataSize; Local $NETCONNECTINFOSTRUCT = DllStructCreate('dword cbStructure;dword dwFlags;dword dwSpeed;dword dwDelay;dword deOptDataSize') #cs http://msdn.microsoft.com/en-us/library/aa385449(VS.85).aspx __in HANDLE hEnum, __inout LPDWORD lpcCount, __out LPVOID lpBuffer, __inout LPDWORD lpBufferSize ); #ce DllCall('Mpr.dll', 'dword', 'WNetEnumResource', 'ptr', $hEnum, 'dword*', $lpcCount, 'ptr', $lpBuffer, 'dword*', $lpBufferSize) ; http://msdn.microsoft.com/en-us/library/aa385342(VS.85).aspx DllCall('Mpr.dll', 'dword', 'MultinetGetConnectionPerformance', 'ptr', DllStructGetPtr($NETRESOURCESTRUCT), 'ptr', DllStructGetPtr($NETCONNECTINFOSTRUCT)) MsgBox(0, '', DllStructGetData($NETCONNECTINFOSTRUCT, 'dwSpeed'))
-
to get back to the town u can easily do: Send('{enter}/resign{enter}') Sleep(2000) MouseClick ( "left" , 100, 200, 1, 0) ;instead 100 and 200a use coordinates of "return to town" dialog
-
[Solved] Need help with DllStructCreate
Markos replied to Markos's topic in AutoIt General Help and Support
@Jos Yes I searched that. Their structure didnt work for me. But I have fixed it now, It must have 38 elements but I missed 1 "int" so i had 37. That caused the autoIt crash. Thanx for your help anyway -
[Solved] Need help with DllStructCreate
Markos replied to Markos's topic in AutoIt General Help and Support
You quite didnt read my post. Is it even POSSIBLE to create struct with more than 16 elements? -
Hello, I am working on little TeamSpeak2 plugin that uses their TSRemote.dll It has function 'tsrGetUserInfo' which returns TS2 Users info (his flags, channel, etc.) but it requires a pointer to a Struct of 38 elements! Actually it is working for me with only 16 elements, but then I dont receive all of the informations the function would normally return. If I specify more elements, AutoIt crashes with 'Dont send' dialog. Did I do something wrong? Or is it known autoit limitation? Is it problem of the dll? Is there something I can do to fix this problem? Thanx for your help. $struct = DllStructCreate('int PlayerId;int ChannelID;char[4];char[4];char[4];char[4];char[4];char[4];char[4];char[4];int PlayerPrivileges;int PlayerFlags;int;int;int;int') $pointer = DllStructGetPtr($struct)