Jump to content


Photo

help with script


  • Please log in to reply
16 replies to this topic

#1 scripttednoobie

scripttednoobie
  • Members
  • 9 posts

Posted 07 August 2012 - 06:48 PM

ok, so i just recently started learning about scripts. Can anyone take a look at my script and tell me whats wrong? cuz it runs fine like 2-3 times then the next time after it spazzes out and doesnt do it anymore. sometimes the clicking action doesnt even work. TIA for all who looked

CoordMode, Mouse, screen
MouseClick, left, 1222, 338
sleep, 3000
MouseClickDrag, left, 1086, 893, 1110, 251, 4
sleep, 1500
MouseClickDrag, left, 1086, 893, 1110, 251, 4
sleep, 1500
MouseClickDrag, left, 1086, 893, 1110, 251, 4
sleep, 1500
MouseClickDrag, left, 1086, 893, 1110, 251, 4
sleep, 1500
MouseClickDrag, left, 1086, 893, 1110, 251, 4
sleep, 2000
MouseClick, left, 936, 881
sleep, 2000
MouseClick, left, 1160, 992
sleep, 2000
MouseClick, right
sleep, 1000
MouseClick, left, 1080,353
sleep, 10000
MouseClick, left, 1130, 903
sleep, 1000
MouseClick, left, 1130, 903
sleep, 1000
MouseClick, left, 820, 316
sleep, 1000
Send, % RandomChar()
RandomChar()
{
mychars := "abcdeghijklmnopqrstuvwxyz"
Random, mychar, 5, StrLen(mychars)
Return Substr(mychars, mychar, 10)
}
Sleep, 500
Send, {SHIFTDOWN}2{SHIFTUP}
Sleep, 500
Send, tyrig.klo ;TYPE EMAIL
Sleep 2000
MouseClick, left, 887, 442
Sleep, 1000
Send, password
Sleep, 1000
MouseClick, left, 1105, 571
Sleep, 5000
MouseClick, left, 955,583
sleep, 8000
MouseClick, left, 1028, 919
sleep, 5000
MouseClickDrag, left, 1169, 866, 1191, 222, 4
sleep, 3000
MouseClick, left, 979, 783
sleep, 3000
MouseClick, left, 925, 849
sleep, 3000
MouseClick, left, 947, 772
sleep, 3000

its for a game on iphone btw and im using my computer as a remote controller. and the script runs my iphone through that.

#2 dylan904

dylan904
  • Members
  • 706 posts

Posted 07 August 2012 - 07:58 PM

This would be at least something to start with improving...
CoordMode, Mouse, screen
MouseClick, left, 1222, 338
sleep, 3000
Loop, 5     ;Repeat everything within the brackets 5 times to aviod redundance.
{
   MouseClickDrag, left, 1086, 893, 1110, 251, 4
   sleep, 1500
}
MouseClick, left, 936, 881
sleep, 2000
MouseClick, left, 1160, 992
sleep, 2000
MouseClick, right
sleep, 1000
MouseClick, left, 1080,353
sleep, 10000
MouseClick, left, 1130, 903
sleep, 1000
MouseClick, left, 1130, 903
sleep, 1000
MouseClick, left, 820, 316
sleep, 1000
Send, % RandomChar()    ;Note that if you use this, it will not always be 10 characters long.

Sleep, 500
Send, {SHIFTDOWN}2{SHIFTUP}
Sleep, 500
Send, tyrig.klo ;TYPE EMAIL
Sleep 2000
MouseClick, left, 887, 442
Sleep, 1000
Send, password
Sleep, 1000
MouseClick, left, 1105, 571 
Sleep, 5000
MouseClick, left, 955,583
sleep, 8000
MouseClick, left, 1028, 919
sleep, 5000
MouseClickDrag, left, 1169, 866, 1191, 222, 4
sleep, 3000
MouseClick, left, 979, 783
sleep, 3000
MouseClick, left, 925, 849
sleep, 3000
MouseClick, left, 947, 772
sleep, 3000
return

RandomChar()    ;I wouldn't suggest keeping a function in the auto-execute section.
{
   mychars := "abcdeghijklmnopqrstuvwxyz"
   Random, mychar, 5, StrLen(mychars)
   Return Substr(mychars, mychar, 10)
}

Esc::ExitApp


#3 scripttednoobie

scripttednoobie
  • Members
  • 9 posts

Posted 07 August 2012 - 08:16 PM

oh ok i see what you did there with the loop, 5. that does make it alot simpler. and the randomchar function i wasnt sure what it was. i was just going by what a friend had given me as an example. thanks a ton :)

#4 scripttednoobie

scripttednoobie
  • Members
  • 9 posts

Posted 08 August 2012 - 04:26 AM

if i wanted to write a script to take a screenshot of my desktop and save it in a folder on my desktop how would i go about executing that function. sorry im still new to this scripting business. thanks in advance

