Jump to content

Abilio_KID

Active Members
  • Posts

    63
  • Joined

  • Last visited

Abilio_KID's Achievements

Wayfarer

Wayfarer (2/7)

1

Reputation

  1. You're the one saying that making it "pro" style is better. I never said my way was better nor worse, just simpler FOR ME (incase you didn't read it). You should also know that there's never a "best design", specially in programming. Take a look at all the modern crap we have in nowadays software. I'm sure you know a lot of good examples. And to stop this now, as you put it, I don't think it's a good way to stick in everyone's face something like "the ways the pros do it is the right way", specially when AutoIt was made for simplicity. If we wanted to be pros I'm sure we'd all be learning some more advanced language... You'll have to excuse me though. I'm not a developer. I'm a guy that knows a tiny bit of many things but unfortunently isn't pro at any. I do what I can.
  2. $s = StringReplace(@ScriptName,".au3",".exe") $p = ProcessList($s) ; --- Check if this program is already running. If so then exit. If $p[0][0] > 1 Or $s <> "MyProgram.exe" Then Exit This works for me. I'll insist I'm not a programmer, I simply do a couple scripts once in a while. Because of it, I try to use the simplest way that works FOR ME. Well... if then you have a 3rd program that you rename to mine and then you run mine... sure, it will think it's already running. BTW guiness, I never said mine was a great post. I simply said it was simpler (in other words).
  3. If you rename it, then you're running "another" program, so you probably want to be running another copy of it... (it's a question of logic). But you are right. It's just I prefer things simpler (I use the same name for both the au3 and exe).
  4. Hmm... been using this: ... $p = ProcessList(StringReplace(@ScriptName,".au3",".exe")) ; --- Check if this program is already running. If so then exit. If $p[0][0] > 1 Then Exit ...
  5. Isn't it simpler to go around and use the builtin AutoIT functions? To check if our program (whatever the name is) is already running (the way I do it, of course): ; Check if this program is already running. If so then exit. $p = ProcessList(StringReplace(@ScriptName,".au3",".exe")) If $p[0][0] > 1 Then MsgBox(0,"Error", @ScriptName & " is already running! Exiting...", 3) Exit EndIf
  6. Thanks UEZ, I would eventually slim it down to avoid having another (almost) repeated function, but you saved me some work. Thanks once more.
  7. Ok, seems I'm smart enough to look into the includes and figure this out myself. I copied some small code from one UDF function into another. Here's the result: #include <ScreenCapture.au3> ;These 2 are not needed as they are already included once in <ScreenCapture.au3> ;#include <WinAPI.au3> ;#include <GDIPlus.au3> $file = @ScriptDir & "\xxx.jpg" ;File to save the screenshot (as an example) Global $qua = 100 ;JPEG quality $per = 75 ;Percentage of the original screenshot size ; Take a screenshot and save it to disc (I have 2 monitors) _ScreenCapture_SetJPGQuality($qua) ;This setting was previously ignored unless I used "_ScreenCapture_Capture" $x1 = _WinAPI_GetSystemMetrics(76) $y1 = _WinAPI_GetSystemMetrics(77) $x2 = _WinAPI_GetSystemMetrics(78) $y2 = _WinAPI_GetSystemMetrics(79) If $per = 100 Then $pic = _ScreenCapture_Capture($file, $x1, $y1, $x2, $y2) ;JPEG is saved in whatever quality I chose in "$qua" Else $pic = _ScreenCapture_Capture("", $x1, $y1, $x2, $y2) _GDIPlus_Startup() $bmp = _GDIPlus_BitmapCreateFromHBITMAP($pic) $scaled = _GDIPlus_ImageResize($bmp, $x2*$per/100, $y2*$per/100, 7) ;Scaling works as intended My_GDIPlus_ImageSaveToFile($scaled, $file) ;Used the altered function instead. Now it works. _GDIPlus_BitmapDispose($bmp) _GDIPlus_BitmapDispose($scaled) _GDIPlus_Shutdown() EndIf _WinAPI_DeleteObject($pic) Exit ; Changed from original "_GDIPlus_ImageSaveToFile" Func My_GDIPlus_ImageSaveToFile($hImage, $sFileName) Local $sExt = __GDIPlus_ExtractFileExt($sFileName) Local $sCLSID = _GDIPlus_EncodersGetCLSID($sExt) If $sCLSID = "" Then Return SetError(-1, 0, False) ; Added from here... Local $tData, $tParams $tParams = _GDIPlus_ParamInit(1) $tData = DllStructCreate("int Quality") DllStructSetData($tData, "Quality", $qua) ;Using here my variable instead _GDIPlus_ParamAdd($tParams, $GDIP_EPGQUALITY, 1, $GDIP_EPTLONG, DllStructGetPtr($tData)) Local $pParams = 0 If IsDllStruct($tParams) Then $pParams = $tParams ; ...to here. Local $bRet = _GDIPlus_ImageSaveToFileEx($hImage, $sFileName, $sCLSID, $pParams) ;Changed from "0" to "$pParams" Return SetError(@error, @extended, $bRet) EndFunc Basically I added to the function the option of chosing the JPEG quality. Shouldn't this be already in the UDF? Unless I'm missing something here...
  8. I've been reading a bit the forums and I simply couldn't find (yet) a solution to this small problem. I have a piece of code that takes a screenshot of the full desktop (multiple monitors included) and saves it to disk. So far nothing too hard, I even setup a variable to reduce the JPEG quality if I want to. However, I also used another variable to select screenshot percentage (for example, 50% of the original destop size). For that matter I need to do a few more bits of code to resize the image and then save it to disk. Now the problem, whatever JPEG quality I chose, the final image is not the quality I set up. It's also never 100% full quality. Here's an example code (just for testing) of what I mean: #include <ScreenCapture.au3> ;These 2 are not needed as they are already included once in <ScreenCapture.au3> ;#include <WinAPI.au3> ;#include <GDIPlus.au3> $file = @ScriptDir & "\xxx.jpg" ;File to save the screenshot (as an example) $qua = 100 ;JPEG quality $per = 75 ;Percentage of the original screenshot size ; Take a screenshot and save it to disc (I have 2 monitors) _ScreenCapture_SetJPGQuality($qua) ;This setting seems to be ignored unless I use "_ScreenCapture_Capture" $x1 = _WinAPI_GetSystemMetrics(76) $y1 = _WinAPI_GetSystemMetrics(77) $x2 = _WinAPI_GetSystemMetrics(78) $y2 = _WinAPI_GetSystemMetrics(79) If $per = 100 Then $pic = _ScreenCapture_Capture($file, $x1, $y1, $x2, $y2) ;JPEG is saved in whatever quality I chose in "$qua" Else $pic = _ScreenCapture_Capture("", $x1, $y1, $x2, $y2) _GDIPlus_Startup() $bmp = _GDIPlus_BitmapCreateFromHBITMAP($pic) $scaled = _GDIPlus_ImageResize($bmp, $x2*$per/100, $y2*$per/100, 7) ;Scaling works as intended _GDIPlus_ImageSaveToFile($scaled, $file) ;Even if "$qua = 100" it seems to save it at a lesser quality. WHY? _GDIPlus_BitmapDispose($bmp) _GDIPlus_BitmapDispose($scaled) _GDIPlus_Shutdown() EndIf _WinAPI_DeleteObject($pic) Sorry if this has already been answeared somewhere else but I don't seem to be able to find anything yet.
  9. Hmm, so I guess nobody had a similar thing or simply nobody cares at all. Lets hope there aren't more issues with 64 bit programs in the future, considering the future is x64...
  10. My script is using AutoIt x64, not compiled yet. The other program has 2 versions, one 32bit and the other 64bit. If I run my script on the 32bit program, it works, detects the color properly. If I run my script on the 64bit version of the same program (it's exactly the same in terms of graphics), it never finds the color I want because it sees everything as 0 (probably black). Nothing much into the code, simple as this: $coord = PixelSearch( $x, $y, $x+$xx, $y+$yy, $c, $sh) If Not @error Then MouseClick("left") EndIf
  11. Hi all, I've tried to search the forums for something similar but can't find an explination to my small problem. I recently moved to Windows 7 x64 and I have a script that sends mouse clicks to another program. If the program is 32 bit the mouse click works fine. However if the program is 64 bit, only sending keystrokes works, Mouseclick does nothing at all. The program is exactly the same, only it has 2 versions, one x86 and the other x64, the script is the same. Is there any bug in the Mouseclick command that won't work on x64 apps? Edit: It seems the problem lies on pixel functions on x64 programs. PixelGetColor always returns 0. Can anyone confirm this?
  12. This may sound silly, but make a 1x1 bitmap in Paint, with just a dot with the color #FF00FF. Save it to the script folder then try this: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $gui = GUICreate("", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP, $WS_EX_LAYERED) GUISetBkColor(0xFF00FF) $a = GUICtrlCreatePic(@ScriptDir & "\dot.bmp", 0, 0, 1, 1) $but1 = GUICtrlCreateButton("Exit", 100, 100, 100, 21) $but2 = GUICtrlCreateButton("Some button", 100, 200, 100, 21) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() select case $msg = $but1 Exit case $msg = $but2 msgbox(0, "", "Some random box") endselect WEnd
  13. I use AutoIt for simple and quick app's. I'm not a programmer but I have done some nice small app's with AutoIt to help me in my day-to-day needs. Icekirby1, I'm giving a the developpers a tip on a simple thing to improve AutoIt GUI functionality. Take a look at Larry's dll, it's very small and shouldn't be hard to implement. For me not replying at all is a lot worse then double posting, but that's just me. All programs use API calls somehow. Would be nice to do it inside AutoIt. For now I'll try Larry's DLL call and wait for something better.
  14. Tip: put the dll call as a command inside AutoIt code, simple as that. If not then provide a similar way of doing it with just AutoIt commands. I already gave you an example. I create a layered window (GUI) then a pic control I apply as the background. Pink parts of the pic become transparent and I can use the pic as a way of dragging the window. Now if I add another pic control as the title bar, make it the one that drags the window and not the background then the background pic looses the transparent parts (they become visible). As for the forum it's the usual in any forum at all. If I don't reply enough and people don't usually know me then they simply don't reply at all.
  15. I'd like to do it only using AutoIt code and not another external DLL. Actually, if that's so simple why isn't there a command like that in AutoIt itself?I never liked the idea of using DLL's or plugins with my app. I prefer the user clicks single exe and never has to worry about missing DLL's and stuff. Of course I could "install" the DLL temporarily but that's not what i want to. Tbh what I want to know is why this works with a single picture (I can use the bitmap and the transparency works) but if I put another picture on top of it then it doesn't work anymore. Is it just me or this forum has seen better days?
×
×
  • Create New...