Jump to content

olivarra1

Active Members
  • Posts

    49
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

olivarra1's Achievements

Seeker

Seeker (1/7)

1

Reputation

  1. My computer is a MSI AIO (It's a PC that's just a screen, like a mac) that has the headphone jack right behind it. Every time I want to switch between speakers/headphone i have to turn the whole PC, and unplug/plug back the headphones. That was, until the day I found MSI made an application called "msi Gaming Control Center" that lets you switch between headphones/speakers clicking on a button. However, booting this app and clicking it takes about 20-30 seconds, and I have a spare key in my keyboard I'd like to use to do this single action. I can program my keyboard to execute an application with no problem. I made a script to increase/decrease the volume, increase/decrease brightness easily, etc. (an Autoit script that uses http://nircmd.nirsoft.net/) gosh... I'm really used to laptops.... Is there anything that could guide me how to acomplish this? I tried looking for what DLLs does this program call with procmon, however, I have a hard time understanding it. To those who make UDFs that work with DLLs, how do you know which methods are available? Thanks, oli
  2. ComputerGroove has the solution. Think that in programming languages like these, the computer executes the program line by line, one after the other. So your script what does is first check wether the q key is pressed, and store that result in $ispressed (normally it gets to false) And then it will loop until $ispressed gets to true, but that will be never, since you never set the variable $ispressed again inside that loop. But I think ComputerGroove's solution using HotKeySet is what you are looking for. In that case, you tell AutoIt that whenever "q" is pressed, he should run the function "TogglePause", and in that TooglePause function you just set $paused to the value you want. This "feature" is called an interruption, because it "interrupts" the normal flow of the program, that's line by line.
  3. Hey there :3 During the first days of these week i've been thinking about developing a remote control, so i could control my computer from any device. At first, i was programming while i was brainstorming. I know i shouldn't do that, but i did . So the code got a little messy... Then these last 2 days i've remade it, and i think the code looks much clearer now. The server [what you put into the machine you want to control] is made with autoit. For flash clients, there's a second autoit, PolicyServer, that sends the policy file [policy.xml] to whichever client asks for it. The client is made with Flex 4 SDK. I put the FlashDevelop project folder inside the attachment. If you want to use it, you will have to look the code, and customize it so it feeds your needs [i.e., setting the IP / port, that's fixed in Constants]. Also, BE AWARE that this software is not secure, it doesn't use any encription method, so anyone could access your machine and do whatever with it. There's a little bit of security but it's not enough: i made that the client has to send a password [in raw text! D:] to be able to send commands. This way not anyone can access the computer, but anyone that puts a packet sniffer between you and your machine. I think this can be solved only by putting some Public Key criptography... but i don't have time to implement it. #include <GDIPlus.au3> #include <ScreenCapture.au3> Opt("MouseClickDragDelay", 50) Dim $deviceScreenWidth = 480 Dim $deviceScreenHeight = 770 Dim $deviceRatio = $deviceScreenWidth / $deviceScreenHeight Const $DEBUG = False ; If true, waits 1 second before executing any command that depends of the state of the remote machine [window active] Const $RESIZE_TO_BIGGER = False #cs If true, if the area to capture is smaller than the device screen, the image will be resized to fit the device screen and then sent. If false, it won't resize it, send it, and the client will resize to fit the image. True requires more bandwidth, but the quality of the resized image is a lot better than False. #ce Const $CLICK = "1" Const $DOWN = "2" Const $UP = "3" Const $RIGHT = "4" Const $LEFT = "5" Const $SCREEN = "6" Const $WINDOW = "7" Const $LOGIN = "a" Const $RESOLUTION = "b" Const $PASSWORD = "c" Const $AUTOIT = "d" Const $RAW = "e" Const $storedPassword = "myprivatepassword" Global $regionStartX Global $regionStartY Global $regionEndX Global $regionEndY Func getRegionWidth() Return $regionEndX - $regionStartX EndFunc Func getRegionHeight() Return $regionEndY - $regionStartY EndFunc _ScreenCapture_SetBMPFormat(0) TCPStartup() Dim $srvSocket, $cliSocket $srvSocket = TCPListen("127.0.0.1", 1045) ; Localhost connection ;$srvSocket = TCPListen("192.168.1.10", 1045) ; LAN connection ;$srvSocket = TCPListen("192.168.0.2", 1045) ; LAN connection If $srvSocket == -1 Then Exit EndIf Dim $error = True Dim $ratio = 0 Dim $allowed While 1 If $error Then Do $cliSocket = TCPAccept($srvSocket) $allowed = False $regionStartX = 0 $regionStartY = 0 $regionEndX = $regionStartX + @DesktopWidth ; @DesktopWidth $regionEndY = $regionStartY + @DesktopHeight ; @DesktopHeight Until $cliSocket <> -1 EndIf ;size(2)code(a-zA-Z0-9)data $s = TCPRecv($cliSocket, 2) $size = Int($s) If $size > 0 Then $str = TCPRecv($cliSocket, $size) While StringLen($str) < $size $str = $str & TCPRecv($cliSocket, $size - StringLen($str)) WEnd $codi = StringLeft($str, 1) $dades = StringTrimLeft($str, 1) If $codi == $LOGIN Then If $dades == "thisismypassword" Then If $DEBUG Then sleep(1000) $allowed = True EndIf ElseIf $codi == $RESOLUTION Then $str = StringSplit($dades, ",", 2) $deviceScreenWidth = Int($str[0]) $deviceScreenHeight = Int($str[1]) $deviceRatio = $deviceScreenWidth / $deviceScreenHeight ;TrayTip("", $deviceScreenWidth & ", " & $deviceScreenHeight, 5) ElseIf $codi == $PASSWORD And $allowed Then Send($storedPassword) ElseIf $codi == $AUTOIT And $allowed Then If $DEBUG Then sleep(1000) Send($dades, 0) ElseIf $codi == $RAW And $allowed Then If $DEBUG Then sleep(1000) Send($dades, 1) ElseIf $codi == $CLICK And $allowed Then $str = StringSplit($dades, ",", 2) $x0 = $str[1] / $ratio + $regionStartX $y0 = $str[2] / $ratio + $regionStartY $xf = $str[3] / $ratio + $regionStartX $yf = $str[4] / $ratio + $regionStartY If $str[0] == "r" Then ; right MouseClickDrag("secondary", $x0, $y0, $xf, $yf, 3) ElseIf $str[0] == "l" Then ; left MouseClickDrag("primary", $x0, $y0, $xf, $yf, 3) EndIf ElseIf $codi == $DOWN Then $val = Int($dades) $regionEndY = $regionEndY + $val / $ratio ElseIf $codi == $UP Then $val = Int($dades) $regionStartY = $regionStartY + $val / $ratio ElseIf $codi == $RIGHT Then $val = Int($dades) $regionEndX = $regionEndX + $val / $ratio ElseIf $codi == $LEFT Then $val = Int($dades) $regionStartX = $regionStartX + $val / $ratio ElseIf $codi == $SCREEN Then $regionStartX = 0 $regionStartY = 0 $regionEndX = $regionStartX + @DesktopWidth $regionEndY = $regionStartY + @DesktopHeight ElseIf $codi == $WINDOW Then If $DEBUG Then sleep(1000) $arr = WinGetPos("[ACTIVE]") $regionStartX = $arr[0] $regionStartY = $arr[1] $regionEndX = $regionStartX + $arr[2] $regionEndY = $regionStartY + $arr[3] EndIf EndIf $w = getRegionWidth() $h = getRegionHeight() $regionRatio = $w / $h If ($deviceRatio > 1 And $regionRatio > 1) Or ($deviceRatio < 1 And $regionRatio < 1) Then ; The device won't flip the image $ratio = $deviceScreenWidth / $w if $ratio * $h > $deviceScreenHeight Then $ratio = $deviceScreenHeight / $h Else ; The device will flip the image $ratio = $deviceScreenWidth / $h if $ratio * $w > $deviceScreenHeight Then $ratio = $deviceScreenHeight / $w EndIf If $ratio < 1 Or $RESIZE_TO_BIGGER Then $deviceW = $w * $ratio $deviceH = $h * $ratio Else $deviceW = $w $deviceH = $h EndIf If $allowed Then $img = _ScreenCapture_Capture("", $regionStartX, $regionStartY, $regionEndX, $regionEndY) _ImageResize($img, @ScriptDir & "\tmp.jpg", $deviceW, $deviceH) _WinAPI_DeleteObject($img) Else $img = _ScreenCapture_Capture("", 0, 0, 0, 0) _ImageResize($img, @ScriptDir & "\tmp.jpg", $deviceScreenWidth, $deviceScreenHeight) _WinAPI_DeleteObject($img) EndIf $size = FileGetSize(@ScriptDir & "\tmp.jpg") $oFile = FileOpen(@ScriptDir & "\tmp.jpg", 0) $bin = FileRead($oFile) FileClose($oFile) SetError(0) $str = to10chars(String($size)) TCPSend($cliSocket, $str) TCPSend($cliSocket, $bin) If @error Then $error = True Else $error = False EndIf WEnd Func to10chars($str) $num = 9 - StringLen($str) For $i = 1 To $num $str = "0" & $str Next $str = "s" & $str Return $str EndFunc Func _ImageResize($sInImage, $sOutImage, $iW, $iH) Local $hWnd, $hDC, $hBMP, $hImage1, $hImage2, $hGraphic, $CLSID, $i = 0 ;OutFile path, to use later on. Local $sOP = StringLeft($sOutImage, StringInStr($sOutImage, "\", 0, -1)) ;OutFile name, to use later on. Local $sOF = StringMid($sOutImage, StringInStr($sOutImage, "\", 0, -1) + 1) ;OutFile extension , to use for the encoder later on. Local $Ext = StringUpper(StringMid($sOutImage, StringInStr($sOutImage, ".", 0, -1) + 1)) ; Win api to create blank bitmap at the width and height to put your resized image on. $hWnd = _WinAPI_GetDesktopWindow() $hDC = _WinAPI_GetDC($hWnd) $hBMP = _WinAPI_CreateCompatibleBitmap($hDC, $iW, $iH) _WinAPI_ReleaseDC($hWnd, $hDC) ;Start GDIPlus _GDIPlus_Startup() ;Get the handle of blank bitmap you created above as an image $hImage1 = _GDIPlus_BitmapCreateFromHBITMAP ($hBMP) ;Load the image you want to resize. If IsString($sInImage) Then $hImage2 = _GDIPlus_ImageLoadFromFile($sInImage) Else $hImage2 = _GDIPlus_BitmapCreateFromHBITMAP($sInImage) ; This function is modified here, so we don't have to write the bmp to the hard disk EndIf ;Get the graphic context of the blank bitmap $hGraphic = _GDIPlus_ImageGetGraphicsContext ($hImage1) ;Draw the loaded image onto the blank bitmap at the size you want _GDIPLus_GraphicsDrawImageRect($hGraphic, $hImage2, 0, 0, $iW, $iH) ;Get the encoder of to save the resized image in the format you want. $CLSID = _GDIPlus_EncodersGetCLSID($Ext) ;Generate a number for out file that doesn't already exist, so you don't overwrite an existing image. Do $i += 1 Until (Not FileExists($sOP & $i & "_" & $sOF)) ;Prefix the number to the begining of the output filename ;$sOutImage = $sOP & $i & "_" & $sOF $sOutImage = $sOP & $sOF ;Save the new resized image. _GDIPlus_ImageSaveToFileEx($hImage1, $sOutImage, $CLSID) ;Clean up and shutdown GDIPlus. _GDIPlus_ImageDispose($hImage1) _GDIPlus_ImageDispose($hImage2) _GDIPlus_GraphicsDispose ($hGraphic) _WinAPI_DeleteObject($hBMP) _GDIPlus_Shutdown() EndFunc The function _ImageResize($sInImage, $sOutImage, $iW, $iH) is taken from this forum, but it's a bit modified. On my version, $sInImage can either be an image handle or a String. edit: and i know this already exists, but for me it was fun to do it and.... now there's 1 more in the world : )
  4. Hi, I'm developing my own remote control server for windows. If it works, it should be able to let any device [let it be Computers, Tablets or Smartphones (if the screen is too small, it's unpractical)] to access the computer that holds the server and be able to see what's on the screen, click wherever he wants, and send any text. To zoom to a certain area, the client will be able to set de top, bottom, left and right borders of the region that he wants to see, and the server will zoom to that part and send it to the device. But there are some problems: 1. I'm using JPG compression to send the screenshot to the client. I don't know if this will be enough for the bandwidth of a normal homemade connection. 2. Here comes the security part... If i set up a server that lets to do such things, then anyone can connect to my IP to that port, and fully control my computer [with those features, he can even delete all of my data] and i obviously don't want it. Then i thought: OK lets put a password you have to send everytime you log in. But let me be paranoid, and what if that evil hacker has put a packet sniffer between my device and my computer? he will get the password and he will be able to access it again. Then i think that putting a password may be worth, because at least not everyone will be able to access my computer, but hackers with some level of evil-hacking. Is there any solution to that? I don't want to implement a Public-Key security, since it would take too much to develop and makes the connection substantialy slower. I put the code i have here: #include <GDIPlus.au3> #include <ScreenCapture.au3> Const $DEVICE_SCREEN_WIDTH = 480 ; 800 Const $DEVICE_SCREEN_HEIGHT = 770 ; 800 ; 480 Const $deviceRatio = $DEVICE_SCREEN_WIDTH / $DEVICE_SCREEN_HEIGHT Const $CLIC = "1" Const $DOWN = "2" Const $UP = "3" Const $RIGHT = "4" Const $LEFT = "5" Global $regionStartX = 0 Global $regionStartY = 0 Global $regionEndX = $regionStartX + 1600 Global $regionEndY = $regionStartY + 900 Func getRegionWidth() Return $regionEndX - $regionStartX EndFunc Func getRegionHeight() Return $regionEndY - $regionStartY EndFunc _ScreenCapture_SetBMPFormat(0) TCPStartup() Dim $srvSocket, $cliSocket $srvSocket = TCPListen("127.0.0.1", 1045) ; Localhost connection ;$srvSocket = TCPListen("192.168.1.10", 1045) ; LAN connection If $srvSocket == -1 Then MsgBox(0, "", "can't setup server socket: " & @error) Exit EndIf #cs $regionStartX = 562 $regionStartY = 410 $regionEndX = 914 $regionEndY = 853 #ce Dim $error = True Dim $ratio = 0 While 1 If $error Then Do $cliSocket = TCPAccept($srvSocket) Until $cliSocket <> -1 EndIf $str = TCPRecv($cliSocket, 1) If $str <> "" Then If $str == $CLIC Then $str = TCPRecv($cliSocket, 10) $str = StringSplit($str, ",", 2) $x = $str[0] $y = $str[1] MouseClick("primary", $x / $ratio + $regionStartX, $y / $ratio + $regionStartY, 1, 0) ElseIf $str == $DOWN Then $str = TCPRecv($cliSocket, 10) $val = Int($str) $regionEndY = $regionEndY + $val ElseIf $str == $UP Then $str = TCPRecv($cliSocket, 10) $val = Int($str) $regionStartY = $regionStartY + $val ElseIf $str == $RIGHT Then $str = TCPRecv($cliSocket, 10) $val = Int($str) $regionEndX = $regionEndX + $val ElseIf $str == $LEFT Then $str = TCPRecv($cliSocket, 10) $val = Int($str) $regionStartX = $regionStartX + $val ElseIf $str = "<" Then ; Policy file request from outside-localhost flash player clients - not yet implemented EndIf EndIf $w = getRegionWidth() $h = getRegionHeight() $regionRatio = $w / $h If ($deviceRatio > 1 And $regionRatio > 1) Or ($deviceRatio < 1 And $regionRatio < 1) Then ; The device won't flip the image $ratio = $DEVICE_SCREEN_WIDTH / $w if $ratio * $h > $DEVICE_SCREEN_HEIGHT Then $ratio = $DEVICE_SCREEN_HEIGHT / $h Else ; The device will flip the image $ratio = $DEVICE_SCREEN_WIDTH / $h if $ratio * $w > $DEVICE_SCREEN_HEIGHT Then $ratio = $DEVICE_SCREEN_HEIGHT / $w EndIf $deviceW = $w * $ratio $deviceH = $h * $ratio ;_ScreenCapture_Capture(@ScriptDir & "\tmp.bmp", $regionStartX, $regionStartY, $regionEndX, $regionEndY) ; This is slow version ;_ImageResize(@ScriptDir & "\tmp.bmp", @ScriptDir & "\tmp.jpg", $deviceW, $deviceH) $img = _ScreenCapture_Capture("", $regionStartX, $regionStartY, $regionEndX, $regionEndY) ; This is optimized version _ImageResize($img, @ScriptDir & "\tmp.jpg", $deviceW, $deviceH) $size = FileGetSize(@ScriptDir & "\tmp.jpg") $oFile = FileOpen(@ScriptDir & "\tmp.jpg", 0) $bin = FileRead($oFile) FileClose($oFile) SetError(0) TCPSend($cliSocket, String($size)) TCPSend($cliSocket, $bin) If @error Then $error = True Else $error = False EndIf WEnd Func _ImageResize($sInImage, $sOutImage, $iW, $iH) Local $hWnd, $hDC, $hBMP, $hImage1, $hImage2, $hGraphic, $CLSID, $i = 0 ;OutFile path, to use later on. Local $sOP = StringLeft($sOutImage, StringInStr($sOutImage, "\", 0, -1)) ;OutFile name, to use later on. Local $sOF = StringMid($sOutImage, StringInStr($sOutImage, "\", 0, -1) + 1) ;OutFile extension , to use for the encoder later on. Local $Ext = StringUpper(StringMid($sOutImage, StringInStr($sOutImage, ".", 0, -1) + 1)) ; Win api to create blank bitmap at the width and height to put your resized image on. $hWnd = _WinAPI_GetDesktopWindow() $hDC = _WinAPI_GetDC($hWnd) $hBMP = _WinAPI_CreateCompatibleBitmap($hDC, $iW, $iH) _WinAPI_ReleaseDC($hWnd, $hDC) ;Start GDIPlus _GDIPlus_Startup() ;Get the handle of blank bitmap you created above as an image $hImage1 = _GDIPlus_BitmapCreateFromHBITMAP ($hBMP) ;Load the image you want to resize. If IsString($sInImage) Then $hImage2 = _GDIPlus_ImageLoadFromFile($sInImage) Else $hImage2 = _GDIPlus_BitmapCreateFromHBITMAP($sInImage) ; This function is modified here, so we don't have to write the bmp to the hard disk EndIf ;Get the graphic context of the blank bitmap $hGraphic = _GDIPlus_ImageGetGraphicsContext ($hImage1) ;Draw the loaded image onto the blank bitmap at the size you want _GDIPLus_GraphicsDrawImageRect($hGraphic, $hImage2, 0, 0, $iW, $iH) ;Get the encoder of to save the resized image in the format you want. $CLSID = _GDIPlus_EncodersGetCLSID($Ext) ;Generate a number for out file that doesn't already exist, so you don't overwrite an existing image. Do $i += 1 Until (Not FileExists($sOP & $i & "_" & $sOF)) ;Prefix the number to the begining of the output filename ;$sOutImage = $sOP & $i & "_" & $sOF $sOutImage = $sOP & $sOF ;Save the new resized image. _GDIPlus_ImageSaveToFileEx($hImage1, $sOutImage, $CLSID) ;Clean up and shutdown GDIPlus. _GDIPlus_ImageDispose($hImage1) _GDIPlus_ImageDispose($hImage2) _GDIPlus_GraphicsDispose ($hGraphic) _WinAPI_DeleteObject($hBMP) _GDIPlus_Shutdown() EndFunc
  5. Oh well, i just have 1 year programming in c++, i learned in university, using linux for making console applications. I've never done a windowed app., but i don't want to do that. just i want to do a console-like app. (that you run it with cmd). what i mean: #include <iostream> #include <string> using namespace std; int main(){ cout << "hello, how're u?" << endl; string response; cin >> response; return 0; } Then including If's, For's, While's, some classes, etc.. and what i want to do it's just a game server, the game is made with Flex + Flash. Right now i've made the server in PHP, but i wonder if in C++ would be faster and use less memory. olivarra1 edit: ohh btw, i've found how to include the sockets library. now i just need to see how does it works (functions that it has, etc.)
  6. Yeah, i saw that too, but idk how to get it... maybe i need Visual C++? i used to use DevC++ & so olivarra1
  7. i've googled a lot trying to find how to make a c or c++ TCP/IP server in Windows, but i found nothing. Then thinking and thinking i remembered that Autoit has functions to make TCP connections, and i thought asking here maybe somebody will know. Now the question: is there any way to make a c++/c TCP server for windows? thank you very much, Olivarra1
  8. Well, after a long time without using autoit, i want to make a packet sniffer. I've searched a lot and a lot and found anything The only thing that i want is to be able to read incoming data (data that comes from internet, not from the computer) My propose: I want my script to be able to read a flash game incoming data. I have a application (smart sniff) that sniffs all the traffic, and the script that i made this days, runs this program and then copies the relevant data, but is too slow. The information that sends the game is soo easy to understand. are things like 1|0|c|rotation_x|rotation_y|x_coordinate|y_coordinate so its so easy to proces (stringsplit($, '|')) Thanks olivarra1 PD: i'm not asking that you do this script for me, i just want a orientation like "look for TCPRecv(...)"
  9. woo thank you! now it works olivarra1 PD: this is what I get when I don't read ALL the documentation about the function that fails xD
  10. Today i've bought a new notebook, and it came with vista (this is the first time I run with vista) but when I open my scripts that need to open IE, doesn't work: firstly, it opens 2 windows of IE, one without any adress and the other with the adress that it has to be. this is not a heavy problem the problem goes when i set the property $f_wait of the function _IECreate to 1, that the page loads, but when its loaded, autoit doesn't do absolutely anything, as if he is wating for the page to load. Thanks, olivarra1
  11. Amazing!!! :) very good job olivarra1
  12. Hi is there any function that encodes a text using UTF-64 (or something like that)? I use stringtobinary($text) and then binarytostring($binary, 3), but it encodes to me to UTF-16 Thanks a lot ^^ olivarra1 PD: this function exists in php.
  13. ok, thank you, that's all olivarra1
  14. Thank you, very usefull (that's what I wanted) ^^ how can I make this? Thanks, olivarra1
  15. i've just seen XSkin, maybe this is what i'm looking for ^^ olivarra1 edit: yay, it's this, but I don't understand anythink (I know how to make skins in XSkin but i don't understand how XSkin makes it xD), can anybody tell me how to do it? thank you olivarra1
×
×
  • Create New...