#5 girlgamer

girlgamer
  • Moderators
  • 2039 posts

Posted 08 August 2012 - 04:42 AM

How would you create this same effect if you were doing it by hand without a script? Exactly what steps and in what order would you need to accomplish what you want to do? Write those steps down in the exact order you would have to do them -- all clicks, sends, etc. That is the outline for the script you're thinking of. Once you have that then you can begin to write a script to do it.

#6 dylan904

dylan904
  • Members
  • 706 posts

Posted 08 August 2012 - 05:17 AM

Gdip...
This should work to your liking, it replaces the prt sc functionality while running, the only difference is it will now be saved to a file in your scripts directory in a folder named PrintScreens...
!PrintScreen::
PrintScreen::
If (A_ThisHotkey = "!PrintScreen")
   WinGetPos, X, Y, Width, Height, A
Else
   X := 0, Y := 0, Width := A_ScreenWidth, Height := A_ScreenHeight
While (FileExist("PrintScreens\" . A_Index . ".png"))
   FileNum := A_Index
++FileNum
pToken := Gdip_Startup()
Gdip_SaveBitmapToFile(pBitmap := Gdip_BitmapFromScreen(X . "|" . Y . "|" . Width . "|" . Height), "PrintScreens\" . FileNum . ".png")
Gdip_DisposeImage(pBitmap)
Gdip_Shutdown(pToken)
return


#7 scripttednoobie

scripttednoobie
  • Members
  • 9 posts

Posted 08 August 2012 - 05:32 AM

ok thanks for the replies. ill try it out once i get home and ill tell you how it went

@girlgamer well i know how to do it manually but writing a script is confusing especially if you dont know the commands for it. which is where i was getting at. i browse through the help and tutorials but i get so lost into all those lingo. i spent about 4 hrs last night just trying to write the original post >.<;;

@dylan904 i appreciate the time you take to help me write those scripts. <3 if theres anything you need. dont hesitate to ask

#8 dylan904

dylan904
  • Members
  • 706 posts

Posted 08 August 2012 - 05:45 AM

I guess I'll go ahead and mention that you need to get the Gdip.ahk library in the link in my last post and put it in your script, or any other location before you can run that.

#9 scripttednoobie

scripttednoobie
  • Members
  • 9 posts

Posted 08 August 2012 - 05:49 AM

ya i saw the hyperlink to it. so it goes into my saved .ahk file? or what do you mean put it in my script? and if i wanted to do it two seperate occassions i would have to put that script into my existing script twice correct?

#10 dylan904

dylan904
  • Members
  • 706 posts

Posted 08 August 2012 - 05:55 AM

You can just paste it to the bottom of your script, or you can save it to its own file at this location. Just run the msgbox MsgBox % A_AhkPath . "\Lib\"

#11 girlgamer

girlgamer
  • Moderators
  • 2039 posts

Posted 08 August 2012 - 06:04 AM

Just so you know -- the steps are the script. If you send a key to a window you use the send command if you have to click you use the click command if you need to position the mouse on the screen somewhere you use the MouseMove command. The actions you need to do manually are the same ones your script will have to do as well. finding the right commands is just a matter of taking one step from your list and trying to find the command or commands that might do that in the autohotkey help file. Honestly, the most difficult part is getting the steps down in sufficient detail first so the script can do them.

#12 scripttednoobie

scripttednoobie
  • Members
  • 9 posts

Posted 08 August 2012 - 07:57 AM

ok so what im finding out is that every 2-3 times it does something wierd like spazzzes out. like sometimes it ignores my click command totally. theres nothing wrong with the script is there...? im thinking that it has to do with my connection. any insight?

#13 girlgamer

girlgamer
  • Moderators
  • 2039 posts

Posted 08 August 2012 - 09:15 AM

If it works at all it works. the issue is timing. maybe you're sending too fast? Maybe you're not waiting long enough to do the next command. Speed can be a serious issue in certain apps. Inserting sleeps between read or write commands can help a lot. Sometimes you just have to figure out exactly what part of the script is trippin' on you.

#14 scripttednoobie

scripttednoobie
  • Members
  • 9 posts

Posted 08 August 2012 - 11:21 AM

MouseClickDrag, left, x, y, x, y

IS such a pain!! only way to scroll...but so hard to be precise. hehe thanks a bunch for all the info im almost done with my script! when im done ill post it on here for you guys to see. dont be to rough on it though, hehe just a bunch of clicks and whatnot. anyways im happy that it was working. again thank you for replies

#15 dylan904

dylan904
  • Members
  • 706 posts

Posted 08 August 2012 - 04:21 PM

No, you should be able to use Send {LButton Down}{WheelDown}{LButton Up}, yes?
To send more than 1 scroll, put a space and the number of scrolls after WheelDown or WheelUp.